function mailing_list_form_submit in Mailing List 6
Same name and namespace in other branches
- 7 mailing_list.admin.inc \mailing_list_form_submit()
Submit handler for the add / rename mailing list form.
1 string reference to 'mailing_list_form_submit'
- mailing_list_form in ./
mailing_list.admin.inc - Form for adding / renaming a mailing list.
File
- ./
mailing_list.admin.inc, line 115 - Mailing list admin UI.
Code
function mailing_list_form_submit($form, &$form_state) {
// drupal_set_message('<pre>'. print_r($form_state['values'],1 ) . '</pre>');
if (isset($form_state['values']['mlid'])) {
$query = "UPDATE {mailing_list} SET name = '%s' WHERE mlid = %d";
$result = db_query($query, $form_state['values']['name'], $form_state['values']['mlid']);
}
else {
$query = "INSERT INTO {mailing_list} (name) VALUES ('%s')";
$result = db_query($query, $form_state['values']['name']);
}
if ($result) {
if (isset($form_state['values']['mlid'])) {
drupal_set_message(t('Renamed mailing list %name', array(
'%name' => $form_state['values']['name'],
)));
watchdog('mailing_list', 'Mailing list: renamed %name.', array(
'%name' => $form_state['values']['name'],
), WATCHDOG_NOTICE, l(t('view'), 'admin/build/mailing-list/' . $form_state['values']['mlid']));
}
else {
drupal_set_message(t('Created mailing list %name', array(
'%name' => $form_state['values']['name'],
)));
watchdog('mailing_list', 'Mailing list: created %name.', array(
'%name' => $form_state['values']['name'],
), WATCHDOG_NOTICE, l(t('view'), 'admin/build/mailing-list/' . db_last_insert_id('mailing_list', 'mlid')));
}
}
else {
if (isset($form_state['values']['mlid'])) {
drupal_set_message(t('Failed to update mailing list %name', array(
'%name' => $form_state['values']['name'],
)), 'error');
}
else {
drupal_set_message(t('Failed to create mailing list %name', array(
'%name' => $form_state['values']['name'],
)), 'error');
}
}
}