X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=functions%2Fimap_mailbox.php;h=422638ed3193150b8a06adb94ac9cfce9ade72ad;hb=5218b2823717b3d99bfbe440df933ff1795203e9;hp=8a06f551afc2806e52ec0f06481f39151bedb69e;hpb=3cb866d7f2515015665c17d633d052af9c75b96e;p=squirrelmail.git diff --git a/functions/imap_mailbox.php b/functions/imap_mailbox.php index 8a06f551..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, $hide) { + 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); + if ($recent) { + for ($i=0; $i"; - } - } - ****/ } return $boxes; } @@ -166,10 +163,9 @@ $inbox_subscribed = false; fputs ($imap_stream, "a001 LSUB \"\" \"*\"\r\n"); $lsub_ary = sqimap_read_data ($imap_stream, "a001", true, $response, $message); + for ($i=0;$i < count($lsub_ary); $i++) { $sorted_lsub_ary[$i] = find_mailbox_name($lsub_ary[$i]); - if (substr($sorted_lsub_ary[$i], -1) == $dm) - $sorted_lsub_ary[$i] = substr($sorted_lsub_ary[$i], 0, strlen($sorted_lsub_ary[$i])-1); if ($sorted_lsub_ary[$i] == "INBOX") $inbox_subscribed = true; } @@ -195,10 +191,15 @@ if ($inbox_subscribed == false || $inbox_in_list == false) { fputs ($imap_stream, "a001 LIST \"\" \"INBOX\"\r\n"); $inbox_ary = sqimap_read_data ($imap_stream, "a001", true, $response, $message); - $sorted_list_ary[count($sorted_list_ary)] = $inbox_ary[0]; + + $pos = count($sorted_list_ary); + $sorted_list_ary[$pos] = $inbox_ary[0]; + + $pos = count($sorted_lsub_ary); + $sorted_lsub_ary[$pos] = find_mailbox_name($inbox_ary[0]); } - $boxes = sqimap_mailbox_parse ($sorted_list_ary, $dm); + $boxes = sqimap_mailbox_parse ($sorted_list_ary, $sorted_lsub_ary, $dm); /** Now, lets sort for special folders **/ for ($i = 0; $i < count($boxes); $i++) { @@ -289,7 +290,9 @@ } $g++; } - $boxes = ary_sort ($boxes, "unformatted", 1); + if ($boxes) { + $boxes = ary_sort ($boxes, "unformatted", 1); + } return $boxes; }