function _environment_readonly_get_configured_roles in Environment 7
Get configured roles.
Parameters
bool $names: Return configured names.
Return value
array Return readonly roles.
2 calls to _environment_readonly_get_configured_roles()
- environment_readonly_admin_settings in modules/
environment_readonly/ environment_readonly.admin.inc - Admin settings form.
- environment_readonly_user_default_permissions_alter in modules/
environment_readonly/ environment_readonly.module - Implements hook_user_default_permissions_alter().
File
- modules/
environment_readonly/ environment_readonly.module, line 120 - Code for the Environment Readonly module.
Code
function _environment_readonly_get_configured_roles($names = FALSE) {
$role_config = variable_get('environment_readonly_roles', NULL);
$user_roles = user_roles();
if ($role_config == NULL) {
$role_config = $user_roles;
}
else {
foreach ($role_config as $rid => $value) {
if (empty($value)) {
unset($role_config[$rid]);
}
else {
$role_config[$rid] = $user_roles[$rid];
}
}
}
if ($names) {
return $role_config;
}
else {
foreach ($role_config as $rid => $value) {
$role_config[$rid] = $rid;
}
return $role_config;
}
}