/[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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 106 - (show annotations)
Thu May 1 17:06:02 2008 UTC (14 years, 3 months ago) by dpavlin
File size: 1405 byte(s)
massive re-structuring to enable models specified in configuration file

- version bump [0.04]
- SyncOrganization now accept org_uid as argument
- objectClass(es) for person and organization are now in config.yml
  as well as link between them (filter on person)
- config.yml is now checked for validity in A3C::LDAP
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::OrganizationCollection->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 sub sticky_on_success { 1 }
39 sub sticky_on_failure { 1 }
40
41 =head2 take_action
42
43 =cut
44
45 sub take_action {
46 my $self = shift;
47
48 if ( $self->result->success ) {
49
50 my $ldap = A3C::LDAP->new;
51 my $org_uid = $self->argument_value( 'org_uid' );
52 my $person_filter = $ldap->link->{person_filter};
53
54 my $org_class = Jifty->app_class('Model', $ldap->objectClass->{organization} );
55
56 my $coll = $ldap->collection( $ldap->objectClass->{person}, filter => "($person_filter=$org_uid)" );
57
58 $self->result->content( 'synced-users' => $coll );
59
60 $self->result->message( _('Synced %1 users from %2', $coll->count, $org_uid) );
61
62 # } else {
63 # $self->result->error();
64 }
65
66 return 1;
67 }
68
69 1;
70

  ViewVC Help
Powered by ViewVC 1.1.26