本文整理汇总了PHP中Roles::get_user_role方法的典型用法代码示例。如果您正苦于以下问题:PHP Roles::get_user_role方法的具体用法?PHP Roles::get_user_role怎么用?PHP Roles::get_user_role使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Roles
的用法示例。
在下文中一共展示了Roles::get_user_role方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generate_inner_html
function generate_inner_html()
{
global $current_theme_path, $base_url, $network_info, $login_uid;
if ($network_info->type == MOTHER_NETWORK_TYPE) {
if ($login_uid == SUPER_USER_ID) {
$this->set_perms('all');
} else {
$role_obj = Roles::get_user_role($login_uid);
if (empty($role_obj)) {
$this->set_perms('none');
} else {
$tasks = Roles::get_tasks_of_role($role_obj->role_id);
$this->set_perms($tasks);
}
}
} else {
//spawned networks only admin roles
if (Network::is_admin($network_info->network_id, $login_uid) || $login_uid == SUPER_USER_ID) {
//owner of network
$this->set_perms('all');
//todo - quick fix here
$this->task_perms['meta_networks'] = FALSE;
} else {
$this->set_perms('none');
}
}
$extra = unserialize($network_info->extra);
$network_content_moderation = FALSE;
if (@$extra['network_content_moderation'] == NET_YES) {
// this can be empty or not set
$network_content_moderation = TRUE;
}
$inner_template = NULL;
switch ($this->mode) {
default:
$inner_template = dirname(__FILE__) . '/center_inner_private.tpl';
}
$obj_inner_template =& new Template($inner_template);
$obj_inner_template->set('base_url', $base_url);
$obj_inner_template->set('task_perms', $this->task_perms);
$obj_inner_template->set('network_content_moderation', $network_content_moderation);
$inner_html = $obj_inner_template->fetch();
return $inner_html;
}
示例2: check_permission
/**
Purpose : this function checks if a given user has permission to given task
@param : $uid, $task_id
@return : TRUE, FALSE
**/
public static function check_permission($uid, $task_id)
{
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_role($uid);
if (empty($role)) {
Logger::log("Exit: function Roles::check_permission");
return FALSE;
}
$role = $role_obj->role_id;
$perm = Roles::is_roletask_exist($role, $task_id);
//dont support multiple roles of user
Logger::log("Exit: function Roles::check_permission");
return $perm;
}
示例3: array
if ($sel_role_id) {
$user_id = (int) $_REQUEST['uid'];
$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'];
}
}
$u_roles = Roles::get_user_role($user_id, DB_FETCHMODE_ASSOC);
foreach ($u_roles as $role) {
$role_id = $role['role_id'];
$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, 'extra' => $role_extra, 'tasks' => $role_tasks);
$user_roles[$role_id] = $role_info;
if ($role_id == $sel_role_id) {
$selected_role = $role_info;
}
}
}
?>
<?php