You are here

paranoia.module in Paranoia 5

Same filename and directory in other branches
  1. 8 paranoia.module
  2. 6 paranoia.module
  3. 7 paranoia.module

File

paranoia.module
View source
<?php

// A module that locks a site down to achieve more security from malicious end users.
function paranoia_form_alter($form_id, &$form) {
  switch ($form_id) {
    case 'user_admin_perm':

      // Do not allow any user safe user #1 to enter PHP anywhere
      unset($form['permission']['use PHP for block visibility']);
      unset($form['permission']['execute php code']);
      foreach (element_children($form['checkboxes']) as $rid) {
        unset($form['checkboxes'][$rid]['use PHP for block visibility']);
        unset($form['checkboxes'][$rid]['#options']['use PHP for block visibility']);
        unset($form['checkboxes'][$rid]['execute php code']);
        unset($form['checkboxes'][$rid]['#options']['execute php code']);
      }
      break;
    case 'filter_admin_format_form':

      // Disable creation of input formats that use the PHP filter
      // Note you should also delete the PHP filter from the default
      // input format.
      unset($form['filters']['filter/1']);
      break;
    case 'system_modules':

      // Disable disabling of this module
      unset($form['name']['paranoia'], $form['version']['paranoia'], $form['description']['paranoia'], $form['throttle']['paranoia'], $form['throttle']['#options']['paranoia']);
      $form['status']['paranoia'] = array(
        '#type' => 'hidden',
        '#value' => 1,
      );
      break;
    case 'user_edit':
      if (arg(1) == 1) {

        // disable deletion of the No. 1 user, also changing of
        // password, status, or mail address.
        unset($form['delete'], $form['account']['mail'], $form['account']['pass'], $form['account']['status']);
      }
      break;
    case 'block_admin_configure':
      unset($form['page_vis_settings']['visibility']['#options'][2]);
      $form['page_vis_settings']['pages']['#description'] = t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are <em>blog</em> for the blog page and <em>blog/*</em> for every personal blog. <em>&lt;front&gt;</em> is the front page.");
      break;
  }
}

Functions