当前位置: 首页>>代码示例>>PHP>>正文


PHP RBAC::getAccessListSelf方法代码示例

本文整理汇总了PHP中RBAC::getAccessListSelf方法的典型用法代码示例。如果您正苦于以下问题:PHP RBAC::getAccessListSelf方法的具体用法?PHP RBAC::getAccessListSelf怎么用?PHP RBAC::getAccessListSelf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RBAC的用法示例。


在下文中一共展示了RBAC::getAccessListSelf方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getAccessList


//.........这里部分代码省略.........
                         		$table['role']." as role,".
                         		$table['user']." as user,".
                         		$table['access']." as access ,".
                         		$table['node']." as node ".
                         		"where access.role_id in ({$myallroles}) and role.status=1 and access.node_id=node.id and node.level=3 and node.pid={$v2['id']} and node.status=1";*/
                         $sql2 = "select node.id ,node.type,node.name from node LEFT JOIN  access ON node.id=access.node_id where access.role_id in(" . $myallroles . ") and node.level=3  and node.pid=" . $v2['id'] . " and node.status=1";
                         $m2 = $db->query($sql2);
                         if ($m2) {
                             $modules = array_merge($modules, $m2);
                         }
                     }
                 }
             }
         }
         // 判断是否存在公共模块的权限
         $publicAction = array();
         foreach ($modules as $k3 => $v3) {
             $moduleId = $v3['id'];
             $moduleName = $v3['name'];
             if ('PUBLIC' == strtoupper($moduleName)) {
                 /*$sql    =   "select DISTINCT(node.id),node.name,access.plevels from ".
                 		$table['role']." as role,".
                 		$table['user']." as user,".
                 		$table['access']." as access ,".
                 		$table['node']." as node ".
                 		"where access.role_id in ({$myallroles}) and role.status=1 and access.node_id=node.id and node.level=4 and node.pid={$moduleId} and node.status=1";*/
                 $sql2 = "select node.id ,node.name,node.group_id,access.plevels from node LEFT JOIN  access ON node.id=access.node_id where access.role_id in(" . $myallroles . ") and node.level=4 and node.pid=" . $moduleId . " and node.status=1";
                 $rs = $db->query($sql2);
                 foreach ($rs as $a) {
                     $publicAction[$a['name']] = $a['id'] . "-" . $a['plevels'];
                 }
                 unset($modules[$k3]);
                 break;
             }
         }
         // 依次读取模块的操作权限
         $already_action = array();
         foreach ($modules as $k4 => $v4) {
             if ($already_action[$v4['id']]) {
                 continue;
             } else {
                 $already_action[$v4['id']] = 1;
             }
             if ($v4['type'] == 2) {
                 continue;
             }
             $moduleId = $v4['id'];
             $moduleName = $v4['name'];
             /*$sql =   "select DISTINCT(node.id),node.name,access.plevels from ".
             		$table['role']." as role,".
             		$table['user']." as user,".
             		$table['access']." as access ,".
             		$table['node']." as node ".
             		"where access.role_id in ({$myallroles}) and role.status=1 and access.node_id=node.id and node.level=4 and node.pid={$moduleId} and node.status=1";*/
             $sql2 = "select node.id ,node.name,node.group_id,access.plevels from node LEFT JOIN  access ON node.id=access.node_id where access.role_id in(" . $myallroles . ") and node.level=4 and node.pid=" . $moduleId . " and node.status=1";
             $rs = $db->query($sql2);
             $action = array();
             foreach ($rs as $a) {
                 $action['GROUPID'] = $a['group_id'];
                 if (isset($action[$a['name']])) {
                     $ex = explode("-", $action[$a['name']]);
                     if ($ex[1] > $a['plevels']) {
                         $action[$a['name']] = $a['id'] . "-" . $a['plevels'];
                     }
                 } else {
                     $action[$a['name']] = $a['id'] . "-" . $a['plevels'];
                 }
             }
             foreach ($publicAction as $b => $c) {
                 if (!isset($action[$b])) {
                     $action[$b] = $c;
                 }
             }
             // 和公共模块的操作权限合并
             //$action += $publicAction;
             $access[strtoupper($appName)][strtoupper($moduleName)] = array_change_key_case($action, CASE_UPPER);
         }
     }
     //获取我的权限
     $access2 = RBAC::getAccessListSelf($authId);
     if ($access2) {
         //过滤相关权限
         foreach ($access2 as $k => $v) {
             foreach ($v as $k2 => $v2) {
                 foreach ($v2 as $k3 => $v3) {
                     $ex = explode("-", $v3);
                     if ($ex[1] == 5) {
                         unset($access[$k][$k2][$k3]);
                     } else {
                         $access[$k][$k2][$k3] = $v3;
                     }
                 }
                 if (count($access[$k][$k2]) == 0) {
                     unset($access[$k][$k2]);
                 }
             }
         }
     }
     return $access;
 }
开发者ID:tmlsoft,项目名称:main,代码行数:101,代码来源:RBAC.class.php


注:本文中的RBAC::getAccessListSelf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。