X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=functions%2Fimap_mailbox.php;h=422638ed3193150b8a06adb94ac9cfce9ade72ad;hb=5218b2823717b3d99bfbe440df933ff1795203e9;hp=f9819a3347b75579ad249ce00ea9edf95666acb5;hpb=1590a66843027b306e82bc819b224fb5ff2a401c;p=squirrelmail.git diff --git a/functions/imap_mailbox.php b/functions/imap_mailbox.php index f9819a33..422638ed 100755 --- a/functions/imap_mailbox.php +++ b/functions/imap_mailbox.php @@ -12,6 +12,7 @@ sqimap_mailbox_select ($imap_stream, $mailbox); fputs ($imap_stream, "a001 EXPUNGE\r\n"); $read = sqimap_read_data($imap_stream, "a001", true, $response, $message); + sqimap_mailbox_close ($imap_stream); } @@ -19,23 +20,39 @@ ** Checks whether or not the specified mailbox exists ******************************************************************************/ function sqimap_mailbox_exists ($imap_stream, $mailbox) { - $boxes = sqimap_mailbox_list ($imap_stream); - $found = false; - for ($i = 0; $i < count ($boxes); $i++) { - if ($boxes[$i]["unformatted"] == $mailbox) - $found = true; + fputs ($imap_stream, "a001 LIST \"\" \"$mailbox\"\r\n"); + $mbx = sqimap_read_data($imap_stream, "a001", true, $response, $message); + if ($mailbox) { + if (ereg ("$mailbox", $mbx[0])) { + return true; + } else { + return false; + } } - return $found; } + /****************************************************************************** + ** Closes an open mailbox + ******************************************************************************/ + function sqimap_mailbox_close ($imap_stream) { + fputs ($imap_stream, "a001 CLOSE\r\n"); + $tmp = sqimap_read_data($imap_stream, "a001", false, $response, $message); + } - /****************************************************************************** ** Selects a mailbox ******************************************************************************/ - function sqimap_mailbox_select ($imap_stream, $mailbox) { + function sqimap_mailbox_select ($imap_stream, $mailbox, $hide=true, $recent=false) { fputs ($imap_stream, "a001 SELECT \"$mailbox\"\r\n"); - $read = sqimap_read_data($imap_stream, "a001", true, $response, $message); + $read = sqimap_read_data($imap_stream, "a001", true, $response, $message); + if ($recent) { + for ($i=0; $i= 0 ; $i--) { + if (($boxes[$i]["unformatted"] == $trash_folder) && ($move_to_trash)) { + $pos = count($boxesnew); + $boxesnew[$pos] = $boxes[$i]; + $boxes[$i]["used"] = true; + $trash_found = true; + } + else if (($boxes[$i]["unformatted"] == $sent_folder) && ($move_to_sent)) { + $pos = count($boxesnew); + $boxesnew[$pos] = $boxes[$i]; + $boxes[$i]["used"] = true; + $sent_found = true; } + + if (($sent_found && $trash_found) || ($sent_found && !$move_to_trash) || ($trash_found && !$move_to_sent) || (!$move_to_sent && !$move_to_trash)) + $i = -1; } } - + for ($i = 0; $i < count($boxes); $i++) { - if (($boxes[$i]["unformatted"] != $special_folders[0]) && + if ((strtolower($boxes[$i]["unformatted"]) != "inbox") && ($boxes[$i]["used"] == false)) { $pos = count($boxesnew); $boxesnew[$pos] = $boxes[$i]; @@ -248,13 +241,12 @@ return $boxesnew; } - */ /****************************************************************************** ** Returns a list of all folders, subscribed or not ******************************************************************************/ function sqimap_mailbox_list_all ($imap_stream) { - global $special_folders, $list_special_folders_first, $folder_prefix; + global $list_special_folders_first, $folder_prefix; if (!function_exists ("ary_sort")) include ("../functions/array.php"); @@ -298,7 +290,9 @@ } $g++; } - $boxes = ary_sort ($boxes, "unformatted", 1); + if ($boxes) { + $boxes = ary_sort ($boxes, "unformatted", 1); + } return $boxes; }