thinkphp RBAC权限节点递归
2016-05-15 15:50
567 查看
Common/function.php //权限节点递归 /** * [getTree description] * @param [type] $node 总权限节点 * @param [type] $access 自身权限节点 * @param integer $pid [description] * @return [type] [description] */ function getTree($node,$access=null,$pid=0){ $tree = array(); foreach ($node as $v) { if(is_array($access)){ $v['access'] = in_array($v['id'], $access) ? 1:0; } if($v['pid'] == $pid){ $v['child'] = getTree($node,$access,$v['id']); $tree[] = $v; } } return $tree; }
//给角色配置节点 public function access(){ $rid = I('rid'); //原有权限 $access = M('access')->where(array('role_id' => $rid))->getField('node_id',true); $node = M('node')->select(); $node1 = getTree($node,$access); $this->display(); }
相关文章推荐
- Windows Server 2012 R2 IIS8.5+PHP(FastCGI)+MySQL环境搭建教程
- Windows Server 2008 R2 IIS7.5+PHP5(FastCGI)+MySQL5环境搭建教程
- PHP语言 -- Smarty函数
- PHP页面之间传递参数的四种方式
- PHP语言 -- Smarty变量
- ntp测试小记
- php压缩与归档扩展总结
- php (适用于初学者)
- 在Ubuntu14.04下安装vsftp服务器
- ThinkPHP 商城属性添加
- PHP联接MySQL
- PHP分页及原理
- 重启PHP
- PHP中MYSQL的连接
- laravel自定义错误输出的内容
- PHP $_SERVER说明详解
- PHPWord生成多篇word文档的时候目录文件冗余bug解决方案
- 检测客户端系统-PHP
- PHP常用函数大全
- win7下匿名ftp的搭建