diff options
author | alecpl <alec@alec.pl> | 2008-05-30 10:35:19 +0000 |
---|---|---|
committer | alecpl <alec@alec.pl> | 2008-05-30 10:35:19 +0000 |
commit | 681a59fa52b2996d8e8fa8c2d36eee1d1e70d938 (patch) | |
tree | 505162e3adf908f9cf3335831afb70d51a97e7c9 /program/include/rcube_imap.php | |
parent | 45f56c1c400ad5b21ddcd4d490f6f6c4ffe0d9fc (diff) |
- Support for subfolders in default/protected folders (#1484665)
Diffstat (limited to 'program/include/rcube_imap.php')
-rw-r--r-- | program/include/rcube_imap.php | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/program/include/rcube_imap.php b/program/include/rcube_imap.php index 12cce6e2e..ee2eafe6f 100644 --- a/program/include/rcube_imap.php +++ b/program/include/rcube_imap.php @@ -2489,10 +2489,12 @@ class rcube_imap */ function _sort_mailbox_list($a_folders) { - $a_out = $a_defaults = array(); + $a_out = $a_defaults = $folders = $subfolders = array(); + + $delimiter = $this->get_hierarchy_delimiter(); // find default folders and skip folders starting with '.' - foreach($a_folders as $i => $folder) + foreach ($a_folders as $i => $folder) { if ($folder{0}=='.') continue; @@ -2500,15 +2502,31 @@ class rcube_imap if (($p = array_search(strtolower($folder), $this->default_folders_lc)) !== false && !$a_defaults[$p]) $a_defaults[$p] = $folder; else - { - $l_folders[$folder] = mb_strtolower(rcube_charset_convert($folder, 'UTF-7')); - } + $folders[$folder] = mb_strtolower(rcube_charset_convert($folder, 'UTF-7')); } - asort($l_folders, SORT_LOCALE_STRING); + asort($folders, SORT_LOCALE_STRING); ksort($a_defaults); - return array_merge($a_defaults, array_keys($l_folders)); + $folders = array_merge($a_defaults, array_keys($folders)); + + // finally we must rebuild the list to move + // subfolders of default folders to their place + while (list($key, $folder) = each($folders)) { + $a_out[] = $folder; + unset($folders[$key]); + if (in_array(strtolower($folder), $this->default_folders_lc)) { + foreach ($folders as $idx => $f) { + if (strpos($f, $folder.$delimiter) === 0) { + $a_out[] = $f; + unset($folders[$idx]); + } + } + reset($folders); + } + } + + return $a_out; } /** |