Fix IMAP PARSE reponse matching. This should get rid of retrival errors
[squirrelmail.git] / functions / imap_messages.php
index 551f3ff92d587ecc6d838e1c721369b84979cbe6..a411f6829d679e15257cb96f46e73d0ad748996a 100755 (executable)
@@ -89,7 +89,7 @@ function sqimap_message_list_squisher($messages_array) {
 }   
 
 function sqimap_get_small_header_list ($imap_stream, $msg_list, $issent) {
-    global $squirrelmail_language, $color;
+    global $squirrelmail_language, $color, $data_dir, $username;
 
     /* Get the small headers for each message in $msg_list */
     $sid = sqimap_session_id();
@@ -205,7 +205,8 @@ function sqimap_get_small_header_list ($imap_stream, $msg_list, $issent) {
                 }
             }
         }
-        if (trim($date) == "") {
+       $internaldate = getPref($data_dir, $username, 'internal_date_sort');
+        if (trim($date) == "" || $internaldate) {
             fputs($imap_stream, "$sid FETCH $msg_list[$msgi] INTERNALDATE\r\n");
             $readdate = sqimap_read_data($imap_stream, $sid, true, $response, $message);
             if (eregi(".*INTERNALDATE \"(.*)\".*", $readdate[0], $regs)) {
@@ -298,6 +299,18 @@ function sqimap_get_message_header ($imap_stream, $id, $mailbox) {
     return $header;
 }
 
+/****************************************************************************
+ **  Wrapper function that reformats the entity header information.
+ ****************************************************************************/
+function sqimap_get_ent_header ($imap_stream, $id, $mailbox, $ent) {
+    $read = sqimap_run_command ($imap_stream, "FETCH $id:$id BODY[$ent.HEADER]", true, $response, $message);
+    $header = sqimap_get_header($imap_stream, $read); 
+    $header->id = $id;
+    $header->mailbox = $mailbox;
+    return $header;
+}
+
+
 /****************************************************************************
  **  Wrapper function that returns entity headers for use by decodeMime
  ****************************************************************************/