Line # Revision Author
1 8 ahitrov@rambler.ru %# vim:syn=mason
2 <select name="<% $name %>"<% $prop->{multiple} && ' multiple' %><% $prop->{size} && ' size="'.$prop->{size}.'"' %>>
3 %
4 % if ($prop->{allow_null}) {
5 %
6 <option value="" <% defined $check ? '' : 'selected' %>>--- не указано ---</option>
7 %
8 % }
9 %
10 % for my $chain (@chains) {
11 %
12 % my $selected = defined $chain && ( ref $check eq 'ARRAY' ? grep { $_ eq $chain } @$check : $check eq $chain ? 1 : 0 );
13 % $found++ if $selected;
14 %
15 <option value="<% $chain %>"<% $selected ? ' selected' : '' %>><% $chain %></option>
16 %
17 % }
18 %
19 % #if used not allowed value
20 % if ( $check and not $found ) {
21 %
22 <option value="<% $check %>" selected style="color:red;"><% $check %></option>
23 %
24 % }
25 %
26 </select>
27 <%args>
28
29 $object => undef
30 $prop => undef
31 $name => undef
32 $values => []
33 $check => undef
34
35 </%args>
36 <%init>
37
38 my $found = 0;
39 my @chains = ();
40
41 if (my $method = $prop->{planets_user_method}) {
42 my $user = $object->$method;
43 if ($user) {
44 push(@chains, "users/" . $user->login);
45 foreach my $member ($user->member_of) {
46 next if $member->{'friendly_status'} < 3;
47 push @chains, 'community/'.$member->{'login'}
48 }
49 }
50 }
51 </%init>