Browse Source

Fix incorrect folder hierarchy shown. Patch was supplied by Awais Ahmad,
works fine here and is confirmed to work by several other users.
Closes bug #1009654 and patch #1082558.

Thijs Kinkhorst 20 years ago
parent
commit
29cba72f37
2 changed files with 18 additions and 9 deletions
  1. 2 0
      ChangeLog
  2. 16 9
      functions/imap_mailbox.php

+ 2 - 0
ChangeLog

@@ -293,6 +293,8 @@ Version 1.5.1 -- CVS
   - Create a generic function to empty a folder tree, thanks to
     Randy Smith (#1145578).
   - Add robots noindex/nofollow meta tag to SquirrelMail generated pages.
+  - Fix incorrect folder hierarchy display (#1009654), thanks
+    Awais Ahmad for the patch (#1082558).
   
 Version 1.5.0
 --------------------

+ 16 - 9
functions/imap_mailbox.php

@@ -170,14 +170,11 @@ function isBoxBelow( $subbox, $parentbox ) {
       return false;
     }
     /* check for delimiter */
-        if (!substr($parentbox,-1) == $delimiter) {
-            $parentbox.=$delimiter;
-        }
-        if (substr($subbox,0,strlen($parentbox)) == $parentbox) {
-            return true;
-        } else {
-            return false;
-        }
+    if (substr($parentbox,-1) != $delimiter) {
+        $parentbox .= $delimiter;
+    }
+
+    return (substr($subbox,0,strlen($parentbox)) == $parentbox);
 }
 
 /**
@@ -680,7 +677,17 @@ function sqimap_mailbox_list($imap_stream, $force=false) {
                 }
             }
         }
-       /* Rest of the folders */
+
+        /* Find INBOX's children */
+        for($k = 0; $k < $cnt; ++$k) {
+            if (isBoxBelow(strtolower($boxesall[$k]['unformatted']), 'inbox') && 
+            strtolower($boxesall[$k]['unformatted']) <> 'inbox') {
+                $boxesnew[] = $boxesall[$k];
+                $used[$k] = true;
+            }   
+        }
+        
+        /* Rest of the folders */
         for($k = 0; $k < $cnt; $k++) {
             if (!$used[$k]) {
                 $boxesnew[] = $boxesall[$k];