You are here

function administerusersbyrole_permission in Administer Users by Role 7

Same name and namespace in other branches
  1. 7.2 administerusersbyrole.module \administerusersbyrole_permission()

Implements hook_permission().

File

./administerusersbyrole.module, line 16
Provides fine-grained permissions for creating, editing, and deleting users.

Code

function administerusersbyrole_permission() {
  $roles = user_roles();
  $perms = array();
  $perms['create users'] = array(
    'title' => 'Create new users',
  );
  $perms['edit users with no custom roles'] = array(
    'title' => 'Edit users with no custom roles',
  );
  $perms['cancel users with no custom roles'] = array(
    'title' => 'Cancel users with no custom roles',
  );
  foreach ($roles as $rid => $role) {
    foreach (array(
      'edit',
      'cancel',
    ) as $op) {

      // edit/cancel x.
      $perm_string = _administerusersbyrole_build_perm_string($role, $op, FALSE);
      $perm_title = ucfirst($perm_string);
      $perms[$perm_string] = array(
        'title' => $perm_title,
      );

      // edit/cancel $op x and other.
      $perm_string = _administerusersbyrole_build_perm_string($role, $op, TRUE);
      $perm_title = ucfirst($perm_string);
      $perms[$perm_string] = array(
        'title' => $perm_title,
      );
    }
  }
  return $perms;
}