Move draft removal code to IMP_Compose_Ui function.
No need to pass draft UID in MIMP/IMP - this information is stored as
metadata within the IMP_Compose object.
* @package IMP
*/
-function _removeAutoSaveDraft($uid)
-{
- if (!empty($uid)) {
- $imp_message = IMP_Message::singleton();
- $imp_message->delete(array($uid . IMP::IDX_SEP . IMP::folderPref($GLOBALS['prefs']->getValue('drafts_folder'), true)), array('nuke' => true));
- }
-}
-
require_once dirname(__FILE__) . '/lib/Application.php';
new IMP_Application(array('init' => true, 'tz' => true));
$result->success = 1;
/* Delete existing draft. */
- _removeAutoSaveDraft($old_uid);
+ $imp_ui->removeDraft($old_uid);
if ($action == 'auto_save_draft') {
$notification->push(_("Draft automatically saved."), 'horde.message');
/* Remove any auto-saved drafts. */
if ($prefs->getValue('auto_save_drafts') ||
$prefs->getValue('auto_delete_drafts')) {
- _removeAutoSaveDraft($imp_compose->getMetadata('draft_uid'));
+ $imp_ui->removeDraft($imp_compose->getMetadata('draft_uid'));
$result->draft_delete = 1;
}
$sent_mail_folder = $identity->getValue('sent_mail_folder');
$thismailbox = Horde_Util::getFormData('thismailbox');
$uid = Horde_Util::getFormData('uid');
-$resume_draft = false;
/* Determine if mailboxes are readonly. */
$draft = IMP::folderPref($prefs->getValue('drafts_folder'), true);
$identity->setDefault($result['identity']);
$sent_mail_folder = $identity->getValue('sent_mail_folder');
}
- $resume_draft = true;
} catch (IMP_Compose_Exception $e) {
$notification->push($e, 'horde.error');
}
try {
if ($imp_compose->buildAndSendMessage($message, $header, Horde_Nls::getEmailCharset(), false, $options)) {
- $imp_compose->destroy();
- if (Horde_Util::getFormData('resume_draft') &&
- $prefs->getValue('auto_delete_drafts')) {
- $imp_message = IMP_Message::singleton();
- $idx_array = array($uid . IMP::IDX_SEP . $thismailbox);
- $delete_draft = $imp_message->delete($idx_array, array('nuke' => true));
+ if ($prefs->getValue('auto_delete_drafts')) {
+ $imp_ui->removeDraft($imp_compose->getMetadata('draft_uid'));
}
+ $imp_compose->destroy();
+
$notification->push(_("Message sent successfully."), 'horde.success');
require IMP_BASE . '/mailbox-mimp.php';
exit;
$identity->setDefault($result['identity']);
$sent_mail_folder = $identity->getValue('sent_mail_folder');
}
- $resume_draft = true;
} catch (IMP_Compose_Exception $e) {
$notification->push($e, 'horde.error');
}
try {
$sent = $imp_compose->buildAndSendMessage($message, $header, $charset, $rtemode, $options);
+
+ if ($prefs->getValue('auto_delete_drafts')) {
+ $imp_ui->removeDraft($imp_compose->getMetadata('draft_uid'));
+ }
+
$imp_compose->destroy();
} catch (IMP_Compose_Exception $e) {
$get_sig = false;
break;
}
- if (Horde_Util::getFormData('resume_draft') &&
- $prefs->getValue('auto_delete_drafts') &&
- ($thismailbox == IMP::folderPref($prefs->getValue('drafts_folder'), true))) {
- $imp_message = IMP_Message::singleton();
- $idx_array = array($uid . IMP::IDX_SEP . $thismailbox);
- if ($imp_message->delete($idx_array)) {
- $notification->push(_("The draft message was automatically deleted because it was successfully completed and sent."), 'horde.success');
- }
- }
-
if ($isPopup) {
if ($prefs->getValue('compose_confirm') || !$sent) {
if ($sent) {
foreach (array('page', 'start', 'popup') as $val) {
$hidden[$val] = htmlspecialchars(Horde_Util::getFormData($val));
}
- if (!empty($resume_draft)) {
- $hidden['resume_draft'] = 1;
- }
if ($browser->hasQuirk('broken_multipart_form')) {
$hidden['msie_formdata_is_broken'] = '';
));
}
+ /**
+ * Remove draft message.
+ *
+ * @param integer $uid The draft message UID.
+ */
+ public function removeDraft($uid)
+ {
+ if (!empty($uid)) {
+ $imp_message = IMP_Message::singleton();
+ $imp_message->delete(array($uid . IMP::IDX_SEP . IMP::folderPref($GLOBALS['prefs']->getValue('drafts_folder'), true)), array('nuke' => true));
+ }
+ }
+
}
// Hidden Variables.
$f->add(new Horde_Mobile_hidden('composeCache', $cacheID));
-$f->add(new Horde_Mobile_hidden('resume_draft', Horde_Util::getFormData('resume_draft', $resume_draft)));
if (!$prefs->isLocked('default_identity')) {
$ib = $f->add(new Horde_Mobile_block(new Horde_Mobile_text(_("Identity: "))));