Line # Revision Author
1 3 ahitrov@rambler.ru <script language="JavaScript">
2 <!--
3 var dom = (document.getElementById) ? true : false;
4 var nn4 = (document.layers) ? true : false;
5 var ie4 = (!dom && document.all) ? true : false;
6 var layerOk;
7
8 if (dom || ie4 || nn4) { layerOk = 1; }
9 else { layerOk = 0; }
10
11 var layerRef, styleRef, showVar, hideVar, showDVar, hideDVar;
12 var srcOpen = '/contenido/i/open11x11.gif';
13 var srcClose = '/contenido/i/close11x11.gif';
14
15 var imageRef;
16
17 if (nn4) {
18 layerRef = "document.layers.";
19 styleRef = "";
20 imageRef = "";
21 showDVar = "'block'";
22 hideDVar = "'none'";
23 showVar = "'show'";
24 hideVar = "'hide'";
25 } else {
26 layerRef = "document.all.";
27 imageRef = "";
28 styleRef = ".style";
29 showDVar = "'block'";
30 hideDVar = "'none'";
31 showVar = "'visible'";
32 hideVar = "'hidden'";
33 }
34
35 if (dom) {
36 layerRef = "document.getElementById('";
37 styleRef = "').style";
38 imageRef = "')";
39 }
40
41 function changeDiv( divID ) {
42 if (eval(layerRef + 'slinks' + divID + styleRef + '.visibility') == 'hidden') {
43 showDiv(divID);
44 } else {
45 hideDiv(divID);
46 }
47 }
48
49 function showDiv( divID ) {
50 if (layerOk) {
51 eval(layerRef + 'slinks' + divID + styleRef + '.visibility=' + showVar);
52 eval(layerRef + 'slinks' + divID + styleRef + '.display=' + showDVar);
53 eval(layerRef + 'simg' + divID + imageRef + '.src = "' + srcClose + '"');
54 }
55 }
56
57 function hideDiv( divID ) {
58 if (layerOk) {
59 eval(layerRef + 'slinks' + divID + styleRef + '.visibility=' + hideVar);
60 eval(layerRef + 'slinks' + divID + styleRef + '.display=' + hideDVar);
61 eval(layerRef + 'simg' + divID + imageRef + '.src = "' + srcOpen + '"');
62 }
63 }
64
65 //-->
66 </script>
67 <fieldset>
68 <legend>������ � �������� (��������) �����<sup>1</sup></legend>
69 <table height="400" border=0>
70 <tr valign="top">
71 <td>
72 <form action="store_user_sections.html" method="POST">
73 <input type="submit" value="��������� ������" class="input_btn">
74
75 % my @sections = $luser->groups();
76 % my $sections_ = {};
77 % for my $secti (@sections) {
78 % $sections_->{$secti} = 1;
79 % my @trace = $keeper->get_section_by_id($secti)->trace();
80 % for my $traci (@trace) {
81 % next if (exists $sections_->{$traci});
82 % $sections_->{$traci} = 1;
83 % }
84 % }
85 % my @fullsections = keys(%{ $sections_ });
86 % my $root = $keeper->get_section_by_id(1);
87 <ul style="font-size:13px;font-family:Tahoma;">
88 % user_sections_tree($root, \@fullsections, \@sections, 0);
89 </ul>
90
91 <input type="hidden" name="login" value="<% $luser->login %>">
92 <input type="submit" value="��������� ������" class="input_btn">
93 </form>
94 </td>
95 </tr>
96 </table>
97 </fieldset>
98
99 <!-- ���������� -->
100 <fieldset>
101 <legend>����������</legend>
102 <table width="100%" cellspacing="5" cellpadding="0" class="tform" height="50">
103 <tr>
104 <th valign=top>1)</th>
105 <td width="100%">������ � ������ ������������� ���� ������ �� ���� �������� �������� ���� ������;<br></td>
106 </tr>
107 </table>
108 </fieldset>
109
110 <%args>
111
112 $luser => undef
113
114 </%args>
115
116 <%init>
117 return undef if !ref($luser);
118 return undef unless ($luser->{attributes}->{groups});
119
120 my $root_section = $keeper->get_section_by_id($Contenido::Section::ROOT || 1);
121
122 sub user_sections_tree
123 {
124 my ($sect, $fullsections, $sections, $depth) = @_;
125 my $count_checked = 0;
126
127 my @childs = $sect->childs(1);
128
129 if ($sect->id)
130 {
131 my $checked = (grep {$_ == $sect->{id} } @{ $sections }) ? ' checked' : '';
132 $count_checked++ if( grep {$_ == $sect->{id} } @{ $fullsections } );
133
134 if (@childs && $sect->id != 1) { $m->out("<a title=\"��������/�������\" style=\"width:22px;text-decoration:none;\" href=\"javascript:changeDiv('$sect->{id}');\"><img id=\"simg$sect->{id}\" src=\"/contenido/i/open11x11.gif\" width=\"11\" height=\"11\" border=\"0\"></a>"); }
135 else { $m->out( '<span style="width:22px;"></span>' ); }
136 $m->out("<input type=\"checkbox\" name=\"section_$sect->{id}\" value=\"1\" $checked>");
137 $m->out("$sect->{name}<br>\n");
138 }
139
140 if (@childs)
141 {
142 my $check_childs = undef;
143 if ($depth > 0) { $m->out( '<div style="visibility:hidden;display:none;" id="slinks'.$sect->id.'">'."\n" ); }
144 $m->out( '<ul>'."\n" );
145 foreach my $child_id (@childs)
146 {
147 my $child = $keeper->get_section_by_id($child_id);
148 $check_childs += user_sections_tree($child, $fullsections, $sections, $depth + 1);
149 }
150 $m->out("</ul>\n");
151 if ($depth > 0) { $m->out( '</div>'."\n" ); }
152 if ($check_childs > 0 && $sect->id != 1) { $m->out( "<script language=\"JavaScript\"><!--\nshowDiv('$sect->{id}');\n//-->\n</script>\n" ); }
153 }
154 return $count_checked;
155 }
156
157 </%init>