You are here

function environment_readonly_user_default_permissions_alter in Environment 7

Implements hook_user_default_permissions_alter().

File

modules/environment_readonly/environment_readonly.module, line 92
Code for the Environment Readonly module.

Code

function environment_readonly_user_default_permissions_alter(&$permissions) {
  $env = environment_current();
  if ($env == 'readonly') {

    // Remove all configured roles from action permissions.
    $role_config = _environment_readonly_get_configured_roles(TRUE);
    $action_perms = _environment_readonly_get_action_perms();
    foreach ($permissions as $perm => $data) {

      // Remove action perms when in readonly mode.
      if (in_array($perm, $action_perms)) {
        foreach ($data['roles'] as $key => $role_name) {
          if (in_array($role_name, $role_config)) {
            unset($permissions[$perm]['roles'][$key]);
          }
        }
      }
    }
  }
}