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


PHP RBAC::findAllrole方法代码示例

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


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

示例1: getAuthorGroup

 public function getAuthorGroup($authId)
 {
     $myallroles = "";
     if ($authId) {
         import("@.ORG.RBAC");
         $db = Db::getInstance(C('RBAC_DB_DSN'));
         $table = array('role_rolegroup' => "role_rolegroup", 'rolegroup_user' => "rolegroup_user");
         $sql_rolegroup_user = "select role_rolegroup  from " . $table['role_rolegroup'] . " where status=1";
         $rolesgrouplist = $db->query($sql_rolegroup_user);
         $sql_rolegroup = "select rolegroup_user.rolegroup_id from " . $table['rolegroup_user'] . " as rolegroup_user " . "where rolegroup_user.user_id='{$authId}'";
         $myrolesgroup = $db->query($sql_rolegroup);
         //echo $db->getlastsql();
         //print_r($myrolesgroup);
         foreach ($myrolesgroup as $key => $val) {
             if ($val['rolegroup_id']) {
                 $temp = RBAC::findAllrole($sql_rolegroup_user, $val['rolegroup_id']);
                 if ($temp) {
                     $myallroles .= $temp;
                 }
             }
         }
         // 所有組id
         return explode(',', $myallroles);
     }
 }
开发者ID:tmlsoft,项目名称:main,代码行数:25,代码来源:Browse.class.php

示例2: getAuthorRole

 /**
 +----------------------------------------------------------
 * 查找出当前用户所有继承及所属的组
 +----------------------------------------------------------
 * @param integer $authId 用户ID
 * @param integer $t 类型 0 全部,1(role_user)组,2(rolegroup)组
 +----------------------------------------------------------
 * @access public
 *
 */
 public function getAuthorRole($authId, $t = 0)
 {
     $myallroles = "";
     if ($authId) {
         $db = Db::getInstance(C('RBAC_DB_DSN'));
         if ($t == 0 || $t == 1) {
             $table = array('role' => C('RBAC_ROLE_TABLE'), 'role_user' => C('RBAC_USER_TABLE'));
             $sql_user_1 = "select role_user.role_id from " . $table['role_user'] . " as role_user " . "where role_user.user_id='{$authId}'";
             $sql_user_2 = "select role.id,role.pid from " . $table['role'] . " as role " . "where role.status=1 and role.pid is not null";
             $myroles = $db->query($sql_user_1);
             $allroles = $db->query($sql_user_2);
             foreach ($myroles as $k => $v) {
                 $myallroles .= RBAC::findAllrole($allroles, $v['role_id']);
             }
         }
         if ($t == 0 || $t == 2) {
             $table = array('role_rolegroup' => "role_rolegroup", 'rolegroup_user' => "rolegroup_user");
             $sql_rolegroup = "select rolegroup_user.rolegroup_id from " . $table['rolegroup_user'] . " as rolegroup_user " . "where rolegroup_user.user_id='{$authId}' group by rolegroup_user.rolegroup_id,rolegroup_user.user_id";
             $myrolesgroup = $db->query($sql_rolegroup);
             foreach ($myrolesgroup as $key => $value) {
                 $sql_group_1 = "select role_rolegroup.role_id from " . $table['role_rolegroup'] . " as role_rolegroup " . "where role_rolegroup.rolegroup_id='{$value[rolegroup_id]}'";
                 $myrolesTop = $db->query($sql_group_1);
                 foreach ($myrolesTop as $k => $v) {
                     $myallroles .= RBAC::findAllrole($allroles, $v['role_id']);
                 }
             }
         }
         $myallroles = substr($myallroles, 1);
         $myallroles = explode(",", $myallroles);
         $myallroles = array_unique($myallroles);
         $myallroles = implode(",", $myallroles);
     }
     return $myallroles;
 }
开发者ID:tmlsoft,项目名称:main,代码行数:44,代码来源:RBAC.class.php


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