From bdfa0f9a6bf233ee61b3b9d24f816d0e33db271c Mon Sep 17 00:00:00 2001 From: pdontthink Date: Fri, 18 May 2007 10:41:02 +0000 Subject: [PATCH] Correctly update cached message flags in ALL places when they are changed by the user git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@12413 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/mailbox_display.php | 29 +++++++++++++++++++++++++++-- src/read_body.php | 9 +++++++-- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/functions/mailbox_display.php b/functions/mailbox_display.php index 1b818700..b54905c8 100644 --- a/functions/mailbox_display.php +++ b/functions/mailbox_display.php @@ -1381,9 +1381,9 @@ function handleMessageListForm($imapConnection,&$aMailbox,$sButton='',$aUid = ar break; } /** - * Updates messages is an array containing the result of the untagged + * $aUpdatedMsgs is an array containing the result of the untagged * fetch responses send by the imap server due to a flag change. That - * response is parsed in a array with msg arrays by the parseFetch function + * response is parsed in an array with msg arrays by the parseFetch function */ if ($aUpdatedMsgs) { // Update the message headers cache @@ -1397,6 +1397,31 @@ function handleMessageListForm($imapConnection,&$aMailbox,$sButton='',$aUid = ar if (isset($aMailbox['MSG_HEADERS'][$iUid])) { $aMailbox['MSG_HEADERS'][$iUid]['FLAGS'] = $aMsg['FLAGS']; } + /** + * Also update flags in message object + */ +//FIXME: WHY are we keeping flags in TWO places?!? This is error-prone and some core code uses the is_xxxx message object values while other code uses the flags array above. That's a mess. + if (isset($aMailbox['MSG_HEADERS'][$iUid]['MESSAGE_OBJECT'])) { + $message = $aMailbox['MSG_HEADERS'][$iUid]['MESSAGE_OBJECT']; + $message->is_seen = false; + $message->is_answered = false; + $message->is_deleted = false; + $message->is_flagged = false; + $message->is_mdnsent = false; + foreach ($aMsg['FLAGS'] as $flag => $value) { + if (strtolower($flag) == '\\seen' && $value) + $message->is_seen = true; + else if (strtolower($flag) == '\\answered' && $value) + $message->is_answered = true; + else if (strtolower($flag) == '\\deleted' && $value) + $message->is_deleted = true; + else if (strtolower($flag) == '\\flagged' && $value) + $message->is_flagged = true; + else if (strtolower($flag) == '$mdnsent' && $value) + $message->is_mdnsent = true; + } + $aMailbox['MSG_HEADERS'][$iUid]['MESSAGE_OBJECT'] = $message; + } /** * Count the messages with the \Delete flag set so we can determine * if the number of expunged messages equals the number of flagged diff --git a/src/read_body.php b/src/read_body.php index b2f82662..36e3ab2b 100644 --- a/src/read_body.php +++ b/src/read_body.php @@ -877,9 +877,14 @@ if (isset($aMailbox['MSG_HEADERS'][$passed_id]['MESSAGE_OBJECT'])) { } else { $message = sqimap_get_message($imapConnection, $passed_id, $mailbox); $FirstTimeSee = !$message->is_seen; - $message->is_seen = true; - $aMailbox['MSG_HEADERS'][$passed_id]['MESSAGE_OBJECT'] = $message; } + +/** + * update message seen status and put in cache + */ +$message->is_seen = true; +$aMailbox['MSG_HEADERS'][$passed_id]['MESSAGE_OBJECT'] = $message; + if (isset($passed_ent_id) && $passed_ent_id) { $message = $message->getEntity($passed_ent_id); if ($message->type0 != 'message' && $message->type1 != 'rfc822') { -- 2.25.1