You are here

function disable_messages_settings_form_submit in Disable Messages 7

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

Submit function for the admin settings form.

1 string reference to 'disable_messages_settings_form_submit'
disable_messages_settings_form in ./disable_messages.module
Filter messages admin settings form.

File

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

Code

function disable_messages_settings_form_submit($form, &$form_state) {

  // Catch comma typos in the id text box.
  $value = $form_state['values']['disable_messages_exclude_users'];
  $value = preg_replace(array(
    '/[^0-9,]/',
    '/^,*/',
    '/,*$/',
  ), '', $value);
  $value = preg_replace('/(,+)/', ',', $value);
  $form_state['values']['disable_messages_exclude_users'] = $value;

  // Process and save the regular expressions in another variable.
  $patterns = explode("\n", $form_state['values']['disable_messages_ignore_patterns']);
  $regexps = array();
  $ignore_case = variable_get('disable_messages_ignore_case', '0') == '1' ? 'i' : '';
  foreach ($patterns as $pattern) {
    $pattern = preg_replace(array(
      '/^\\s*/',
      '/\\s*$/',
    ), '', $pattern);
    if (variable_get('disable_messages_anchor_regex', 1)) {
      $pattern = '^' . $pattern . '$';
    }
    $pattern = '/' . $pattern . '/su' . $ignore_case;
    $regexps[] = $pattern;
  }
  variable_set('disable_messages_ignore_regex', $regexps);
}