function _environment_readonly_get_action_perms in Environment 7
Get action permissions.
Return value
array Return permissions.
2 calls to _environment_readonly_get_action_perms()
- 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 176 - Code for the Environment Readonly module.
Code
function _environment_readonly_get_action_perms() {
$settings = variable_get('environment_readonly_permissions', NULL);
// If there are no settings set, then we'll have to figure out the defaults.
if ($settings == NULL) {
$edit_text = array(
'administer',
'cancel',
'change',
'create',
'delete',
'edit',
'post',
'manage',
'revert',
'select',
);
$settings = array();
$permissions = _environment_readonly_get_perms();
foreach ($permissions as $perm => $perm_title) {
$settings[$perm] = 0;
$selected = FALSE;
foreach ($edit_text as $text) {
// Checking spaces before and after to minimize within-words checks.
if (strpos($perm, ' ' . $text) !== FALSE || strpos($perm, $text . ' ') !== FALSE) {
$settings[$perm] = $perm;
}
}
}
}
// Remove all the unset permissions.
foreach ($settings as $perm => $value) {
if (empty($value)) {
unset($settings[$perm]);
}
}
return $settings;
}