فهرست منبع

fix E_ALL warnings when server/thread sorting not supported

jmunro 23 سال پیش
والد
کامیت
b9fecdce5d
3فایلهای تغییر یافته به همراه20 افزوده شده و 6 حذف شده
  1. 8 4
      functions/imap_messages.php
  2. 4 2
      functions/mailbox_display.php
  3. 8 0
      src/read_body.php

+ 8 - 4
functions/imap_messages.php

@@ -130,8 +130,10 @@ function sqimap_get_sort_order ($imap_stream, $sort) {
         fputs($imap_stream, $sort_query);
         $sort_test = sqimap_read_data($imap_stream, $sid, false, $response, $message);
     }
-    if (preg_match("/^\* SORT (.+)$/", $sort_test[0], $regs)) {
-        $server_sort_array = preg_split("/ /", trim($regs[1]));
+    if (isset($sort_test[0])) {
+        if (preg_match("/^\* SORT (.+)$/", $sort_test[0], $regs)) {
+            $server_sort_array = preg_split("/ /", trim($regs[1]));
+        }
     }
     if ($sort == 0 || $sort == 2 || $sort == 4) {
        $server_sort_array = array_reverse($server_sort_array);
@@ -256,8 +258,10 @@ function get_thread_sort ($imap_stream) {
     $thread_query = "$sid THREAD $sort_type ".strtoupper($default_charset)." ALL\r\n";
     fputs($imap_stream, $thread_query);
     $thread_test = sqimap_read_data($imap_stream, $sid, false, $response, $message);
-    if (preg_match("/^\* THREAD (.+)$/", $thread_test[0], $regs)) {
-       $thread_list = trim($regs[1]);
+    if (isset($thread_test[0])) {
+        if (preg_match("/^\* THREAD (.+)$/", $thread_test[0], $regs)) {
+            $thread_list = trim($regs[1]);
+        }
     }
     else {
        $thread_list = "";

+ 4 - 2
functions/mailbox_display.php

@@ -161,8 +161,10 @@ function printMessageInfo($imapConnection, $t, $i, $key, $mailbox, $sort,
       case 4: /* subject */
 	echo "   <td bgcolor=\"$hlt_color\">$bold";
 	if ($thread_sort_messages == 1) {
-	  echo str_repeat("&nbsp;&nbsp;&nbsp;&nbsp;",$indent_array[$msg["ID"]]);
-	}
+      if (isset($indent_array[$msg["ID"]])) {
+	    echo str_repeat("&nbsp;&nbsp;&nbsp;&nbsp;",$indent_array[$msg["ID"]]);
+	  }
+    }
 	echo "<a href=\"read_body.php?mailbox=$urlMailbox&amp;passed_id="
 	  . $msg["ID"] 
 	  . "&amp;startMessage=$start_msg&amp;show_more=0$search_stuff\"";

+ 8 - 0
src/read_body.php

@@ -30,6 +30,10 @@ function findNextMessage() {
     global $msort, $currentArrayIndex, $msgs, $sort, 
            $thread_sort_messages, $allow_server_sort,
            $server_sort_array;
+    if (!is_array($server_sort_array)) {
+        $thread_sort_messages = 0;
+        $allow_server_sort = 'false';
+    }
     $result = -1;
     if ($thread_sort_messages == 1 || $allow_server_sort == 'true') {
         reset($server_sort_array);
@@ -89,6 +93,10 @@ function findPreviousMessage() {
            $mailbox, $data_dir, $username, $thread_sort_messages,
            $allow_server_sort, $server_sort_array;
     $result = -1;
+    if (!is_array($server_sort_array)) {
+        $thread_sort_messages = 0;
+        $allow_server_sort = 'false';
+    }
     if ($thread_sort_messages == 1 || $allow_server_sort == 'true') {
         reset($server_sort_array);
         while(list($key, $value) = each ($server_sort_array)) {