1 |
use strict; |
2 |
use warnings; |
3 |
|
4 |
=head1 NAME |
5 |
|
6 |
A3C::Action::SyncOrganization |
7 |
|
8 |
=cut |
9 |
|
10 |
package A3C::Action::SyncOrganization; |
11 |
use base qw/A3C::Action Jifty::Action/; |
12 |
|
13 |
use A3C::LDAP; |
14 |
|
15 |
use Data::Dump qw/dump/; |
16 |
|
17 |
use Jifty::Param::Schema; |
18 |
use Jifty::Action schema { |
19 |
|
20 |
param org_uid => |
21 |
label is _('Organization'), |
22 |
available are defer { |
23 |
my $ldap = A3C::LDAP->new; |
24 |
my $coll = A3C::Model::hrEduOrgCollection->new; |
25 |
# unlimit, order_by works, other way around doesn't! |
26 |
$coll->unlimit; |
27 |
$coll->order_by( column => $ldap->link->{value_from}, order => 'ASC' ); |
28 |
[{ |
29 |
display_from => $ldap->link->{display_from}, |
30 |
value_from => $ldap->{link}->{value_from}, |
31 |
collection => $coll, |
32 |
}]; |
33 |
}, |
34 |
render as 'Select'; |
35 |
|
36 |
}; |
37 |
|
38 |
=head2 sticky_on_success |
39 |
|
40 |
=head2 sticky_on_failure |
41 |
|
42 |
Keep values entered after submit of action |
43 |
|
44 |
=cut |
45 |
|
46 |
sub sticky_on_success { 1 } |
47 |
sub sticky_on_failure { 1 } |
48 |
|
49 |
=head2 take_action |
50 |
|
51 |
=cut |
52 |
|
53 |
sub take_action { |
54 |
my $self = shift; |
55 |
|
56 |
if ( $self->result->success ) { |
57 |
|
58 |
my $ldap = A3C::LDAP->new; |
59 |
my $org_uid = $self->argument_value( 'org_uid' ); |
60 |
my $person_filter = $ldap->link->{person_filter}; |
61 |
|
62 |
my $org_class = Jifty->app_class('Model', $ldap->objectClass->{organization} ); |
63 |
|
64 |
my $coll = $ldap->collection( $ldap->objectClass->{person}, filter => "($person_filter=$org_uid)" ); |
65 |
|
66 |
$self->result->content( 'synced-users' => $coll ); |
67 |
|
68 |
$self->result->message( _('Synced %1 users from %2', $coll->count, $org_uid) ); |
69 |
|
70 |
# } else { |
71 |
# $self->result->error(); |
72 |
} |
73 |
|
74 |
return 1; |
75 |
} |
76 |
|
77 |
1; |
78 |
|