--- lib/A3C/View.pm 2008/03/30 15:02:55 40 +++ lib/A3C/View.pm 2008/04/10 21:33:37 71 @@ -9,12 +9,8 @@ use Data::Dump qw/dump/; -template '/skole' => page { - h1 { _('Schools in system') }; - show 'skole_sve'; -}; - -private template 'skole_sve' => sub { +template 'ldap' => page { + h1 { _('LDAP data about Schools in system') }; my $ldap = A3C::LDAP->new; div { $ldap->search( @@ -22,7 +18,7 @@ filter => '(objectClass=hrEduOrg)', sizelimit => 10, ); - while ( my $entry = $ldap->next ) { + while ( my $entry = $ldap->current_search->shift_entry ) { #warn $entry->dump; ul { foreach my $attr ( $entry->attributes ) { @@ -36,3 +32,62 @@ } }; +template 'people' => page { + + h1 { _('Find people') } + + my $action = new_action( + class => 'SearchPerson', + moniker => 'search-users', + sticky_on_success => 1, + sticky_on_failure => 1, + ); + + + form { + render_action( $action => [ 'uid_contains', 'cn_contains' ] ); + form_submit( label => _('Find someone') ); + }; + +# warn dump( $action->result->content ); + + if ( my $search = $action->result->content('search') ) { + div { sprintf(_('Found %d results'), $search->count ) } + ol { + while (my $user = $search->next) { + li { + span { $user->cn } + tt { $user->uid } + } + } + } + } + +}; + +template 'sync' => page { + + h1 { _('Sync school from LDAP') } + + my $action = new_action( + class => 'SyncOrganization', + moniker => 'sync-organization' + ); + + form { + render_action( $action => [ 'cn' ] ); + form_submit( label => _('Sync Organization') ); + }; + + if ( my $users = $action->result->content('synced-users') ) { + ol { + while (my $user = $users->next) { + li { + span { $user->cn } + tt { { class is 'email' } '<' . $user->mail . '>' } + } + } + } + } + +};