/[A3C]/lib/A3C/Action/SyncOrganization.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /lib/A3C/Action/SyncOrganization.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 66 - (hide annotations)
Wed Apr 9 23:14:47 2008 UTC (14 years, 4 months ago) by dpavlin
File size: 1269 byte(s)
rename User model to Person
1 dpavlin 55 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 Jifty::Param::Schema;
16     use Jifty::Action schema {
17    
18     param cn =>
19     label is _('Organization'),
20     available are defer {
21     my $coll = A3C::Model::OrganizationCollection->new;
22     # unlimit, order_by works, other way around doesn't!
23     $coll->unlimit;
24     $coll->order_by( column => 'cn', order => 'ASC' );
25     [{
26     display_from => 'name',
27     value_from => 'cn',
28     collection => $coll,
29     }];
30     },
31     render as 'Select';
32    
33     };
34    
35     sub sticky_on_success { 1 }
36     sub sticky_on_failure { 1 }
37    
38     =head2 take_action
39    
40     =cut
41    
42     sub take_action {
43     my $self = shift;
44    
45     if ( $self->result->success ) {
46    
47     my $organization = A3C::Model::Organization->new;
48     my $cn = $self->argument_value( 'cn' );
49     $organization->load_by_cols( cn => $cn ) or die "can't load organization";
50    
51     my $ldap = A3C::LDAP->new;
52 dpavlin 66 my $coll = $ldap->collection( 'Person', filter => "(HrEduPersonHomeOrg=$cn)" );
53 dpavlin 55
54     $self->result->content( 'synced-users' => $coll );
55    
56 dpavlin 58 $self->result->message( sprintf('Synced %d users from %s (%s)', $coll->count, $organization->name, $cn) );
57 dpavlin 55
58     # } else {
59     # $self->result->error();
60     }
61    
62     return 1;
63     }
64    
65     1;
66    

  ViewVC Help
Powered by ViewVC 1.1.26