X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=functions%2Fimap_mailbox.php;h=422638ed3193150b8a06adb94ac9cfce9ade72ad;hb=5218b2823717b3d99bfbe440df933ff1795203e9;hp=c5c8aced064586d7dbc40eedf27296c278092d67;hpb=abddc974c228ad2762c276ad68778dde7cdfeabf;p=squirrelmail.git diff --git a/functions/imap_mailbox.php b/functions/imap_mailbox.php index c5c8aced..422638ed 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\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"; @@ -125,7 +277,7 @@ $boxes[$g]["id"] = $g; /** Now lets get the flags for this mailbox **/ - fputs ($imap_stream, "a002 LIST \"\" \"$mailbox\"\n"); + fputs ($imap_stream, "a002 LIST \"\" \"$mailbox\"\r\n"); $read_mlbx = sqimap_read_data ($imap_stream, "a002", true, $response, $message); $flags = substr($read_mlbx[0], strpos($read_mlbx[0], "(")+1); @@ -137,66 +289,11 @@ } } $g++; - - if (!$read_ary[$i+1]) { - if ($phase == "inbox") { - fputs ($imap_stream, "a001 LSUB \"\" *\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"]); + if ($boxes) { + $boxes = ary_sort ($boxes, "unformatted", 1); } - - /** 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; - } - } - } - } - - 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; } ?>