E_ALL notice removal
[squirrelmail.git] / functions / imap_mailbox.php
index 3a17cd662d3a75b79c8693fddd8401b86c31bf5b..a968dc19a7624bb65c6ec51236a3325323a5d0c3 100755 (executable)
@@ -419,25 +419,29 @@ 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) {
+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 = '';
 
-    $shorten_box_names = getPref($data_dir, $username, 'mailbox_select_style', SMPREF_OFF);
+    if ( $use_long_format ) {
+        $shorten_box_names = 0;
+    } else {
+        $shorten_box_names = getPref($data_dir, $username, 'mailbox_select_style', SMPREF_OFF);
+    }
 
     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);
 
@@ -795,7 +799,7 @@ function sqimap_mailbox_tree($imap_stream) {
             if (($unseen_notify == 2 && $mbx == 'INBOX') ||
                 ($unseen_notify == 3) ||
                 ($move_to_trash && ($mbx == $trash_folder))) {
-                if($sorted_lsub_ary[$i]['noselect']) {
+                if(isset($sorted_lsub_ary[$i]['noselect']) && $sorted_lsub_ary[$i]['noselect']) {
                     $sorted_lsub_ary[$i]['unseen'] = 0;
                 } else {
                     $sorted_lsub_ary[$i]['unseen'] =