From 52ed2f8826e0497d4683280183feb98f805a78e4 Mon Sep 17 00:00:00 2001 From: robsiemb Date: Mon, 22 Jul 2002 18:37:39 +0000 Subject: [PATCH] add $no_list_for_subscribe configure option to turn off generation of the list of available folders in the subscription dialog git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@3117 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- config/conf.pl | 3 ++- config/config_default.php | 8 ++++++++ src/folders.php | 34 ++++++++++++++++++++++++---------- src/folders_subscribe.php | 21 ++++++++++++++++++--- 4 files changed, 52 insertions(+), 14 deletions(-) diff --git a/config/conf.pl b/config/conf.pl index 70628b24..9554acb5 100755 --- a/config/conf.pl +++ b/config/conf.pl @@ -2407,7 +2407,6 @@ sub save_data { print CF "\$allow_charset_search = $allow_charset_search;\n"; # boolean print CF "\$uid_support = $uid_support;\n"; - # boolean print CF "\n"; # all plugins are strings @@ -2475,6 +2474,8 @@ sub save_data { print CF "\$prefs_key_field = '$prefs_key_field';\n"; # string print CF "\$prefs_val_field = '$prefs_val_field';\n"; + # boolean + print CF "\$no_list_for_subscribe = $no_list_for_subscribe;\n"; print CF "\n"; print CF "/**\n"; diff --git a/config/config_default.php b/config/config_default.php index 656c9ddf..a5ae959a 100644 --- a/config/config_default.php +++ b/config/config_default.php @@ -500,6 +500,14 @@ $allow_server_sort = false; global $noselect_fix_enable; $noselect_fix_enable = false; +/** + * this disables listing all of the folders on the IMAP Server to + * generate the folder subscribe listbox (this can take a long time + * when you have a lot of folders). Instead, a textbox will be + * displayed allowing users to enter a specific folder name to subscribe to */ +global $no_list_for_subscribe; +$no_list_for_subscribe = false; + /** * Make sure there are no characters after the PHP closing * tag below (including newline characters and whitespace). diff --git a/src/folders.php b/src/folders.php index c9d2540f..3f4936df 100644 --- a/src/folders.php +++ b/src/folders.php @@ -43,6 +43,10 @@ if ((isset($success) && $success) || $td_str = "" . _("Created folder successfully!") . "
"; } else if ($success == "rename") { $td_str = "" . _("Renamed successfully!") . "
"; + } else if ($success == "subscribe-doesnotexist") { + $td_str = "" . + _("Subscription Unsuccessful - Folder does not exist.") . + "
"; } echo html_tag( 'table', @@ -252,12 +256,14 @@ $boxes_sub = $boxes; /** SUBSCRIBE TO FOLDERS **/ echo html_tag( 'td', '', 'center', $color[0], 'width="50%"' ); -$imap_stream = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 1); -$boxes_all = sqimap_mailbox_list_all ($imap_stream); - -$box = ""; -$box2 = ""; -for ($i = 0, $q = 0; $i < count($boxes_all); $i++) { +if(!$no_list_for_subscribe) { + $imap_stream = sqimap_login ($username, $key, $imapServerAddress, + $imapPort, 1); + $boxes_all = sqimap_mailbox_list_all ($imap_stream); + + $box = ""; + $box2 = ""; + for ($i = 0, $q = 0; $i < count($boxes_all); $i++) { $use_folder = true; for ($p = 0; $p < count ($boxes); $p++) { if ($boxes_all[$i]["unformatted"] == $boxes[$p]["unformatted"]) { @@ -272,10 +278,10 @@ for ($i = 0, $q = 0; $i < count($boxes_all); $i++) { $box2[$q] = imap_utf7_decode_local($boxes_all[$i]["unformatted-disp"]); $q++; } -} -sqimap_logout($imap_stream); + } + sqimap_logout($imap_stream); -if ($box && $box2) { + if ($box && $box2) { echo "
\n"; echo "

"; echo "\n"; echo "

\n"; -} else { + } else { echo _("No folders were found to subscribe to!") . ""; + } +} else { + /* don't perform the list action -- this is much faster */ + echo "
\n"; + echo _("Subscribe to:") . "
"; + echo ""; + echo "\n"; + echo "
\n"; } do_hook("folders_bottom"); diff --git a/src/folders_subscribe.php b/src/folders_subscribe.php index a887fde6..ae7eb179 100644 --- a/src/folders_subscribe.php +++ b/src/folders_subscribe.php @@ -19,7 +19,25 @@ require_once('../functions/display_messages.php'); $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); $location = get_location(); + +if (!isset($mailbox) || !isset($mailbox[0]) || $mailbox[0] == "") { + header("Location: $location/folders.php"); + sqimap_logout($imapConnection); + exit(0); +} + if ($method == 'sub') { + if($no_list_for_subscribe && $imap_server_type == 'cyrus') { + /* Cyrus, atleast, does not typically allow subscription to + * nonexistent folders (this is an optional part of IMAP), + * lets catch it here and report back cleanly. */ + if(!sqimap_mailbox_exists($imapConnection, $mailbox[0])) { + header("Location: $location/folders.php?success=subscribe-doesnotexist"); + sqimap_logout($imapConnection); + exit(0); + } + } + for ($i=0; $i < count($mailbox); $i++) { $mailbox[$i] = trim($mailbox[$i]); sqimap_subscribe ($imapConnection, $mailbox[$i]); @@ -32,9 +50,6 @@ if ($method == 'sub') { header("Location: $location/folders.php?success=unsubscribe"); } } -if (!isset($mailbox)) { - header("Location: $location/folders.php"); -} sqimap_logout($imapConnection); /* -- 2.25.1