diff options
-rw-r--r-- | program/lib/imap.inc | 2 | ||||
-rw-r--r-- | program/steps/mail/compose.inc | 19 | ||||
-rw-r--r-- | program/steps/mail/func.inc | 24 | ||||
-rw-r--r-- | program/steps/mail/sendmail.inc | 9 |
4 files changed, 45 insertions, 9 deletions
diff --git a/program/lib/imap.inc b/program/lib/imap.inc index 2316e404b..1a6a7aca9 100644 --- a/program/lib/imap.inc +++ b/program/lib/imap.inc @@ -1451,7 +1451,7 @@ function iil_C_FetchHeaders(&$conn, $mailbox, $message_set, $uidfetch=false, $bo $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; diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc index 36a352955..a5b0a340e 100644 --- a/program/steps/mail/compose.inc +++ b/program/steps/mail/compose.inc @@ -151,18 +151,27 @@ if (!empty($msg_uid)) 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']; - $_SESSION['compose']['reply_msgid'] = '<'.$MESSAGE->headers->in_reply_to.'>'; + $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) diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc index 101a978cd..3f2ac0289 100644 --- a/program/steps/mail/func.inc +++ b/program/steps/mail/func.inc @@ -1288,6 +1288,30 @@ function rcmail_wrap_quoted($text, $max = 76) } +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; diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc index acff62d79..13210be68 100644 --- a/program/steps/mail/sendmail.inc +++ b/program/steps/mail/sendmail.inc @@ -313,12 +313,12 @@ else if (!empty($identity_arr['reply-to'])) 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 @@ if (!empty($_POST['_receipt'])) $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']; |