function smtp_admin_criteria_settings_submit in SMTP Authentication Support 7.2
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.
File
- ./
smtp.admin.inc, line 745 - Administrative page code for the smtp module.
Code
function smtp_admin_criteria_settings_submit($form, &$form_state) {
if (isset($form_state['storage']['criteria']['weight'])) {
// Do not change the weight of previously created criterias
$weight = $form_state['storage']['criteria']['weight'];
}
else {
// New criteria receives the highest weight
$query = db_select('smtp_selection_criteria', 'c');
$query
->addExpression('MAX(weight) + 1', 'next_weight');
$result = $query
->execute()
->fetchAssoc();
$weight = isset($result['next_weight']) ? $result['next_weight'] : 0;
}
// Fields to be updated
$fields = array(
'provider' => $form_state['values']['provider'],
'weight' => $weight,
);
foreach ($form_state['values']['message'] as $key => $value) {
$fields["message_{$key}"] = $value;
}
if (empty($form_state['storage']['criteria'])) {
// New criteria
$result = db_insert('smtp_selection_criteria')
->fields($fields)
->execute();
}
else {
// Update
$result = db_update('smtp_selection_criteria')
->fields($fields)
->condition('cid', $form_state['storage']['criteria']['cid'])
->execute();
}
// Go back to the configuration form
drupal_goto("admin/config/system/smtp");
}