You are here

function mailsystem_admin_settings_submit in Mail System 8.2

Same name and namespace in other branches
  1. 8 mailsystem.admin.inc \mailsystem_admin_settings_submit()
  2. 6.2 mailsystem.admin.inc \mailsystem_admin_settings_submit()
  3. 6 mailsystem.admin.inc \mailsystem_admin_settings_submit()
  4. 7.3 mailsystem.admin.inc \mailsystem_admin_settings_submit()
  5. 7 mailsystem.admin.inc \mailsystem_admin_settings_submit()
  6. 7.2 mailsystem.admin.inc \mailsystem_admin_settings_submit()

Processes mailsystem_admin_settings form.

1 string reference to 'mailsystem_admin_settings_submit'
mailsystem_admin_settings in ./mailsystem.admin.inc
@file Administrative form for setting the mail_system variable.

File

./mailsystem.admin.inc, line 159
Administrative form for setting the mail_system variable.

Code

function mailsystem_admin_settings_submit($form, &$form_state) {
  variable_set('mailsystem_theme', $form_state['values']['mailsystem']['mailsystem_theme']);

  // Rebuild the theme registry to make changes needed by theme rendering.
  drupal_theme_rebuild();
  unset($form_state['values']['mailsystem']['mailsystem_theme']);
  $default_id = mailsystem_default_id();
  $mail_system = array(
    $default_id => empty($form_state['values'][$default_id]) ? mailsystem_default_value() : $form_state['values'][$default_id],
  );
  foreach (element_children($form_state['values']['mailsystem']) as $module) {
    $class = $form_state['values']['mailsystem'][$module];
    if (!empty($class) && $class != $default_id) {
      $mail_system[$module] = $class;
    }
  }
  unset($form_state['values']['mailsystem']);
  if ($form_state['values']['class']['format'] === mailsystem_default_id()) {
    unset($form_state['values']['class']['format']);
  }
  if ($form_state['values']['class']['mail'] === mailsystem_default_id()) {
    unset($form_state['values']['class']['mail']);
  }
  if ($form_state['values']['class']) {
    $new_class = mailsystem_create_class($form_state['values']['class']);
  }
  else {
    $new_class = $mail_system[mailsystem_default_id()];
  }
  unset($form_state['values']['class']);
  if ($id = $form_state['values']['identifier']['module']) {
    if (!empty($form_state['values']['identifier']['key'])) {
      $id .= '_' . $form_state['values']['identifier']['key'];
    }
    $mail_system[$id] = $new_class;
  }
  unset($form_state['values']['identifier']);
  variable_set('mail_system', $mail_system);
  drupal_set_message(t('The configuration options have been saved.'));
}