/[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 137 - (hide annotations)
Fri May 30 20:56:18 2008 UTC (14 years, 2 months ago) by dpavlin
File size: 1503 byte(s)
document why are we sticky
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 dpavlin 106 use Data::Dump qw/dump/;
16    
17 dpavlin 55 use Jifty::Param::Schema;
18     use Jifty::Action schema {
19    
20 dpavlin 106 param org_uid =>
21 dpavlin 55 label is _('Organization'),
22     available are defer {
23 dpavlin 106 my $ldap = A3C::LDAP->new;
24 dpavlin 123 my $coll = A3C::Model::hrEduOrgCollection->new;
25 dpavlin 55 # unlimit, order_by works, other way around doesn't!
26     $coll->unlimit;
27 dpavlin 106 $coll->order_by( column => $ldap->link->{value_from}, order => 'ASC' );
28 dpavlin 55 [{
29 dpavlin 106 display_from => $ldap->link->{display_from},
30     value_from => $ldap->{link}->{value_from},
31 dpavlin 55 collection => $coll,
32     }];
33     },
34     render as 'Select';
35    
36     };
37    
38 dpavlin 137 =head2 sticky_on_success
39    
40     =head2 sticky_on_failure
41    
42     Keep values entered after submit of action
43    
44     =cut
45    
46 dpavlin 55 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 dpavlin 106 my $org_uid = $self->argument_value( 'org_uid' );
60     my $person_filter = $ldap->link->{person_filter};
61 dpavlin 55
62 dpavlin 106 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 dpavlin 55 $self->result->content( 'synced-users' => $coll );
67    
68 dpavlin 106 $self->result->message( _('Synced %1 users from %2', $coll->count, $org_uid) );
69 dpavlin 55
70     # } else {
71     # $self->result->error();
72     }
73    
74     return 1;
75     }
76    
77     1;
78    

  ViewVC Help
Powered by ViewVC 1.1.26