<?php
class admin_menuControl extends skymvc{
	
	function __construct(){
		parent::__construct();	
	}
	
	public function  menu(){
		$this->loadModel(array("admin_group","navbar"));
		$id=get_post('id','i');
		$where=array(
			"pid"=>0,
			"group_id"=>2,
			"status"=>2,
			//"id"=>$id
		);
		$option=array(
			"where"=>$where,
			"order"=>" orderindex ASC",
		);
		$permission=unserialize($this->admin_group->selectOne(array("where"=>array("id"=>$_SESSION['ssadmin']['group_id']),"fields"=>"content")));
		$_SESSION['ssadmin']['permission']=$permission;
		$data=$this->navbar->select($option,$rscount);
		if($data){
			foreach($data as $k=>$v){
				$child=$this->navbar->select(array("where"=>array("pid"=>$v['id']),"order"=>" orderindex ASC"));
				if($child){
					foreach($child as $kk=>$vv){
						if(!$this->checkpermission($_SESSION['ssadmin']['permission'],$vv['m'],$vv['a'])){
							if(!TESTMODEL && !$_SESSION['ssadmin']['isfounder']) unset($child[$kk]);
						}
					}
				}
				$v['child']=$child;
				$data[$k]=$v;
			}
		}
		return $data;
	}
	
}
?>