function smtp_admin_settings_form_submit in SMTP Authentication Support 7.2
Same name and namespace in other branches
- 7 smtp.admin.inc \smtp_admin_settings_form_submit()
Submit handler().
Parameters
form: An associative array containing the structure of the form.
form_state: A keyed array containing the current state of the form.
1 string reference to 'smtp_admin_settings_form_submit'
- smtp_admin_settings in ./
smtp.admin.inc - Administrative settings.
File
- ./
smtp.admin.inc, line 284 - Administrative page code for the smtp module.
Code
function smtp_admin_settings_form_submit($form, &$form_state) {
// Check if SMTP status has been changed.
if (!variable_get('smtp_on', FALSE) && $form_state['values']['smtp_on'] || variable_get('smtp_on', FALSE) && !$form_state['values']['smtp_on']) {
$mail_modes = variable_get('mail_system', array(
'default-system' => 'DefaultMailSystem',
));
// Turning on.
if ($form_state['values']['smtp_on']) {
variable_set('smtp_previous_mail_system', $mail_modes['default-system']);
$mail_modes['default-system'] = 'SmtpMailSystem';
}
else {
$mail_modes['default-system'] = variable_get('smtp_previous_mail_system', 'DefaultMailSystem');
}
variable_set('mail_system', $mail_modes);
}
// If there is a provider set, use it.
if (!empty($form_state['values']['provider_default'])) {
variable_set('smtp_default_provider', $form_state['values']['provider_default']);
}
// If username is set empty, we must set both username/password empty as well.
if (empty($form_state['values']['smtp_username'])) {
$form_state['values']['smtp_password'] = '';
}
elseif (empty($form_state['values']['smtp_password'])) {
unset($form_state['values']['smtp_password']);
}
// Save the test address to send an email after all the settings have been
// updated.
$form_state['storage']['smtp']['smtp_test_address'] = $form_state['values']['smtp_test_address'];
unset($form_state['values']['smtp_test_address']);
// Saves criterias' weights
if (!empty($form_state['values']['criterias']['table'])) {
foreach ($form_state['values']['criterias']['table'] as $cid => $criteria_values) {
db_update('smtp_selection_criteria')
->fields(array(
'weight' => $criteria_values['weight'],
))
->condition('cid', $cid)
->execute();
}
}
}