Quellcode durchsuchen

Fixed the issue where inbox showed up in the lsub response with a \NoSelect
flag. If we detect inbox with \NoSelect we unset the result for inbox and do
a list request for inbox.

stekkel vor 21 Jahren
Ursprung
Commit
c51abba34c
1 geänderte Dateien mit 18 neuen und 2 gelöschten Zeilen
  1. 18 2
      functions/imap_mailbox.php

+ 18 - 2
functions/imap_mailbox.php

@@ -814,13 +814,29 @@ function sqimap_mailbox_tree($imap_stream) {
         for ($i = 0, $cnt = count($lsub_ary); $i < $cnt; $i++) {
         for ($i = 0, $cnt = count($lsub_ary); $i < $cnt; $i++) {
             if (preg_match("/^\*\s+LSUB.*\s\"?INBOX\"?[^(\/\.)].*$/i",$lsub_ary[$i])) {
             if (preg_match("/^\*\s+LSUB.*\s\"?INBOX\"?[^(\/\.)].*$/i",$lsub_ary[$i])) {
 	        $lsub_ary[$i] = strtoupper($lsub_ary[$i]);
 	        $lsub_ary[$i] = strtoupper($lsub_ary[$i]);
-                $has_inbox = true;
+                // in case of an unsubscribed inbox an imap server can
+                // return the inbox in the lsub results with a \NoSelect 
+                // flag.
+                if (!preg_match("/\*\s+LSUB\s+\(.*\\\\NoSelect.*\).*/i",$lsub_ary[$i])) {
+                    $has_inbox = true;
+                } else {
+                    // remove the result and request it again  with a list
+                    // response at a later stage.
+                    unset($lsub_ary[$i]);
+                }
                 break;
                 break;
             }
             }
         }
         }
 
 
         if ($has_inbox == false) {
         if ($has_inbox == false) {
-            $lsub_ary[] = '* LSUB () NIL INBOX';
+            // do a list request for inbox because we should always show
+            // inbox even if the user isn't subscribed to it.
+            $inbox_ary = sqimap_run_command ($imap_stream, 'LIST "" INBOX',
+                                             true, $response, $message);
+            $inbox_ary = compact_mailboxes_response($inbox_ary);
+            if (count($inbox_ary)) {
+                $lsub_ary[] = $inbox_ary[0];
+            }
         }
         }
 
 
         /*
         /*