protected function _saveDraftServer($data)
{
if (!($drafts_mbox = IMP_Mailbox::getPref(IMP_Mailbox::MBOX_DRAFTS))) {
throw new IMP_Compose_Exception(_("Saving the draft failed. No drafts mailbox specified."));
}
/* Check for access to drafts mailbox. */
if (!$drafts_mbox->create()) {
throw new IMP_Compose_Exception(_("Saving the draft failed. Could not create a drafts mailbox."));
}
$append_flags = array(Horde_Imap_Client::FLAG_DRAFT, Horde_Imap_Client::FLAG_MDNSENT);
if (!$GLOBALS['prefs']->getValue('unseen_drafts')) {
$append_flags[] = Horde_Imap_Client::FLAG_SEEN;
}
$old_uid = $this->getMetadata('draft_uid');
/* Add the message to the mailbox. */
try {
$ids = $drafts_mbox->imp_imap->append($drafts_mbox, array(array('data' => $data, 'flags' => $append_flags)));
if ($old_uid) {
$old_uid->delete(array('nuke' => true));
}
$this->_setMetadata('draft_uid', $drafts_mbox->getIndicesOb($ids));
return sprintf(_("The draft has been saved to the \"%s\" mailbox."), $drafts_mbox->display);
} catch (IMP_Imap_Exception $e) {
return _("The draft was not successfully saved.");
}
}