X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=functions%2Fimap_mailbox.php;h=de9ce022e9ec81c35bb612a5164a668777c6617b;hp=963f7d43faea7831e12f2201c3305cf068e4835f;hb=f9b3e5d9902a047bfa8995c1d795cae2226a857a;hpb=0ad7dbda6b8c49dcc2de6d52fc27ff26c915a674 diff --git a/functions/imap_mailbox.php b/functions/imap_mailbox.php index 963f7d43..de9ce022 100755 --- a/functions/imap_mailbox.php +++ b/functions/imap_mailbox.php @@ -1,4 +1,4 @@ -= 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 ((strtolower($boxes[$i]["unformatted"]) != "inbox") && + ($boxes[$i]["used"] == false)) { + $pos = count($boxesnew); + $boxesnew[$pos] = $boxes[$i]; + $boxes[$i]["used"] = true; + } + } + + return $boxesnew; + } + + /****************************************************************************** + ** Returns a list of all folders, subscribed or not + ******************************************************************************/ + function sqimap_mailbox_list_all ($imap_stream) { + global $list_special_folders_first, $folder_prefix; if (!function_exists ("ary_sort")) include ("../functions/array.php"); $dm = sqimap_get_delimiter ($imap_stream); - fputs ($imap_stream, "a001 LIST \"\" INBOX\r\n"); + fputs ($imap_stream, "a001 LIST \"$folder_prefix\" *\r\n"); $read_ary = sqimap_read_data ($imap_stream, "a001", true, $response, $message); $g = 0; $phase = "inbox"; @@ -137,66 +301,11 @@ } } $g++; - - if (!$read_ary[$i+1]) { - if ($phase == "inbox") { - fputs ($imap_stream, "a001 LSUB \"\" *\r\n"); - $read_ary = sqimap_read_data ($imap_stream, "a001", true, $response, $message); - $phase = "lsub"; - $i--; - } - } - } - - $original = $boxes; - - /** Get the folders into lower case so sorting is not case sensative */ - for ($i = 0; $i < count($original); $i++) { - $boxes[$i]["unformatted"] = strtolower($boxes[$i]["unformatted"]); - } - - /** Sort them **/ - $boxes = ary_sort($boxes, "unformatted", 1); - - /** Get them back from the original array, still sorted by the id **/ - for ($i = 0; $i < count($boxes); $i++) { - for ($j = 0; $j < count($original); $j++) { - if ($boxes[$i]["id"] == $original[$j]["id"]) { - $boxes[$i] = $original[$j]; - } - } - } - - - for ($i = 0; $i < count($boxes); $i++) { - if ($boxes[$i]["unformatted"] == $special_folders[0]) { - $boxesnew[0] = $boxes[$i]; - $boxes[$i]["used"] = true; - } } - - if ($list_special_folders_first == true) { - for ($i = 0; $i < count($boxes); $i++) { - for ($j = 1; $j < count($special_folders); $j++) { - if (substr($boxes[$i]["unformatted"], 0, strlen($special_folders[$j])) == $special_folders[$j]) { - $pos = count($boxesnew); - $boxesnew[$pos] = $boxes[$i]; - $boxes[$i]["used"] = true; - } - } - } + if ($boxes) { + $boxes = ary_sort ($boxes, "unformatted", 1); } - - for ($i = 0; $i < count($boxes); $i++) { - if (($boxes[$i]["unformatted"] != $special_folders[0]) && - ($boxes[$i]["used"] == false)) { - $pos = count($boxesnew); - $boxesnew[$pos] = $boxes[$i]; - $boxes[$i]["used"] = true; - } - } - - return $boxesnew; + return $boxes; } ?>