/* Checks whether or not the specified mailbox exists */
function sqimap_mailbox_exists ($imap_stream, $mailbox) {
- if (!isset($mailbox)) {
+ if (!isset($mailbox) || empty($mailbox)) {
return false;
}
$mbx = sqimap_run_command($imap_stream, "LIST \"\" \"$mailbox\"",
* $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).
+ * $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 ) {
+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);
}
+
foreach ($boxes as $boxes_part) {
- if (!in_array('noselect', $boxes_part['flags'])) {
+ if ($flag == NULL || !in_array($flag, $boxes_part['flags'])) {
$box = $boxes_part['unformatted'];
$lowerbox = strtolower($box);
$inbox_ary = sqimap_run_command ($imap_stream, "LIST \"\" \"INBOX\"",
true, $response, $message);
/* Another workaround for literals */
- if (isset($inbox_ary[1]) && substr($inbox_ary[$i],-3) == "}\r\n") {
+ if (isset($inbox_ary[1]) && substr($inbox_ary[0],-3) == "}\r\n") {
if (ereg("^(\\* [A-Z]+.*)\\{[0-9]+\\}([ \n\r\t]*)$",
$inbox_ary[0], $regs)) {
$inbox_ary[0] = $regs[1] . '"' . addslashes(trim($inbox_ary[1])) .