- $dm_count = countCharInString($mailbox, $dm);
- if (substr($mailbox, -1) == $dm)
- $dm_count--;
-
- for ($j = 0; $j < $dm_count - (countCharInString($folder_prefix, $dm)); $j++)
- $boxes[$g]["formatted"] = $boxes[$g]["formatted"] . " ";
- $boxes[$g]["formatted"] .= readShortMailboxName($mailbox, $dm);
+ $dm_count = countCharInString($mailbox, $delimiter);
+ if (substr($mailbox, -1) == $delimiter)
+ $dm_count--; // If name ends in delimiter - decrement count by one
+
+ // Format folder name, but only if it's a INBOX.* or have
+ // a parent.
+ $boxesbyname[$mailbox] = $g;
+ $parentfolder = readMailboxParent($mailbox, $delimiter);
+ if((strtolower(substr($mailbox, 0, 5)) == "inbox") ||
+ (substr($mailbox, 0, strlen($folder_prefix)) == $folder_prefix) ||
+ (isset($boxesbyname[$parentfolder]) && (strlen($parentfolder) > 0) ) ) {
+ $indent = $dm_count - (countCharInString($folder_prefix, $delimiter));
+ if ($indent > 0)
+ $boxes[$g]["formatted"] = str_repeat(" ", $indent);
+ else
+ $boxes[$g]["formatted"] = '';
+ $boxes[$g]["formatted"] .= readShortMailboxName($mailbox, $delimiter);
+ } else {
+ $boxes[$g]["formatted"] = $mailbox;
+ }