fix from Michael Long for imap servers that do not return the UID in the fetch response
authorstekkel <stekkel@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Mon, 21 Nov 2005 19:34:15 +0000 (19:34 +0000)
committerstekkel <stekkel@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Mon, 21 Nov 2005 19:34:15 +0000 (19:34 +0000)
returned by doing a UID STORE.

git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@10386 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/imap_messages.php

index 6d847aaf0ae7a64ddc2bc20994f13473d5fb148b..7e63ddc85462e4fd088a613c1c2ca3e4e8fb2c4e 100755 (executable)
@@ -89,9 +89,27 @@ function sqimap_msgs_list_delete($imap_stream, $mailbox, $id, $bypass_trash=fals
 function sqimap_toggle_flag($imap_stream, $id, $flag, $set, $handle_errors) {
     $msgs_id = sqimap_message_list_squisher($id);
     $set_string = ($set ? '+' : '-');
+
+    // mpl-spirit
+    for ($i=0; $i<sizeof($id); $i++) {
+        $aMessageList["$id[$i]"] = array();
+    }
+
     $aResponse = sqimap_run_command_list($imap_stream, "STORE $msgs_id ".$set_string."FLAGS ($flag)", $handle_errors, $response, $message, TRUE);
-    // parse the fetch response
-    return parseFetch($aResponse);
+
+    // parse the fetch response (mpl-spirit added 2nd arg)
+    $parseFetchResults=parseFetch($aResponse,$aMessageList);
+
+    // mpl-spirit
+    // some broken IMAP servers do not return UID elements on UID STORE
+    // if this is the case, then we need to do a UID FETCH
+    $testkey=$id[0];
+    if (!isset($parseFetchResults[$testkey]['UID'])) {
+        $aResponse = sqimap_run_command_list($imap_stream, "FETCH $msgs_id (FLAGS)", $handle_errors, $response, $message, TRUE);
+        $parseFetchResults = parseFetch($aResponse,$aMessageList);
+    }
+
+    return ($parseFetchResults);
 }