You are here

function statspro_main_admin_settings_form_submit in Statistics Pro 6.2

Implementation of hook_modulename_submit() for main admin settings form.

File

./statspro_admin_settings.inc, line 252

Code

function statspro_main_admin_settings_form_submit($form, &$form_state) {
  $op = isset($form_state['values']['op']) ? $form_state['values']['op'] : '';
  if ($op == t('Reset to defaults')) {
    variable_del('statspro_period');
    variable_del('statspro_custom_number_days');
    variable_del('statspro_charting_library');
    $keys = array_keys($_SESSION);
    foreach ($keys as $key) {
      if (strpos($key, 'statspro_') === 0) {
        unset($_SESSION[$key]);
      }
    }
    drupal_set_message(t('The configuration options have been reset to their default values.'));
  }
  else {
    variable_set('statspro_period', $form_state['values']['statspro_period']);
    if ($form_state['values']['statspro_period'] == 'custom_days') {
      variable_set('statspro_custom_number_days', (int) $form_state['values']['statspro_custom_number_days']);
    }
    if (statspro_get_available_charts_graphs()) {
      variable_set('statspro_charting_library', $form_state['values']['statspro_charting_library']);
    }
    drupal_set_message(t('The configuration options have been saved.'));
  }
}