From bbc8565e5afa7e5352bc3aaf7cf067066ec6d4b1 Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Thu, 04 Mar 2010 03:17:04 -0500
Subject: [PATCH] Flag original messages after sending a draft (#1486203)

---
 CHANGELOG                       |    1 +
 program/steps/mail/compose.inc  |    6 +++---
 program/lib/imap.inc            |    3 ++-
 program/steps/mail/sendmail.inc |    6 ++++++
 4 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index cbd39a1..30fe24e 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
 CHANGELOG RoundCube Webmail
 ===========================
 
+- Flag original messages when sending a draft (#1486203)
 - Changed signature separator when top-posting (#1486330)
 - Let the admin define defaults for search modifiers (#1485897)
 - Fix long e-mail addresses validation (#1486453)
diff --git a/program/lib/imap.inc b/program/lib/imap.inc
index 9a5a67b..2316e40 100644
--- a/program/lib/imap.inc
+++ b/program/lib/imap.inc
@@ -1450,7 +1450,8 @@
 	$request .= "BODY.PEEK[HEADER.FIELDS ";
 	$request .= "(DATE FROM TO SUBJECT REPLY-TO IN-REPLY-TO CC BCC ";
 	$request .= "CONTENT-TRANSFER-ENCODING CONTENT-TYPE MESSAGE-ID ";
-	$request .= "REFERENCES DISPOSITION-NOTIFICATION-TO X-PRIORITY".$add.")])";
+	$request .= "REFERENCES DISPOSITION-NOTIFICATION-TO X-PRIORITY ";
+	$request .= "X-REPLY-UID X-FORWARD-UID".$add.")])";
 
 	if (!iil_PutLine($fp, $request)) {
 		return false;
diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc
index 52a396b..fa1ea95 100644
--- a/program/steps/mail/compose.inc
+++ b/program/steps/mail/compose.inc
@@ -158,9 +158,9 @@
   {
     if($MESSAGE->headers->in_reply_to)
     {
-      // TODO: how to get reply_uid/forward_uid value, maybe we must set X-Reply-UID/X-Forward-UID
-      // $_SESSION['compose']['reply_uid'] = ?
-      // $_SESSION['compose']['forward_uid'] = ?
+      // get reply_uid/forward_uid to flag the original message when sending
+      $_SESSION['compose']['reply_uid'] = $MESSAGE->headers->others['x-reply-uid'];
+      $_SESSION['compose']['forward_uid'] = $MESSAGE->headers->others['x-forward-uid'];
       $_SESSION['compose']['reply_msgid'] = '<'.$MESSAGE->headers->in_reply_to.'>';
     }
     $_SESSION['compose']['references']  = $MESSAGE->headers->references;
diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc
index 134664b..abd4209 100644
--- a/program/steps/mail/sendmail.inc
+++ b/program/steps/mail/sendmail.inc
@@ -314,6 +314,12 @@
 if (!empty($_SESSION['compose']['reply_msgid']))
   $headers['In-Reply-To'] = $_SESSION['compose']['reply_msgid'];
 
+// remember reply/forward UIDs in special headers
+if (!empty($_SESSION['compose']['reply_uid']) && $savedraft)
+  $headers['X-Reply-UID'] = $_SESSION['compose']['reply_uid'];
+else if (!empty($_SESSION['compose']['forward_uid']) && $savedraft)
+  $headers['X-Forward-UID'] = $_SESSION['compose']['forward_uid'];
+
 if (!empty($_SESSION['compose']['references']))
   $headers['References'] = $_SESSION['compose']['references'];
 

--
Gitblit v1.9.1