12 |
|
|
13 |
use A3C::LDAP; |
use A3C::LDAP; |
14 |
|
|
15 |
|
use Data::Dump qw/dump/; |
16 |
|
|
17 |
use Jifty::Param::Schema; |
use Jifty::Param::Schema; |
18 |
use Jifty::Action schema { |
use Jifty::Action schema { |
19 |
|
|
20 |
param cn => |
param org_uid => |
21 |
label is _('Organization'), |
label is _('Organization'), |
22 |
available are defer { |
available are defer { |
23 |
my $coll = A3C::Model::OrganizationCollection->new; |
my $ldap = A3C::LDAP->new; |
24 |
|
my $coll = A3C::Model::hrEduOrgCollection->new; |
25 |
# unlimit, order_by works, other way around doesn't! |
# unlimit, order_by works, other way around doesn't! |
26 |
$coll->unlimit; |
$coll->unlimit; |
27 |
$coll->order_by( column => 'cn', order => 'ASC' ); |
$coll->order_by( column => $ldap->link->{value_from}, order => 'ASC' ); |
28 |
[{ |
[{ |
29 |
display_from => 'name', |
display_from => $ldap->link->{display_from}, |
30 |
value_from => 'cn', |
value_from => $ldap->{link}->{value_from}, |
31 |
collection => $coll, |
collection => $coll, |
32 |
}]; |
}]; |
33 |
}, |
}, |
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 } |
sub sticky_on_success { 1 } |
47 |
sub sticky_on_failure { 1 } |
sub sticky_on_failure { 1 } |
48 |
|
|
55 |
|
|
56 |
if ( $self->result->success ) { |
if ( $self->result->success ) { |
57 |
|
|
|
my $organization = A3C::Model::Organization->new; |
|
|
my $cn = $self->argument_value( 'cn' ); |
|
|
$organization->load_by_cols( cn => $cn ) or die "can't load organization"; |
|
|
|
|
58 |
my $ldap = A3C::LDAP->new; |
my $ldap = A3C::LDAP->new; |
59 |
my $coll = $ldap->collection( 'Person', filter => "(HrEduPersonHomeOrg=$cn)" ); |
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 ); |
$self->result->content( 'synced-users' => $coll ); |
67 |
|
|
68 |
$self->result->message( sprintf('Synced %d users from %s (%s)', $coll->count, $organization->name, $cn) ); |
$self->result->message( _('Synced %1 users from %2', $coll->count, $org_uid) ); |
69 |
|
|
70 |
# } else { |
# } else { |
71 |
# $self->result->error(); |
# $self->result->error(); |