Initial commit
[manu/RT-Extension-UserDetails.git] / html / Elements / ShowUserDetails
1 <span id="toggleuserdetails-<% $id %>">
2 % if ( $Toggle ) {
3 <a href="<% $url %>" onclick="ahah('<% $url |n %>&Toggle=0', 'toggleuserdetails-<% $id |n %>'); return false;" <img src="<% RT->Config->Get('WebPath') %>/NoAuth/images/userdetails.png" alt="<% loc('Details') %>" title="<% loc('Details') %>" style="border-style: none" /></a>
4 <div id="userdetails">
5 <a href="<% $url %>" onclick="ahah('<% $url |n %>&Toggle=0', 'toggleuserdetails-<% $id |n %>'); return false;" <img src="<% RT->Config->Get('WebPath') %>/NoAuth/images/close.png" alt="<% loc('Close') %>" title="<% loc('Close') %>" style="border-style: none" /></a>
6 <ul>
7 % foreach my $sort (sort { $a <=> $b } keys %attributes) {
8 % my $attr_name = $attributes{$sort}{'AttributeName'};
9 % my $display_name = $attributes{$sort}{'DisplayName'};
10 <li><% loc($display_name) %>: <% $User->$attr_name || '' %></li>
11 % }
12 </ul>
13 </div>
14 % } else {
15 <a href="<% $url %>" onclick="ahah('<% $url |n %>&Toggle=1', 'toggleuserdetails-<% $id |n %>'); return false;" <img src="<% RT->Config->Get('WebPath') %>/NoAuth/images/userdetails.png" alt="<% loc('Details') %>" title="<% loc('Details') %>" style="border-style: none" /></a>
16 % }
17 </span>
18
19 <%init>
20 my $url = RT->Config->Get('WebPath') ."/Helpers/Toggle/UserDetails?id=". $id;
21
22 # Default Attributes to display
23 # SortOrder => { AttributeName => '',
24 #                DisplayName   => '', }
25 unless ( RT->Config->Get('UserDetailsAttributes') ) {
26     RT->Config->Set('UserDetailsAttributes',
27         1 => { AttributeName => 'RealName',
28                DisplayName => 'Real Name',
29              },
30         2 => { AttributeName => 'EmailAddress',
31                DisplayName => 'Email',
32              },
33         3 => { AttributeName => 'Organization',
34                DisplayName => 'Organization',
35              },
36         );
37 }
38
39 my %attributes = RT->Config->Get('UserDetailsAttributes');
40
41
42
43 my $User;
44
45 # Load User only if needed
46 if ( $Toggle ) {
47     $User = RT::User->new( $session{'CurrentUser'} );
48     $User->Load( $id );
49 }
50
51 </%init>
52
53 <%args>
54 $id
55 $Toggle => 0
56 </%args>
57