You are here

function secure_permissions_get_existing_roles in Secure Permissions 7.2

Same name and namespace in other branches
  1. 7 secure_permissions.module \secure_permissions_get_existing_roles()

Get all roles stored by Drupal.

3 calls to secure_permissions_get_existing_roles()
secure_permissions_build_permissions in ./secure_permissions.module
Build function to create the permissions arrays.
secure_permissions_build_roles in ./secure_permissions.module
Build the roles table correctly.
secure_permissions_export in ./secure_permissions.module
Page callback to generate roles and permissions in code.

File

./secure_permissions.module, line 174
Secure Permissions module file.

Code

function secure_permissions_get_existing_roles() {

  // Function user_roles fetches translated names
  // for anonymous and authenticated roles.
  // which leads to inconsistencies in rebuilding.
  // Query it thus adapted from core user_roles.
  $query = db_select('role', 'r');
  $query
    ->fields('r', array(
    'rid',
    'name',
  ));
  $query
    ->orderBy('name');
  $result = $query
    ->execute();
  $roles = array();
  foreach ($result as $role) {
    $roles[$role->rid] = $role->name;
  }
  return $roles;
}