You are here

function signup_settings_form_submit in Signup 6.2

Same name and namespace in other branches
  1. 6 includes/admin.settings.inc \signup_settings_form_submit()
  2. 7 includes/admin.settings.inc \signup_settings_form_submit()

Submits the signup settings form

Parameters

$form_id The ID of the form being submitted.:

$form_values The constructed form values array of the submitted form.:

1 string reference to 'signup_settings_form_submit'
signup_settings_form in includes/admin.settings.inc
Form builder for the settings page under admin/setttings/signup

File

includes/admin.settings.inc, line 198
Code required for the signup settings page (admin/settings/signup).

Code

function signup_settings_form_submit($form, &$form_state) {
  $op = isset($form_state['values']['op']) ? $form_state['values']['op'] : '';
  if ($op == t('Save configuration') && db_result(db_query('SELECT COUNT(*) FROM {signup} WHERE nid = 0'))) {
    $values = array(
      $form_state['values']['signup_forwarding_email'],
      $form_state['values']['signup_send_confirmation'],
      $form_state['values']['signup_confirmation_email'],
      $form_state['values']['signup_close_signup_limit'],
    );
    $values[] = isset($form_state['values']['signup_send_reminder']) ? $form_state['values']['signup_send_reminder'] : 0;
    $values[] = isset($form_state['values']['signup_reminder_days_before']) ? $form_state['values']['signup_reminder_days_before'] : 0;
    $values[] = isset($form_state['values']['signup_reminder_email']) ? $form_state['values']['signup_reminder_email'] : '';
    $values[] = 0;

    // "nid" of the row in {signup} for the global settings.
    db_query("UPDATE {signup} SET forwarding_email = '%s', send_confirmation = %d, confirmation_email = '%s', close_signup_limit = %d, send_reminder = %d, reminder_days_before = %d, reminder_email = '%s' WHERE nid = %d", $values);

    // Handle the pane settings.
    _signup_node_settings_panes_save($form_state['values']['signup_form_panes'], 0);
  }
  else {
    module_load_include('install', 'signup', 'signup');
    db_query("DELETE FROM {signup} WHERE nid = 0");
    signup_insert_default_signup_info();
  }

  // Now, remove all the settings we just processed from our copy of
  // $form_state['values'], so system_settings_form_submit() doesn't see them.
  $settings = array(
    'signup_forwarding_email',
    'signup_send_confirmation',
    'signup_confirmation_email',
    'signup_send_reminder',
    'signup_reminder_days_before',
    'signup_reminder_email',
    'signup_close_signup_limit',
  );
  foreach ($settings as $setting) {
    unset($form_state['values'][$setting]);
  }

  // Remove the hidden element from signup_node_settings_form(), too.
  unset($form_state['values']['signup']);

  // Since the advanced settings can mess with the menu, rebuild that.
  menu_rebuild();

  // Let system_settings_form_submit() do its magic with everything else.
  system_settings_form_submit($form, $form_state);
}