You are here

function disable_messages_settings_form in Disable Messages 7

Same name and namespace in other branches
  1. 6 disable_messages.module \disable_messages_settings_form()

Filter messages admin settings form.

1 string reference to 'disable_messages_settings_form'
disable_messages_menu in ./disable_messages.module
Implements hook_menu().

File

./disable_messages.module, line 285
The disable_messages module file.

Code

function disable_messages_settings_form() {
  $form = array();
  $form['disable_messages_enable'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable filtering'),
    '#default_value' => variable_get('disable_messages_enable', '1'),
    '#description' => t('Uncheck this checkbox to disable all message filtering.
      If you uncheck this, all messages will be shown to all users and
      no custom filtering rules will be applied.'),
  );
  $form['disable_messages_ignore_patterns'] = array(
    '#type' => 'textarea',
    '#title' => t('Messages to be disabled'),
    '#description' => t('Enter messages that should not be shown to end
      users. Regular expressions are supported. You do not have to include
      the opening and closing forward slashes for the regular expression.
      The system will automatically add /^ and $/ at the beginning and end
      of the pattern to ensure that the match is always a full match
      instead of a partial match. This will help prevent unexpected
      filtering of messages. So if you want to filter out a specific
      message ensure that you add the full message including any punctuation
      and additional HTML if any. Add one per line. See !PCRE documentation
      for details on regular expressions.', array(
      '!PCRE' => l(t('PCRE'), 'http://us3.php.net/manual/en/book.pcre.php', array(
        'external' => TRUE,
      )),
    )),
    '#default_value' => variable_get('disable_messages_ignore_patterns', ''),
  );
  $form['disable_messages_ignore_case'] = array(
    '#type' => 'checkbox',
    '#title' => t('Ignore case'),
    '#default_value' => variable_get('disable_messages_ignore_case', '1'),
    '#description' => t('Check this to ignore case while matching the patterns.'),
  );
  $form['disable_messages_anchor_regex'] = array(
    '#type' => 'checkbox',
    '#title' => t('Anchor regex'),
    '#default_value' => variable_get('disable_messages_anchor_regex', '1'),
    '#description' => t('Check this to anchor regex to begin and end of message. Note that the necessary wildcards may cause memory issues.'),
  );
  $form['disable_messages_filter_options'] = array(
    '#type' => 'fieldset',
    '#title' => t('Page and user level filtering options'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['disable_messages_filter_options']['role_information'] = array(
    '#type' => 'item',
    '#title' => t('Filering by role'),
    '#markup' => t('By default, permission to view all status message
      types are given for all roles. You can change this in !link to
      limit the roles which can view a given message type.', array(
      '!link' => l(t('administer permissions'), 'admin/user/permissions', array(
        'fragment' => 'module-disable_messages',
      )),
    )),
  );
  $options = array(
    t('Apply filters on all pages.'),
    t('Apply filters on every page except the listed pages.'),
    t('Apply filters only on the listed pages.'),
  );
  $description = t("Enter one page per line as Drupal paths.\n    The '*' character is a wildcard. Example paths are %blog for\n    the blog page and %blog-wildcard for every personal blog.\n    %front is the front page.", array(
    '%blog' => 'blog',
    '%blog-wildcard' => 'blog/*',
    '%front' => '<front>',
  ));
  $form['disable_messages_filter_options']['disable_messages_filter_by_page'] = array(
    '#type' => 'radios',
    '#title' => t('Apply filters by page'),
    '#options' => $options,
    '#default_value' => variable_get('disable_messages_filter_by_page', 0),
  );
  $form['disable_messages_filter_options']['disable_messages_page_filter_paths'] = array(
    '#type' => 'textarea',
    '#title' => t('Pages'),
    '#default_value' => variable_get('disable_messages_page_filter_paths', ''),
    '#description' => $description,
  );
  $form['disable_messages_filter_options']['disable_messages_exclude_users'] = array(
    '#type' => 'textfield',
    '#title' => t('Users excluded from filtering'),
    '#size' => 40,
    '#default_value' => variable_get('disable_messages_exclude_users', ''),
    '#description' => t('Comma separated list of user ids to be excluded
     from any filtering. All messages will be shown to all the
     listed users irrespective of their permissons to view
     the corresponding type of message.'),
  );
  $form['disable_messages_debug'] = array(
    '#type' => 'fieldset',
    '#title' => t('Debug options'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['disable_messages_debug']['disable_messages_enable_debug'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable debug mode'),
    '#default_value' => variable_get('disable_messages_enable_debug', '0'),
    '#description' => t('Check this to enable debug information.
      The debug information will be shown in an explicitly hidden
      div sent to the page via $closure. You can use firebug or a
      similar tool like that to set the visibility of this div or just
      view source to see the debug information. Safe to use even on
      production sites.'),
  );
  $form['disable_messages_debug']['disable_messages_debug_visible_div'] = array(
    '#type' => 'checkbox',
    '#title' => t('Show debug div as visible'),
    '#default_value' => variable_get('disable_messages_debug_visible_div', '0'),
    '#description' => t('Frustrated with having to view source everytime?
      Don\'t worry. Enable this to show the debug messages in a visible
      div. <strong>Remember to disable this on the production
      sites if you enable debug there :)</strong>.'),
  );
  $form['#submit'][] = 'disable_messages_settings_form_submit';
  return system_settings_form($form);
}