fix orphaned subfolders on the folder list when they are subfolders of a special...
[squirrelmail.git] / functions / imap_mailbox.php
index 6c4d916e5cc087d5f6af4cd510feaf7c6480a1db..351993c91c5421c6068abb9a13a754147fb8b5e3 100755 (executable)
@@ -338,7 +338,7 @@ function user_strcasecmp($a, $b) {
  * See comment on sqimap_mailbox_parse() for info about the returned array.
  */
 function sqimap_mailbox_list($imap_stream) {
-    global $boxesnew;
+    global $boxesnew, $default_folder_prefix;
 
     if ( !isset( $boxesnew ) ) {
 
@@ -460,7 +460,6 @@ function sqimap_mailbox_list($imap_stream) {
                 $used[$k] = false;
             }
         }
-
         /* List special folders and their subfolders, if requested. */
         if ($list_special_folders_first) {
             foreach ( $boxesall as $k => $box ) {
@@ -468,6 +467,10 @@ function sqimap_mailbox_list($imap_stream) {
                     $boxesnew[] = $box;
                     $used[$k] = true;
                 }
+                if (!$used[$k] && preg_match("/$default_folder_prefix(Sent|Drafts|Trash)/", $box['unformatted']) ) {
+                    $boxesnew[] = $box;
+                    $used[$k] = true;
+                }
             }
 
         }
@@ -479,7 +482,6 @@ function sqimap_mailbox_list($imap_stream) {
             }
         }
     }
-
     return $boxesnew;
 }