function workbench_access_get_roles in Workbench Access 7
Fetch all user roles with the a specific permission.
This is a wrapper for user_roles() since it may exclude user roles that have a permission assigned to the 'authenticated user' role.
Parameters
$permission: The perimission to return active roles.
Return value
An array of allowed roles, in the format rid => name.
8 calls to workbench_access_get_roles()
- WorkbenchAccessMenuTestCase::testWorkbenchAccessMenu in tests/
workbench_access.test - WorkbenchAccessRoleTestCase::testWorkbenchAccessRoles in tests/
workbench_access.test - WorkbenchAccessTaxonomyTestCase::testWorkbenchAccessTaxonomy in tests/
workbench_access.test - workbench_access_autocomplete in ./
workbench_access.pages.inc - Autocomplete callback for adding users to a section.
- workbench_access_editors in ./
workbench_access.admin.inc - Display the editors for a section.
3 string references to 'workbench_access_get_roles'
- WorkbenchAccessMenuTestCase::testWorkbenchAccessMenu in tests/
workbench_access.test - WorkbenchAccessTaxonomyTestCase::testWorkbenchAccessTaxonomy in tests/
workbench_access.test - workbench_access_reset_tree in ./
workbench_access.module - Reset tree data stored in statics.
File
- ./
workbench_access.module, line 2005 - Workbench Access module file.
Code
function workbench_access_get_roles($permission) {
$roles =& drupal_static(__FUNCTION__, array());
if (!isset($roles[$permission])) {
// Build the list of user roles that can be assigned workbench access.
$roles[$permission] = user_roles(FALSE, $permission);
if (isset($roles[$permission][DRUPAL_AUTHENTICATED_RID])) {
// Because the permission may only be granted for the 'authenticated user'
// role, manually add in all non-anonymous roles in that case.
$roles[$permission] += user_roles(TRUE);
}
}
return $roles[$permission];
}