You are here

function administerusersbyrole_perm in Administer Users by Role 5

Same name and namespace in other branches
  1. 6 administerusersbyrole.module \administerusersbyrole_perm()

@file Allows users with 'administer users' permission and a role (specified in 'Access control') to edit/delete other users with a specified role. If the user being edited has multiple roles, the user doing the editing must have permission to edit ALL of the user being edited's roles. Also provides control over user creation. Works well in conjunction with <a href='http://drupal.org/project/role_delegation'>role_delegation</a>.

File

./administerusersbyrole.module, line 8
Allows users with 'administer users' permission and a role (specified in 'Access control') to edit/delete other users with a specified role. If the user being edited has multiple roles, the user doing the editing must have…

Code

function administerusersbyrole_perm() {
  $roles = db_query('SELECT name FROM {role} WHERE rid > 2 ORDER BY name');
  $perms = array();
  $perms[] = 'create users';
  while ($role = db_fetch_array($roles)) {
    $perms[] = 'edit users with role ' . $role['name'];
    $perms[] = 'delete users with role ' . $role['name'];
  }
  return $perms;
}