Revision 195 (by ahitrov, 2012/03/15 18:26:13) Users plugin
%# vim:syn=mason:
%	users_index_tree( $sect, 0, \$line, $level, $mode, $profile, $width_limit, $root );
<%args>

	$root => 1
	$level => 3
	$mode => 1
	$width_limit => undef

</%args>
<%init>
	my $profile = $m->comp('/contenido/components/context.msn', name => 'profile');

	sub users_index_tree
	{
		my ($sect, $offset, $line_ref, $count_offset, $viewmode, $profile, $width_limit, $root) = @_;
		my $section_access = $user->section_accesses($user, $sect->{id});

		my $spacer = '';
		for(my $c=1; $c<$offset; $c++)
		{
			$spacer = $spacer.(($c == $offset-1) ? '&nbsp;&nbsp;&raquo;&nbsp;&nbsp;' : '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');
		}
		if( $sect->{id} && ($sect->{id} != 1) && ($offset != 0) && $section_access > 0)
		{
			$$line_ref++;

			my $href = 'sections.html?id='.$sect->id;

			my $sname = $sect->name();
			$sname = substr($sname, 0, $width_limit - $offset).' ...' if defined $width_limit && $offset + length($sname) > $width_limit;
			my $html_sect = (!$sect->status ? '<span class="hiddensect">' : '').($section_access ? '<a href="'.$href.'">' : '').$sname.'&nbsp;' . ($section_access ? '</a>' : '') . '&nbsp;'.(!$sect->status ? '&nbsp; (�������)</span>' : $sect->status == 3 ? '&nbsp;(��������)' : '');
			my $style = ($offset == 1) ? ($viewmode ? ' style="font-size:110%;"':' style="font-size:95%;"') : '';

			$m->out(<<EOT);
<tr>
<td align="right">&nbsp;${$line_ref}&nbsp;<a href="section.html?id=$sect->{id}&move=up&ret=$root"><img src="/contenido/i/ico-up-9x10.gif" border=0 alt="����������� ������ �� ��� �����"></a>&nbsp;<a href="section.html?id=$sect->{id}&move=down&ret=$root"><img src="/contenido/i/ico-down-9x10.gif" border=0 alt="����������� ������ �� ��� ����"></a></td>
<td><table cellpadding="0" cellspacing="0" border="0">
	<tr valign="top">
	<td width="10">&nbsp;</td>
	<td>$spacer</td>
	<td nowrap $style>$html_sect</td>
	</tr>
	</table>
</td>
EOT

			if ($viewmode)
			{
				my $fhref = '/contenido/?set_context=filter-'.$sect->id();
				$m->out(qq^\n<td align="center" nowrap><a href="$fhref">���.������</a>^);
				$m->out(qq^&nbsp;&nbsp;&nbsp;<a href="document.html?sect_id=$sect->{id}">���.�����</a>^) if $section_access == 2;
				$m->out("</td>");
			}

			$m->out('</tr>');
		}
		
		my $childs = $sect->{childs} || [];
 		if( ref($childs) && @$childs && $offset < $count_offset )
 		{
 			$offset++;
 			foreach my $child (@$childs)
 			{
				next	if ( $child->class() ne 'users::Section' );
				next	if (! $request->{cCLASSES}->{$child->class()});
 				users_index_tree( $child, $offset, $line_ref, $count_offset, $viewmode, $profile, $width_limit, $root );
 			}
 			$offset--;
 		}
	}

	my $sect = $keeper->get_tree(light=>1, root=>$root);
	return undef unless ref $sect;

	$user->get_accesses();

	my $line = 0;
	$request->{cCLASSES} = {};
	$request->{cCLASSES}->{'users::Section'} = 1;
	if (ref($request->{tab}->{sections}))
	{
		map { $request->{cCLASSES}->{$_} = 1 } (@{ $request->{tab}->{sections} });
	}
	return undef	if (scalar(keys(%{ $request->{cCLASSES} })) == 0);

</%init>