Bug #8661: Save References/In-Reply-To header info when saving a draft
authorMichael M Slusarz <slusarz@curecanti.org>
Wed, 28 Oct 2009 00:00:54 +0000 (18:00 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Wed, 28 Oct 2009 00:01:27 +0000 (18:01 -0600)
imp/docs/CHANGES
imp/lib/Compose.php

index f01ce0c..c0018ee 100644 (file)
@@ -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.
index d6ae9b5..a64d6d8 100644 (file)
@@ -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.