1 |
package A3C::View::LDAP; |
2 |
|
3 |
=head1 NAME |
4 |
|
5 |
A3C::View::LDAP |
6 |
|
7 |
=head1 DESCRIPTION |
8 |
|
9 |
Provide LDAP interface |
10 |
|
11 |
=cut |
12 |
|
13 |
use strict; |
14 |
use warnings; |
15 |
|
16 |
use Jifty::View::Declare -base; |
17 |
use Data::Dump qw/dump/; |
18 |
|
19 |
template 'sync' => page { |
20 |
|
21 |
h1 { _('Sync school from LDAP') } |
22 |
|
23 |
my $action = new_action( |
24 |
class => 'SyncOrganization', |
25 |
moniker => 'sync-organization' |
26 |
); |
27 |
|
28 |
form { |
29 |
render_action( $action => [ 'org_uid' ] ); |
30 |
form_submit( label => _('Sync Organization') ); |
31 |
}; |
32 |
|
33 |
if ( my $users = $action->result->content('synced-users') ) { |
34 |
ol { |
35 |
while (my $user = $users->next) { |
36 |
li { |
37 |
span { $user->cn } |
38 |
tt { { class is 'email' } '<' . $user->mail . '>' } |
39 |
} |
40 |
} |
41 |
} |
42 |
} |
43 |
|
44 |
}; |
45 |
|
46 |
use Encode qw/decode/; |
47 |
|
48 |
template 'search' => page { |
49 |
h1 { _('LDAP data about Schools in system') }; |
50 |
|
51 |
my $action = new_action( |
52 |
class => 'SearchLDAP', |
53 |
moniker => 'search-ldap' |
54 |
); |
55 |
|
56 |
form { |
57 |
render_action( $action => [ 'base', 'filter', 'sizelimit' ] ); |
58 |
form_submit( label => _('Search LDAP') ); |
59 |
}; |
60 |
|
61 |
if ( my $search = $action->result->content( 'current_search' ) ) { |
62 |
div { |
63 |
while ( my $entry = $search->shift_entry ) { |
64 |
#warn $entry->dump; |
65 |
ul { |
66 |
foreach my $attr ( $entry->attributes ) { |
67 |
li { |
68 |
tt { $attr } |
69 |
my $vals = decode('utf-8', join('<b>•</b>', $entry->get_value( $attr ) )); |
70 |
span { outs_raw( $vals ) } |
71 |
} |
72 |
} |
73 |
} |
74 |
} |
75 |
} |
76 |
} |
77 |
}; |
78 |
|
79 |
|
80 |
|