You are here

function paranoia_form_user_admin_permissions_alter in Paranoia 7

Same name and namespace in other branches
  1. 8 paranoia.module \paranoia_form_user_admin_permissions_alter()

Implements hook_form_FORM_ID_alter().

Hides permissions considered risky by hook_paranoia_hide_permissions().

File

./paranoia.module, line 141
Paranoia module file. Provides various extra security features.

Code

function paranoia_form_user_admin_permissions_alter(&$form, &$form_state) {
  $banned_permissions = module_invoke_all('paranoia_hide_permissions');
  foreach ($banned_permissions as $permission) {
    if (isset($form['permission'][$permission])) {
      $form['permission'][$permission]['#markup'] .= ' ' . t('<strong>Disabled by paranoia module.<strong>');
    }
    foreach ($form['checkboxes'] as $index => $elements) {
      if (isset($elements['#options'][$permission])) {
        $form['checkboxes'][$index][$permission]['#access'] = FALSE;
      }
    }
  }
  $form['#validate'][] = 'paranoia_permissions_validate';
  $form['#submit'][] = 'paranoia_permissions_submit';
}