You are here

function jsonlog_form_system_logging_settings_submit in JSONlog 7

Same name and namespace in other branches
  1. 8.2 jsonlog.module \jsonlog_form_system_logging_settings_submit()
  2. 8 jsonlog.module \jsonlog_form_system_logging_settings_submit()
  3. 7.2 jsonlog.module \jsonlog_form_system_logging_settings_submit()
  4. 3.x jsonlog.module \jsonlog_form_system_logging_settings_submit()

Custom submit handler for the system logging settings form.

_state

Parameters

array $form:

1 string reference to 'jsonlog_form_system_logging_settings_submit'
jsonlog_form_system_logging_settings_alter in ./jsonlog.module
Adds this module's setting fields to the system logging settings form.

File

./jsonlog.module, line 396
JSONlog module.

Code

function jsonlog_form_system_logging_settings_submit($form, &$form_state) {
  $values =& $form_state['values'];
  $file = '';
  $fields = array(
    'jsonlog_severity_threshold',
    'jsonlog_truncate',
    'jsonlog_siteid',
    'jsonlog_file',
  );
  foreach ($fields as $name) {

    // Trim all values.
    $values[$name] = trim($values[$name]);
    switch ($name) {
      case 'jsonlog_truncate':
        if (!$values['jsonlog_truncate']) {
          $values['jsonlog_truncate'] = 0;
        }
        break;
      case 'jsonlog_file':
        if ($values['jsonlog_file']) {
          $file = $values['jsonlog_file'];
        }
        break;
    }
  }

  // Tags.
  if (($values['jsonlog_tags'] = $v = trim($values['jsonlog_tags'])) !== '') {
    $v = str_replace(array(
      "\r",
      "\n",
    ), '', $v);
    if ($v !== '') {
      if ($v[0] === ',') {
        $v = substr($v, 1);
      }
      if ($v !== '') {
        if ($v[strlen($v) - 1] === ',') {
          $v = substr($v, 0, strlen($v) - 1);
        }
      }
      if (strpos($v, ',')) {
        $v = preg_replace('/ *, */', ',', $v);
      }
    }
    $values['jsonlog_tags'] = trim($v);
  }

  // Test.
  if ($values['jsonlog_test_filing']) {
    module_load_include('inc', 'jsonlog');
    jsonlog_test_filing($file ? $file : jsonlog_default_file());
  }

  // Don't ever save that field.
  unset($form_state['input']['jsonlog_test_filing'], $values['jsonlog_test_filing']);
}