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


PHP Roles::get_user_roles方法代码示例

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


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

示例1: __construct

 public function __construct($user_id)
 {
     if (!isset($user_id)) {
         throw new CNException(REQUIRED_PARAMETERS_MISSING, "PermissionsHandler::__construct() must be called with User object or user_id parameter");
     }
     $tasks_obj = Tasks::get_instance();
     $this->tasks = $tasks_obj->get_tasks();
     foreach ($this->tasks as $task) {
         $this->static_permissions[] = $task->task_value;
     }
     $this->uid = (int) $user_id;
     $this->is_net_admin = Network::is_admin(PA::$network_info->network_id, $this->uid);
     $roles = Roles::get_user_roles((int) $user_id, DB_FETCHMODE_OBJECT);
     //    echo "User Roles <pre>".print_r(PA::$login_user, 1). "</pre>";
     $this->user_permissions = array();
     $user_perms = array();
     $network_perms = array();
     $groups_perms = array();
     foreach (array('user', 'network', 'groups') as $type) {
         foreach ($roles as $role) {
             $role_extra = unserialize($role->extra);
             if ($type == 'user') {
                 $condition = $role_extra['user'] == true;
             } else {
                 if ($type == 'network') {
                     $condition = $role_extra['network'] == true;
                 } else {
                     $condition = count($role_extra['groups']) > 0;
                 }
             }
             if ($condition) {
                 $role_tasks = Roles::get_tasks_of_role($role->role_id);
                 //         echo "RoleID: $role->role_id<pre>".print_r($role_tasks,1)."</pre>";
                 if ($role_tasks) {
                     foreach ($role_tasks as $rt) {
                         if ($type == 'user') {
                             $user_perms[] = $rt->task_value;
                         } else {
                             if ($type == 'network') {
                                 $network_perms[] = $rt->task_value;
                             } else {
                                 foreach ($role_extra['groups'] as $group_id) {
                                     if (isset($groups_perms[$group_id]) && is_array($groups_perms[$group_id])) {
                                         array_push($groups_perms[$group_id], $rt->task_value);
                                     } else {
                                         $groups_perms[$group_id] = array($rt->task_value);
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $this->user_permissions['user'] = $user_perms;
     $this->user_permissions['network'] = $network_perms;
     $this->user_permissions['groups'] = $groups_perms;
     if ($this->is_net_admin) {
         // user is network admin, grant him same privileges for all network groups
         foreach ($this->user_permissions['groups'] as &$gr_perms) {
             $gr_perms = array_unique(array_merge($gr_perms, $this->user_permissions['network']));
         }
     }
     //    echo "<pre>".print_r($this->user_permissions,1)."</pre>";
 }
开发者ID:Cyberspace-Networks,项目名称:CoreSystem,代码行数:66,代码来源:CNPermissionsHandler.php

示例2: foreach

} else {
    foreach ($u_groups as $group) {
        $user_groups[$group['gid']] = $group['name'];
    }
}
if ($group_id) {
    // show only Group roles
    $u_roles = Roles::get_user_roles($user_id, DB_FETCHMODE_ASSOC, array('type' => 'group', 'gid' => $group_id));
} else {
    // show network and user personal pages roles
    $g_roles = array();
    $u_roles = array();
    $net_roles = array();
    $g_roles = Roles::get_user_roles($user_id, DB_FETCHMODE_ASSOC, array('type' => 'group', 'gid' => $group_id));
    $u_roles = Roles::get_user_roles($user_id, DB_FETCHMODE_ASSOC, array('type' => 'user'));
    $net_roles = Roles::get_user_roles($user_id, DB_FETCHMODE_ASSOC, array('type' => 'network'));
    $u_roles = array_merge($u_roles, $net_roles);
    $u_roles = array_merge($u_roles, $g_roles);
}
foreach ($u_roles as $role) {
    $role_id = $role['role_id'];
    $role_type = $role['type'];
    $role_name = Roles::get_role_name($role_id);
    $role_tasks = Roles::get_tasks_of_role($role_id);
    $role_extra = unserialize($role['extra']);
    $role_info = array('role_id' => $role_id, 'name' => $role_name, 'type' => $role_type, 'extra' => $role_extra, 'tasks' => $role_tasks);
    $user_roles[$role_id] = $role_info;
    if ($role_id == $sel_role_id) {
        $selected_role = $role_info;
    }
}
开发者ID:Cyberspace-Networks,项目名称:PeopleAggregator,代码行数:31,代码来源:user_roles.php

示例3: get_user_task_permissions

 private function get_user_task_permissions($uid)
 {
     $tasks = array();
     $role_obj = Roles::get_user_roles($uid);
     if (!empty($role_obj)) {
         $tasks = array();
         foreach ($role_obj as $r_obj) {
             $tasks_roles = Roles::get_tasks_of_role($r_obj->role_id);
             if ($tasks_roles) {
                 $tasks = array_merge($tasks, $tasks_roles);
             }
         }
     }
     return $tasks;
 }
开发者ID:Cyberspace-Networks,项目名称:PeopleAggregator,代码行数:15,代码来源:NetworkLeftLinksModule.php

示例4: strlen

        $start = 0;
        $length = strlen($links[$i]['email']) + 15;
        for ($end = 0; $end <= $length; $end += 15) {
            echo substr($links[$i]['email'], $start, $end) . "<br>";
            $start = $end;
        }
        ?>
</a>
                                    </td>
                        -->
                        <td><div  id = "curr_role<?php 
        echo $links[$i]['user_id'];
        ?>
" >
                                <?php 
        $user_roles = Roles::get_user_roles((int) $links[$i]['user_id'], DB_FETCHMODE_ASSOC);
        //             echo '<pre>' . print_r($user_roles,1) . '</pre>';
        foreach ($user_roles as $role) {
            $rolename = $roles_list[$role['role_id']];
            ?>
                                    <?php 
            echo $rolename;
            ?>
<br />
                                <?php 
        }
        ?>
                                <div></td>

                                    <td><a href="<?php 
        echo $url;
开发者ID:Cyberspace-Networks,项目名称:CoreSystem,代码行数:31,代码来源:cnmodule.php

示例5: check_permission

 public static function check_permission($uid, $task_id)
 {
     $result = false;
     Logger::log("Enter: function Roles::check_permission");
     if (SUPER_USER_ID == $uid) {
         return TRUE;
         //TODO:same holds true for network owner
     }
     $role_obj = Roles::get_user_roles($uid);
     foreach ($role_obj as $r_obj) {
         $result = Roles::is_roletask_exist($r_obj->role_id, $task_id);
         if ($result) {
             break;
         }
         // user have permission for this task!
     }
     Logger::log("Exit: function Roles::check_permission");
     return $result;
 }
开发者ID:Cyberspace-Networks,项目名称:CoreSystem,代码行数:19,代码来源:CNRoles.php

示例6: array

$group_id = !empty($_REQUEST['gid']) && $_REQUEST['gid'] != '-1' ? $_REQUEST['gid'] : null;
$user_roles = array();
$user_groups = array();
$u_groups = Group::get_user_groups($user_id);
if (count($u_groups) < 1) {
    $u_groups = Group::get_all_groups_for_admin(FALSE);
    foreach ($u_groups as $group) {
        $user_groups[$group['group_id']] = $group['title'];
    }
} else {
    foreach ($u_groups as $group) {
        $user_groups[$group['gid']] = $group['name'];
    }
}
$r_params = $group_id ? array('type' => 'group', 'gid' => $group_id) : null;
$u_roles = Roles::get_user_roles($user_id, DB_FETCHMODE_ASSOC, $r_params);
foreach ($u_roles as $role) {
    $role_id = $role['role_id'];
    $role_type = $role['type'];
    $role_name = Roles::get_role_name($role_id);
    $role_tasks = Roles::get_tasks_of_role($role_id);
    $role_extra = unserialize($role['extra']);
    $role_info = array('role_id' => $role_id, 'name' => $role_name, 'type' => $role_type, 'extra' => $role_extra, 'tasks' => $role_tasks);
    $user_roles[$role_id] = $role_info;
}
?>

      <?php 
foreach ($user_roles as $role) {
    $curr_role_id = $role['role_id'];
    $extra = $role['extra'];
开发者ID:Cyberspace-Networks,项目名称:PeopleAggregator,代码行数:31,代码来源:refresh_role_extra.php

示例7: array

                }
            }
            $extra['groups'] = $_groups;
        }
    }
    $user_roles = array();
    $role = new Roles();
    $_extra = serialize(array('user' => true, 'network' => true, 'groups' => array()));
    if (!empty($role_extra[$role_id])) {
        $_extra = serialize($role_extra[$role_id]);
    } else {
        if ($group_id) {
            $_extra = array('user' => false, 'network' => false, 'groups' => array($group_id));
            $_extra = serialize($_extra);
        }
    }
    $user_roles[] = array('role_id' => $role_id, 'extra' => $_extra);
    if ($_POST['roles_action'] == 'delete') {
        $role->delete_user_roles($uid, $user_roles, $group_id);
    } else {
        $role->assign_role_to_user($user_roles, $uid);
    }
    $names = array();
    $r_params = $group_id ? array('type' => 'group', 'gid' => $group_id) : null;
    $saved_roles = Roles::get_user_roles($uid, DB_FETCHMODE_OBJECT, $r_params);
    foreach ($saved_roles as $s_role) {
        $names[] = Roles::get_role_name($s_role->role_id);
    }
    $msg = implode("<br />", $names);
    echo $msg;
}
开发者ID:Cyberspace-Networks,项目名称:PeopleAggregator,代码行数:31,代码来源:assign_role.php


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