From 20b51df26d16620d02fa1f5095adadee59319b1b Mon Sep 17 00:00:00 2001 From: Erin Schnabel Date: Thu, 1 May 2003 04:56:50 +0000 Subject: [PATCH] UW Folder badness take two. --- functions/imap_mailbox.php | 18 +++++++++--------- src/folders.php | 16 +++++++++++----- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/functions/imap_mailbox.php b/functions/imap_mailbox.php index a2580f4b5..2bb6468b9 100755 --- a/functions/imap_mailbox.php +++ b/functions/imap_mailbox.php @@ -419,9 +419,14 @@ function user_strcasecmp($a, $b) { * $folder_skip - array of folders to keep out of option list (compared in lower) * $boxes - list of already fetched boxes (for places like folder panel, where * you know these options will be shown 3 times in a row.. (most often unset). - * $parent - used to indicate whether or not listed boxes can be parents + * $flag - flag to check for in mailbox flags, used to filter out mailboxes. + * 'noselect' by default to remove unselectable mailboxes. + * 'noinferiors' used to filter out folders that can not contain subfolders. + * NULL to avoid flag check entirely. + * $use_long_format - override folder display preference and always show full folder name. */ -function sqimap_mailbox_option_list($imap_stream, $show_selected = 0, $folder_skip = 0, $boxes = 0, $parent = false, $use_long_format = false ) { +function sqimap_mailbox_option_list($imap_stream, $show_selected = 0, $folder_skip = 0, $boxes = 0, + $flag = 'noselect', $use_long_format = false ) { global $username, $data_dir; $mbox_options = ''; @@ -434,14 +439,9 @@ function sqimap_mailbox_option_list($imap_stream, $show_selected = 0, $folder_sk if ($boxes == 0) { $boxes = sqimap_mailbox_list($imap_stream); } - if ($parent) { - $flag = 'noinferiors'; - } - else { - $flag = 'noselect'; - } + foreach ($boxes as $boxes_part) { - if (!in_array($flag, $boxes_part['flags'])) { + if ($flag == NULL || !in_array($flag, $boxes_part['flags'])) { $box = $boxes_part['unformatted']; $lowerbox = strtolower($box); diff --git a/src/folders.php b/src/folders.php index 6b436539e..2fe3a7130 100644 --- a/src/folders.php +++ b/src/folders.php @@ -120,9 +120,9 @@ if ( $default_sub_of_inbox == false ) { // Call sqimap_mailbox_option_list, using existing connection to IMAP server, // the arrays of folders to include or skip (assembled above), -// and indicate that folders listed should be parents (we're creating folders, -// so we want to list the folders that can contain other folders), also force long form -echo sqimap_mailbox_option_list($imapConnection, $show_selected, $skip_folders, $boxes, true, true); +// use 'noinferiors' as a mailbox filter to leave out folders that can not contain other folders. +// use the long format to show subfolders in an intelligible way if parent is missing (special folder) +echo sqimap_mailbox_option_list($imapConnection, $show_selected, $skip_folders, $boxes, 'noinferiors', true); echo "\n"; if ($show_contain_subfolders_option) { @@ -183,7 +183,11 @@ if ($count_special_folders < count($boxes)) { . "\n". "\n" . '