From: Michael M Slusarz Date: Thu, 10 Dec 2009 18:59:13 +0000 (-0700) Subject: Draft removal tweaks. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=1e1f5f321decb41665545aadcccf5a07b41e284f;p=horde.git Draft removal tweaks. 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. --- diff --git a/imp/compose-dimp.php b/imp/compose-dimp.php index 5368c3e90..949a3a128 100644 --- a/imp/compose-dimp.php +++ b/imp/compose-dimp.php @@ -17,14 +17,6 @@ * @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)); @@ -99,7 +91,7 @@ if (count($_POST)) { $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'); @@ -171,7 +163,7 @@ if (count($_POST)) { /* 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; } diff --git a/imp/compose-mimp.php b/imp/compose-mimp.php index b1fb59cc3..d9d6df133 100644 --- a/imp/compose-mimp.php +++ b/imp/compose-mimp.php @@ -56,7 +56,6 @@ $save_sent_mail = $prefs->getValue('save_sent_mail'); $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); @@ -107,7 +106,6 @@ case 'd': $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'); } @@ -269,15 +267,13 @@ case _("Send"): 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; diff --git a/imp/compose.php b/imp/compose.php index 41cc366a0..f92a81683 100644 --- a/imp/compose.php +++ b/imp/compose.php @@ -283,7 +283,6 @@ case 'draft': $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'); } @@ -409,6 +408,11 @@ case 'send_message': 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; @@ -432,16 +436,6 @@ case 'send_message': 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) { @@ -855,9 +849,6 @@ if ($redirect) { 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'] = ''; diff --git a/imp/lib/Ui/Compose.php b/imp/lib/Ui/Compose.php index e3e0af87e..03fa083a2 100644 --- a/imp/lib/Ui/Compose.php +++ b/imp/lib/Ui/Compose.php @@ -226,4 +226,17 @@ class IMP_Ui_Compose )); } + /** + * 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)); + } + } + } diff --git a/imp/templates/compose/compose-mimp.inc b/imp/templates/compose/compose-mimp.inc index a4c83142f..df9a385dc 100644 --- a/imp/templates/compose/compose-mimp.inc +++ b/imp/templates/compose/compose-mimp.inc @@ -10,7 +10,6 @@ $f = $c->add(new Horde_Mobile_form('compose-mimp.php')); // 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: "))));