From c3ce607ec3a0f1e4f7e8cab7c4f326d9590bae80 Mon Sep 17 00:00:00 2001 From: kink Date: Mon, 4 Apr 2005 19:04:24 +0000 Subject: [PATCH] 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. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@9195 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- ChangeLog | 2 ++ functions/imap_mailbox.php | 25 ++++++++++++++++--------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 278ac313..9fdb2f2c 100644 --- a/ChangeLog +++ b/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 -------------------- diff --git a/functions/imap_mailbox.php b/functions/imap_mailbox.php index 06689618..292ba46b 100755 --- a/functions/imap_mailbox.php +++ b/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]; -- 2.25.1