搜索 |
此操作是针对把栏目也存到数据库,然后能操作什么栏目就显示什么栏目的方法
$auth_one=M("AuthGroupAccess");
$map_one['uid']=session('myadmin.id');
$auth_one_info=$auth_one->where( $map_one)->getField('group_id',true);
$auth_two=M("AuthGroup");
$map_two['id']=array('in',$auth_one_info);
$auth_two_info=$auth_two->where( $map_two)->getField('rules',true);
$auth_there=M("AuthRule");
$ids=array();
foreach ($auth_two_info as $key => $value) {
$ids=array_merge($ids,explode(",",$value));
}
// 这里可以根据权限设置查询条件
// 例如超级管理员的话就查询全部
$map_th['id']=array('in',$ids);
$auth_there_info=$auth_there->where($map_th)->field("pid,title,name")->select();
$this->assign('canDo',$auth_there_info);
dump($auth_there_info);