From 1eb0638c8e39b7ad6b4ca577ebb33e72cb8298dd Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Tue, 27 Oct 2009 18:00:54 -0600 Subject: [PATCH] Bug #8661: Save References/In-Reply-To header info when saving a draft --- imp/docs/CHANGES | 1 + imp/lib/Compose.php | 40 +++++++++++++++++++++++++++++++--------- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/imp/docs/CHANGES b/imp/docs/CHANGES index f01ce0cc8..c0018eee8 100644 --- a/imp/docs/CHANGES +++ b/imp/docs/CHANGES @@ -109,6 +109,7 @@ v5.0-git v4.3.6-cvs ---------- +[mms] Save References/In-Reply-To header info when saving a draft (Bug #8661). [jan] Fix viewing S/MIME encrypted and signed messages from Outlook (Express) (Bug #8629). [jan] Add Oracle-specific SQL script. diff --git a/imp/lib/Compose.php b/imp/lib/Compose.php index d6ae9b5f2..a64d6d8c5 100644 --- a/imp/lib/Compose.php +++ b/imp/lib/Compose.php @@ -235,6 +235,9 @@ class IMP_Compose /* Need to add Message-ID so we can use it in the index search. */ $draft_headers->addMessageIdHeader(); + /* Add necessary headers for replies. */ + $this->_addReferences($draft_headers); + return $base->toString(array('defserver' => $session ? $_SESSION['imp']['maildomain'] : null, 'headers' => $draft_headers)); } @@ -343,6 +346,14 @@ class IMP_Compose 'subject' => $headers->getValue('subject') ); + if ($val = $headers->getValue('references')) { + $this->_metadata['references'] = $val; + + if ($val = $headers->getValue('in-reply-to')) { + $this->_metadata['in_reply_to'] = $val; + } + } + list($this->_metadata['draft_index'],) = explode(IMP::IDX_SEP, $index); $this->_modified = true; @@ -482,15 +493,7 @@ class IMP_Compose $headers->addHeader('Subject', Horde_String::convertCharset($header['subject'], $browser_charset, $charset)); /* Add necessary headers for replies. */ - if (!empty($this->_metadata['reply_type']) && - ($this->_metadata['reply_type'] == 'reply')) { - if (!empty($this->_metadata['references'])) { - $headers->addHeader('References', implode(' ', preg_split('|\s+|', trim($this->_metadata['references'])))); - } - if (!empty($this->_metadata['in_reply_to'])) { - $headers->addHeader('In-Reply-To', $this->_metadata['in_reply_to']); - } - } + $this->_addReferences($headers); /* Add the 'User-Agent' header. */ if (empty($opts['useragent'])) { @@ -636,6 +639,25 @@ class IMP_Compose } /** + * Add necessary headers for replies. + * + * @param Horde_Mime_Headers $headers The object holding this message's + * headers. + */ + protected function _addReferences($headers) + { + if (!empty($this->_metadata['reply_type']) && + ($this->_metadata['reply_type'] == 'reply')) { + if (!empty($this->_metadata['references'])) { + $headers->addHeader('References', implode(' ', preg_split('|\s+|', trim($this->_metadata['references'])))); + } + if (!empty($this->_metadata['in_reply_to'])) { + $headers->addHeader('In-Reply-To', $this->_metadata['in_reply_to']); + } + } + } + + /** * Sends a message. * * @param string $email The e-mail list to send to. -- 2.11.0