Browse Source

fix from Michael Long for imap servers that do not return the UID in the fetch response
returned by doing a UID STORE.

stekkel 19 years ago
parent
commit
04c62bb45f
1 changed files with 20 additions and 2 deletions
  1. 20 2
      functions/imap_messages.php

+ 20 - 2
functions/imap_messages.php

@@ -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);
 }