From ce3105c58f921f33654c738fa7460d3d107813ce Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Thu, 24 Mar 2016 12:07:31 -0400
Subject: [PATCH] Reply/Reply-All/Forward/Change-format buttons for message/rfc822 preview

---
 program/steps/mail/sendmail.inc |   26 +++++++++++++++++++-------
 1 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc
index dbd6f98..68c444e 100644
--- a/program/steps/mail/sendmail.inc
+++ b/program/steps/mail/sendmail.inc
@@ -189,11 +189,17 @@
 }
 
 // remember reply/forward UIDs in special headers
-if (!empty($COMPOSE['reply_uid']) && $savedraft) {
-    $headers['X-Draft-Info'] = array('type' => 'reply', 'uid' => $COMPOSE['reply_uid']);
-}
-else if (!empty($COMPOSE['forward_uid']) && $savedraft) {
-    $headers['X-Draft-Info'] = array('type' => 'forward', 'uid' => rcube_imap_generic::compressMessageSet($COMPOSE['forward_uid']));
+if ($savedraft) {
+    // Note: We ignore <UID>.<PART> forwards/replies here
+    if (($uid = $COMPOSE['reply_uid']) && !preg_match('/^\d+[0-9.]+$/', $uid)) {
+        $headers['X-Draft-Info'] = array('type' => 'reply', 'uid' => $uid);
+    }
+    else if (!empty($COMPOSE['forward_uid'])
+        && ($uid = rcube_imap_generic::compressMessageSet($COMPOSE['forward_uid']))
+        && !preg_match('/^\d+[0-9.]+$/', $uid)
+    ) {
+        $headers['X-Draft-Info'] = array('type' => 'forward', 'uid' => $uid);
+    }
 }
 
 if (!empty($COMPOSE['reply_msgid'])) {
@@ -550,12 +556,18 @@
     // set replied/forwarded flag
     if ($COMPOSE['reply_uid']) {
         foreach (rcmail::get_uids($COMPOSE['reply_uid'], $COMPOSE['mailbox']) as $mbox => $uids) {
-            $RCMAIL->storage->set_flag($uids, 'ANSWERED', $mbox);
+            // skip <UID>.<PART> replies
+            if (!preg_match('/^\d+[0-9.]+$/', implode(',', (array) $uids))) {
+                $RCMAIL->storage->set_flag($uids, 'ANSWERED', $mbox);
+            }
         }
     }
     else if ($COMPOSE['forward_uid']) {
         foreach (rcmail::get_uids($COMPOSE['forward_uid'], $COMPOSE['mailbox']) as $mbox => $uids) {
-            $RCMAIL->storage->set_flag($uids, 'FORWARDED', $mbox);
+            // skip <UID>.<PART> forwards
+            if (!preg_match('/^\d+[0-9.]+$/', implode(',', (array) $uids))) {
+                $RCMAIL->storage->set_flag($uids, 'FORWARDED', $mbox);
+            }
         }
     }
 }

--
Gitblit v1.9.1