From 71bfa5f207a70b335399e0392f56d7b89a35f5e4 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Wed, 29 Jul 2015 19:41:16 +0200 Subject: [PATCH] Fix draft removal after a message is sent and storing sent message is disabled (#1490467) --- CHANGELOG | 1 + program/steps/mail/sendmail.inc | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 5ab0b74ec..d79694e69 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -16,6 +16,7 @@ CHANGELOG Roundcube Webmail - Fix multi-folder search result sorting by arrival date (#1490450) - Fix so *-request@ addresses in Sender: header are also ignored on reply-all (#1490452) - Update to TinyMCE 4.1.10 (#1490405) +- Fix draft removal after a message is sent and storing sent message is disabled (#1490467) RELEASE 1.1.2 ------------- diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc index 5326d6452..154a4245c 100644 --- a/program/steps/mail/sendmail.inc +++ b/program/steps/mail/sendmail.inc @@ -636,24 +636,24 @@ if ($store_target) { $OUTPUT->send('iframe'); } } - - // delete previous saved draft - if ($saved && ($old_id = rcube_utils::get_input_value('_draft_saveid', rcube_utils::INPUT_POST))) { - $deleted = $RCMAIL->storage->delete_message($old_id, $drafts_mbox); - - // raise error if deletion of old draft failed - if (!$deleted) { - rcube::raise_error(array('code' => 800, 'type' => 'imap', - 'file' => __FILE__, 'line' => __LINE__, - 'message' => "Could not delete message from $drafts_mbox"), true, false); - } - } } // remove temp file else if ($mailbody_file) { unlink($mailbody_file); } +// delete previous saved draft +$old_id = rcube_utils::get_input_value('_draft_saveid', rcube_utils::INPUT_POST); +if ($old_id && ($sent || $saved)) { + $deleted = $RCMAIL->storage->delete_message($old_id, $drafts_mbox); + + // raise error if deletion of old draft failed + if (!$deleted) { + rcube::raise_error(array('code' => 800, 'type' => 'imap', + 'file' => __FILE__, 'line' => __LINE__, + 'message' => "Could not delete message from $drafts_mbox"), true, false); + } +} if ($savedraft) { // remember new draft-uid ($saved could be an UID or true/false here)