Pārlūkot izejas kodu

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

stekkel 19 gadi atpakaļ
vecāks
revīzija
07e5783857
1 mainītis faili ar 27 papildinājumiem un 3 dzēšanām
  1. 27 3
      src/compose.php

+ 27 - 3
src/compose.php

@@ -82,6 +82,7 @@ if ( sqgetGlobalVar('startMessage',$startMessage) ) {
     $startMessage = 1;
     $startMessage = 1;
 }
 }
 
 
+
 /** POST VARS */
 /** POST VARS */
 sqgetGlobalVar('sigappend',             $sigappend,             SQ_POST);
 sqgetGlobalVar('sigappend',             $sigappend,             SQ_POST);
 sqgetGlobalVar('from_htmladdr_search',  $from_htmladdr_search,  SQ_POST);
 sqgetGlobalVar('from_htmladdr_search',  $from_htmladdr_search,  SQ_POST);
@@ -96,6 +97,12 @@ if ( sqgetGlobalVar('return', $temp, SQ_POST) ) {
 
 
 /** GET VARS */
 /** GET VARS */
 sqgetGlobalVar('attachedmessages', $attachedmessages, SQ_GET);
 sqgetGlobalVar('attachedmessages', $attachedmessages, SQ_GET);
+if ( sqgetGlobalVar('account', $temp,  SQ_GET) ) {
+    $iAccount = (int) $temp;
+} else {
+    $iAccount = 0;
+}
+
 
 
 /** get smaction */
 /** get smaction */
 if ( !sqgetGlobalVar('smaction',$action) )
 if ( !sqgetGlobalVar('smaction',$action) )
@@ -1657,12 +1664,29 @@ function deliverMessage($composeMessage, $draft=false) {
             sqimap_append_done ($imap_stream, $sent_folder);
             sqimap_append_done ($imap_stream, $sent_folder);
             unset ($imap_deliver);
             unset ($imap_deliver);
         }
         }
-        global $passed_id, $mailbox, $action;
+
+        global $passed_id, $mailbox, $action, $what, $iAccount,$startMessage;
+
         ClearAttachments($composeMessage);
         ClearAttachments($composeMessage);
         if ($action == 'reply' || $action == 'reply_all') {
         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);
         sqimap_logout($imap_stream);
     }
     }
     return $succes;
     return $succes;