Browse Source

Update the cached flag info in the mailbox cache in case of an reply (set
the reply flag in the cache)

stekkel 19 năm trước cách đây
mục cha
commit
07e5783857
1 tập tin đã thay đổi với 27 bổ sung3 xóa
  1. 27 3
      src/compose.php

+ 27 - 3
src/compose.php

@@ -82,6 +82,7 @@ if ( sqgetGlobalVar('startMessage',$startMessage) ) {
     $startMessage = 1;
 }
 
+
 /** POST VARS */
 sqgetGlobalVar('sigappend',             $sigappend,             SQ_POST);
 sqgetGlobalVar('from_htmladdr_search',  $from_htmladdr_search,  SQ_POST);
@@ -96,6 +97,12 @@ if ( sqgetGlobalVar('return', $temp, SQ_POST) ) {
 
 /** GET VARS */
 sqgetGlobalVar('attachedmessages', $attachedmessages, SQ_GET);
+if ( sqgetGlobalVar('account', $temp,  SQ_GET) ) {
+    $iAccount = (int) $temp;
+} else {
+    $iAccount = 0;
+}
+
 
 /** get smaction */
 if ( !sqgetGlobalVar('smaction',$action) )
@@ -1657,12 +1664,29 @@ function deliverMessage($composeMessage, $draft=false) {
             sqimap_append_done ($imap_stream, $sent_folder);
             unset ($imap_deliver);
         }
-        global $passed_id, $mailbox, $action;
+
+        global $passed_id, $mailbox, $action, $what, $iAccount,$startMessage;
+
         ClearAttachments($composeMessage);
         if ($action == 'reply' || $action == 'reply_all') {
-            sqimap_mailbox_select ($imap_stream, $mailbox);
-            sqimap_toggle_flag($imap_stream, array($passed_id), '\\Answered', true, false);
+            $aMailbox = sqm_api_mailbox_select($imap_stream, $iAccount, $mailbox,array('setindex' => $what, 'offset' => $startMessage),array());
+            //sqimap_mailbox_select ($imap_stream, $mailbox);
+            $aUpdatedMsgs = sqimap_toggle_flag($imap_stream, array($passed_id), '\\Answered', true, false);
+             if (isset($aUpdatedMsgs[$iUid]['FLAGS'])) {
+                /**
+                 * Only update the cached headers if the header is
+                 * cached.
+                 */
+                if (isset($aMailbox['MSG_HEADERS'][$iUid])) {
+                    $aMailbox['MSG_HEADERS'][$iUid]['FLAGS'] = $aMsg['FLAGS'];
+                }
+            }
         }
+        /**
+         * Write mailbox with updated seen flag information back to cache.
+         */
+        $mailbox_cache[$iAccount.'_'.$aMailbox['NAME']] = $aMailbox;
+        sqsession_register($mailbox_cache,'mailbox_cache');
         sqimap_logout($imap_stream);
     }
     return $succes;