function mailhandler_add_edit_mailbox_submit in Mailhandler 7
Same name and namespace in other branches
- 6 mailhandler.admin.inc \mailhandler_add_edit_mailbox_submit()
Save a mailbox to the database - determine whether adding or editing by checking for a mailbox id (mid)
File
- ./
mailhandler.admin.inc, line 241
Code
function mailhandler_add_edit_mailbox_submit($form, &$form_state) {
// TODO: try to rewrite these monsters wth drupal_write_record();
if ($form_state['values']['mid']) {
db_query("UPDATE {mailhandler} SET mail = '%s', mailto = '%s', domain = '%s', port = %d, folder = '%s', name = '%s', pass = '%s', extraimap = '%s', mime = '%s', imap = '%s', security = %d, replies = %d, fromheader = '%s', commands = '%s', sigseparator = '%s', enabled = %d, delete_after_read = %d, format = %d, authentication = '%s' WHERE mid = %d", $form_state['values']['mail'], $form_state['values']['mailto'], $form_state['values']['domain'], $form_state['values']['port'], $form_state['values']['folder'], $form_state['values']['name'], $form_state['values']['pass'], $form_state['values']['extraimap'], $form_state['values']['mime'], $form_state['values']['imap'], $form_state['values']['security'], $form_state['values']['replies'], $form_state['values']['fromheader'], $form_state['values']['commands'], $form_state['values']['sigseparator'], $form_state['values']['enabled'], $form_state['values']['delete_after_read'], $form_state['values']['format'], $form_state['values']['authentication'], $form_state['values']['mid']);
drupal_set_message(t('Mailbox %mailbox updated.', array(
'%mailbox' => $form_state['values']['mail'],
)));
}
else {
db_query("INSERT INTO {mailhandler} (mail, mailto, domain, port, folder, name, pass, extraimap, mime, imap, security, replies, fromheader, commands, sigseparator, enabled, delete_after_read, format, authentication) VALUES ('%s', '%s', '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', '%s', %d, %d, %d, '%s')", $form_state['values']['mail'], $form_state['values']['mailto'], $form_state['values']['domain'], $form_state['values']['port'], $form_state['values']['folder'], $form_state['values']['name'], $form_state['values']['pass'], $form_state['values']['extraimap'], $form_state['values']['mime'], $form_state['values']['imap'], $form_state['values']['security'], $form_state['values']['replies'], $form_state['values']['fromheader'], $form_state['values']['commands'], $form_state['values']['sigseparator'], $form_state['values']['enabled'], $form_state['values']['delete_after_read'], $form_state['values']['format'], $form_state['values']['authentication']);
drupal_set_message(t('Mailbox %mailbox added.', array(
'%mailbox' => $form_state['values']['mail'],
)));
}
$form_state['redirect'] = 'admin/content/mailhandler';
return;
}