Fixed the issue where inbox showed up in the lsub response with a \NoSelect
authorstekkel <stekkel@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Thu, 26 Feb 2004 18:01:59 +0000 (18:01 +0000)
committerstekkel <stekkel@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Thu, 26 Feb 2004 18:01:59 +0000 (18:01 +0000)
flag. If we detect inbox with \NoSelect we unset the result for inbox and do
a list request for inbox.

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

functions/imap_mailbox.php

index 54577b8e23d159aa219036478793a4b711ee8894..a5a6277c7c6a2b28f3d18e021c3e27bcac0af244 100755 (executable)
@@ -814,13 +814,29 @@ function sqimap_mailbox_tree($imap_stream) {
         for ($i = 0, $cnt = count($lsub_ary); $i < $cnt; $i++) {
             if (preg_match("/^\*\s+LSUB.*\s\"?INBOX\"?[^(\/\.)].*$/i",$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;
             }
         }
 
         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];
+            }
         }
 
         /*