function authcache_get_roles in Authenticated User Page Caching (Authcache) 7.2
Helper function, get authcache user roles.
Parameters
bool $all_roles: TRUE when all user roles should be returned, FALSE for authcache-enabled only.
Return value
array Associative array of role names keyed by their role-id.
Related topics
9 calls to authcache_get_roles()
- AuthcacheTestAdminWidgets::testGetRoleRestrict in tests/
authcache.widget.test - Cover authcache_get_role_restrict_roles().
- authcache_admin_config in ./
authcache.admin.inc - Main Authcache configuration form.
- authcache_admin_pagecaching in ./
authcache.admin.inc - Page caching rules form.
- authcache_authcache_account_exclude in ./
authcache.module - Implements hook_authcache_account_exclude().
- authcache_form_admin in modules/
authcache_form/ authcache_form.admin.inc - Form API callback: Generate admin form.
File
- ./
authcache.module, line 797 - Authenticated User Page Caching (and anonymous users, too!)
Code
function authcache_get_roles($all_roles = FALSE) {
$roles = user_roles();
// Clarify that the authenticated user-rid will only be considired if the
// user does not have any other role.
$roles[DRUPAL_AUTHENTICATED_RID] = t('@authenticated_user (without additional roles)', array(
'@authenticated_user' => $roles[DRUPAL_AUTHENTICATED_RID],
));
if (!$all_roles) {
$authcache_roles = variable_get('authcache_roles', array());
$roles = array_intersect_key($roles, $authcache_roles);
}
return $roles;
}