欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

drupal 给其它的用户赋予角色的模块

shiping1 的头像

Role Delegation


这个模块 可以分配角色给其它的用户 仅仅是给其它的用户赋予角色 没有其它功能

1)安装 启用它
2)到权限页面 可以看到 

Role Delegation role_delegation 模块

assign all roles  这个是可以分配所有角色
assign  .... roles 就可 某个特定的角色


assign all roles
administer permissions  (管理权限)
这两个权限最好去掉

就给 角色分配权限吧
3) 用户就可以 user/用户id/roles 来访问页面了 
这个 用户id 并不一定是本人id 而是其它用户的id
(如果没有权限访问看下面的代码)
//看role_delegation.module
function role_delegation_menu() {
  global $user;
  $items = array();
 
  $items['user/%user/roles'] = array(
    'title' => 'Roles',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('role_delegation_roles_form', 1),
    'access callback' => 'role_delegation_access',
    'type' => MENU_LOCAL_TASK,
  );
  return $items;
}

下面是烦人的权限代码 权限切要注意 搞不好会出问题
function role_delegation_access() {
  // Check access to user profile page.
  if (!user_access('access user profiles')) {
    return FALSE;
  }
  // Check if they can edit users. In that case, the Roles tab is not needed.
  if (user_access('administer users')) {
    return FALSE;
  }
  // Check access to role assignment page.
  if (user_access('administer permissions')) {
    return TRUE;
  }
  $perms = role_delegation_perm();
  foreach ($perms as $perm) {
    if (user_access($perm)) {
      return TRUE;
    }
  }

  return FALSE;
}





https://drupal.org/project/role_delegation
普通分类: