[Svn] r3353 - in trunk/roundcubemail/program: lib steps/mail

trac at roundcube.net trac at roundcube.net
Thu Mar 11 23:44:44 CET 2010


Author: thomasb
Date: 2010-03-11 16:44:43 -0600 (Thu, 11 Mar 2010)
New Revision: 3353

Modified:
   trunk/roundcubemail/program/lib/imap.inc
   trunk/roundcubemail/program/steps/mail/compose.inc
   trunk/roundcubemail/program/steps/mail/func.inc
   trunk/roundcubemail/program/steps/mail/sendmail.inc
Log:
Save draft information in one header; finally fixes #1486203

Modified: trunk/roundcubemail/program/lib/imap.inc
===================================================================
--- trunk/roundcubemail/program/lib/imap.inc	2010-03-11 18:34:01 UTC (rev 3352)
+++ trunk/roundcubemail/program/lib/imap.inc	2010-03-11 22:44:43 UTC (rev 3353)
@@ -1451,7 +1451,7 @@
 	$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 ";
-	$request .= "X-REPLY-UID X-FORWARD-UID".$add.")])";
+	$request .= "X-DRAFT-INFO".$add.")])";
 
 	if (!iil_PutLine($fp, $request)) {
 		return false;

Modified: trunk/roundcubemail/program/steps/mail/compose.inc
===================================================================
--- trunk/roundcubemail/program/steps/mail/compose.inc	2010-03-11 18:34:01 UTC (rev 3352)
+++ trunk/roundcubemail/program/steps/mail/compose.inc	2010-03-11 22:44:43 UTC (rev 3353)
@@ -151,18 +151,27 @@
 
     if (!empty($_SESSION['compose']['param']['all']))
       $MESSAGE->reply_all = 1;
-      
+
     $OUTPUT->set_env('compose_mode', 'reply');
   }
   else if ($compose_mode == RCUBE_COMPOSE_DRAFT)
   {
-    if($MESSAGE->headers->in_reply_to)
+    if ($MESSAGE->headers->others['x-draft-info'])
     {
       // 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'];
+      $info = rcmail_draftinfo_decode($MESSAGE->headers->others['x-draft-info']);
+
+      if ($info['type'] == 'reply')
+        $_SESSION['compose']['reply_uid'] = $info['uid'];
+      else if ($info['type'] == 'forward')
+        $_SESSION['compose']['forward_uid'] = $info['uid'];
+
+      $_SESSION['compose']['mailbox'] = $info['folder'];
+    }
+    
+    if ($MESSAGE->headers->in_reply_to)
       $_SESSION['compose']['reply_msgid'] = '<'.$MESSAGE->headers->in_reply_to.'>';
-    }
+
     $_SESSION['compose']['references']  = $MESSAGE->headers->references;
   }
   else if ($compose_mode == RCUBE_COMPOSE_FORWARD)

Modified: trunk/roundcubemail/program/steps/mail/func.inc
===================================================================
--- trunk/roundcubemail/program/steps/mail/func.inc	2010-03-11 18:34:01 UTC (rev 3352)
+++ trunk/roundcubemail/program/steps/mail/func.inc	2010-03-11 22:44:43 UTC (rev 3353)
@@ -1288,6 +1288,30 @@
 }
 
 
+function rcmail_draftinfo_encode($p)
+{
+  $parts = array();
+  foreach ($p as $key => $val)
+    $parts[] = $key . '=' . ($key == 'folder' ? base64_encode($val) : $val);
+  
+  return join('; ', $parts);
+}
+
+
+function rcmail_draftinfo_decode($str)
+{
+  $info = array();
+  foreach (preg_split('/;\s+/', $str) as $part) {
+    list($key, $val) = explode('=', $part, 2);
+    if ($key == 'folder')
+      $val = base64_decode($val);
+    $info[$key] = $val;
+  }
+  
+  return $info;
+}
+
+
 function rcmail_message_part_controls()
   {
   global $MESSAGE;

Modified: trunk/roundcubemail/program/steps/mail/sendmail.inc
===================================================================
--- trunk/roundcubemail/program/steps/mail/sendmail.inc	2010-03-11 18:34:01 UTC (rev 3352)
+++ trunk/roundcubemail/program/steps/mail/sendmail.inc	2010-03-11 22:44:43 UTC (rev 3353)
@@ -313,12 +313,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'];
+  $headers['X-Draft-Info'] = array('type' => 'reply', 'uid' => $_SESSION['compose']['reply_uid']);
 else if (!empty($_SESSION['compose']['forward_uid']) && $savedraft)
-  $headers['X-Forward-UID'] = $_SESSION['compose']['forward_uid'];
+  $headers['X-Draft-Info'] = array('type' => 'forward', 'uid' => $_SESSION['compose']['forward_uid']);
 
 if (!empty($_SESSION['compose']['references']))
   $headers['References'] = $_SESSION['compose']['references'];
@@ -341,6 +341,9 @@
 $headers['Message-ID'] = $message_id;
 $headers['X-Sender'] = $from;
 
+if (is_array($headers['X-Draft-Info']))
+  $headers['X-Draft-Info'] = rcmail_draftinfo_encode($headers['X-Draft-Info'] + array('folder' => $_SESSION['compose']['mailbox']));
+
 if (!empty($CONFIG['useragent']))
   $headers['User-Agent'] = $CONFIG['useragent'];
 

_______________________________________________
http://lists.roundcube.net/mailman/listinfo/svn



More information about the Svn mailing list