<?php
/*
* @package LabCMS
* @copyright (c) 2006 Alexander Levin aka Loki (loki_angel@mail.ru)
* @support http://labcms.ru
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*/

Tpl::i()->assign(array(
'access_delete'=>access('delete'),
'access_edit'=>access('edit'),
'access_add'=>access('add')
));

switch(true)
{
	case($_GET['action']=='add' && access('add')):
		$mode="add";
		include dirname(__FILE__)."/edit_user.php";
	break;
	
	case($_GET['action']=='edit' && access('edit')):
		$mode="edit";
		include dirname(__FILE__)."/edit_user.php";
	break;
	
	case($_GET['action']=='clones' && access('read')):
		include dirname(__FILE__)."/find_clones.php";
		addBreadcrumb('Поиск клонов');
	break;
	case(access('read')):
		include dirname(__FILE__)."/users_list.php";
	break;
	default:
		LabCMS::i()->error403();
}

	
function get_child_groups($parent_id=0, $level=0, &$groups=array())
{
	$result=Db::i()->select("SELECT group_id, group_name FROM ?_groups WHERE parent_id=? ORDER BY group_name", $parent_id);
	if (is_array($result))
	{
		foreach($result as $group)
		{
			$margin="";
			for($i=0; $i<$level*3; $i++) $margin.="&nbsp;";
			$groups[$group['group_id']]=array('name_html'=>$margin.htmlspecialchars($group['group_name']), 'disabled'=>($group['group_id']==-1));
			get_child_groups($group['group_id'], $level+1, $groups);
		}
		return $groups;
	}
}