From 37578167cf36077ca8bcb395191bd96a069046a7 Mon Sep 17 00:00:00 2001 From: lkehresman Date: Sat, 25 Mar 2000 00:07:06 +0000 Subject: [PATCH] Added unsubscribe/subscribe to folders git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@339 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- TODO | 6 ++-- functions/imap_mailbox.php | 53 ++++++++++++++++++++++++++++ src/folders.php | 72 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 128 insertions(+), 3 deletions(-) diff --git a/TODO b/TODO index 146b674a..28bf0bbe 100644 --- a/TODO +++ b/TODO @@ -15,12 +15,12 @@ initials = taken by that person - Better inline HTML support including graphics (content-disposition) - Maybe a rewrite of mime.php (see Gustav before any work is done) - Better handling emptying Trash folder. Some servers don't allow deleting it (Courier) -(lme) Fix "Seen" bug with UW IMAP server - - Add "subscribe" to folders section. +(lme) Add "subscribe" to folders section. - Make Location redirects absolute rather than relative (index.php) - POP suport (maybe) Finished: ------------------------------------------------------ - (lme) Saving sent messages +(lme) Saving sent messages +(lme) Fix "Seen" bug with UW IMAP server diff --git a/functions/imap_mailbox.php b/functions/imap_mailbox.php index 963f7d43..8d2dc88c 100755 --- a/functions/imap_mailbox.php +++ b/functions/imap_mailbox.php @@ -198,5 +198,58 @@ 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; + + if (!function_exists ("ary_sort")) + include ("../functions/array.php"); + + $dm = sqimap_get_delimiter ($imap_stream); + + fputs ($imap_stream, "a001 LIST \"\" *\r\n"); + $read_ary = sqimap_read_data ($imap_stream, "a001", true, $response, $message); + $g = 0; + $phase = "inbox"; + for ($i = 0; $i < count($read_ary); $i++) { + if (substr ($read_ary[$i], 0, 4) != "a001") { + $boxes[$g]["raw"] = $read_ary[$i]; + + $mailbox = find_mailbox_name($read_ary[$i]); + $dm_count = countCharInString($mailbox, $dm); + if (substr($mailbox, -1) == $dm) + $dm_count--; + + for ($j = 0; $j < $dm_count; $j++) + $boxes[$g]["formatted"] = $boxes[$g]["formatted"] . " "; + $boxes[$g]["formatted"] .= readShortMailboxName($mailbox, $dm); + + $boxes[$g]["unformatted-dm"] = $mailbox; + if (substr($mailbox, -1) == $dm) + $mailbox = substr($mailbox, 0, strlen($mailbox) - 1); + $boxes[$g]["unformatted"] = $mailbox; + $boxes[$g]["id"] = $g; + + /** Now lets get the flags for this mailbox **/ + 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); + $flags = substr($flags, 0, strpos($flags, ")")); + $flags = str_replace("\\", "", $flags); + $flags = trim(strtolower($flags)); + if ($flags) { + $boxes[$g]["flags"] = explode(" ", $flags); + } + } + $g++; + } + $boxes = ary_sort ($boxes, "unformatted", 1); + return $boxes; + } ?> diff --git a/src/folders.php b/src/folders.php index 861ddf09..069857b5 100644 --- a/src/folders.php +++ b/src/folders.php @@ -146,6 +146,78 @@ echo "\n"; + echo "\n"; + } else { + echo _("No mailboxes found") . "

"; + } + $boxes_sub = $boxes; + + /** UNSUBSCRIBE FOLDERS **/ + echo ""; + echo _("Unsubscribe/Subscribe"); + echo ""; + echo ""; + if ($count_special_folders < count($boxes)) { + echo "
\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + } else { + echo _("No mailboxes found") . "

"; + } + $boxes_sub = $boxes; + + /** SUBSCRIBE TO FOLDERS **/ + + echo ""; + if ($count_special_folders < count($boxes)) { + $imap_stream = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 1); + $boxes = sqimap_mailbox_list_all ($imap_stream); + + echo "
\n"; + echo "\n"; + echo "\n"; echo "

\n"; } else { echo _("No mailboxes found") . "

"; -- 2.25.1