You are here

function mailhandler_mailbox_save in Mailhandler 6

Save a Mailhandler Mailbox in the database.

When $mailbox has 'mid' attribute defined, the database entry with this ID will be updated, otherwise a new mailbox will be created.

Parameters

$mailbox: A mailbox settings array.

Related topics

1 call to mailhandler_mailbox_save()
mailhandler_add_edit_mailbox_submit in ./mailhandler.admin.inc
Submit handler for mailhandler_add_edit_mailbox() form.

File

./mailhandler.module, line 374
Mailhandler module code.

Code

function mailhandler_mailbox_save(&$mailbox) {

  // Determine this is an update or a new mailbox.
  $update = isset($mailbox['mid']) && $mailbox['mid'] ? array(
    'mid',
  ) : array();

  // Set default values for missing mailbox attributes.
  $mailbox += mailhandler_mailbox_defaults();

  // Save entry into database.
  drupal_write_record('mailhandler', $mailbox, $update);

  // Record information message
  mailhandler_watchdog_record('Mailbox %mailbox saved.', array(
    '%mailbox' => $mailbox['mail'],
  ), WATCHDOG_INFO);
}