From: Michael M Slusarz Date: Tue, 2 Feb 2010 06:58:53 +0000 (-0700) Subject: Delete older auto save draft. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=abdf859122e1bcd25aa8180b344c638806643ff8;p=horde.git Delete older auto save draft. --- diff --git a/imp/lib/Compose.php b/imp/lib/Compose.php index bfe16a560..8daebbeff 100644 --- a/imp/lib/Compose.php +++ b/imp/lib/Compose.php @@ -312,8 +312,19 @@ class IMP_Compose /* Add the message to the mailbox. */ try { + if ($this->getMetadata('autodraft')) { + $old_uid = $this->getMetadata('draft_uid'); + } + $ids = $GLOBALS['imp_imap']->ob()->append($drafts_mbox, array(array('data' => $data, 'flags' => $append_flags, 'messageid' => $headers->getValue('message-id')))); + + if ($old_uid) { + $idx_array = array($old_uid . IMP::IDX_SEP . IMP::folderPref($GLOBALS['prefs']->getValue('drafts_folder'), true)); + $GLOBALS['injector']->getInstance('IMP_Message')->delete($idx_array, array('nuke' => true)); + } + $this->_metadata['draft_uid'] = reset($ids); + $this->_metadata['autodraft'] = true; $this->_modified = true; return sprintf(_("The draft has been saved to the \"%s\" folder."), IMP::displayFolder($drafts_mbox)); } catch (Horde_Imap_Client_Exception $e) {