From 91f999f6777c170dfa84465f1ccfec69ff06b3a5 Mon Sep 17 00:00:00 2001 From: lkehresman Date: Wed, 9 Feb 2000 12:10:43 +0000 Subject: [PATCH] Fixed some major bugs in getting the folder list. Might fix the problem with the left folder not refreshing. Also made the folder creation and deletion look nicer. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@199 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/imap.php | 26 +++++++++++++++++++------- functions/strings.php | 3 +++ po/squirrelmail.po | 31 ++++++++++++++++++++++++++----- src/folders_create.php | 10 ++++++---- src/folders_delete.php | 14 +++++++++----- src/left_main.php | 19 ++++++------------- 6 files changed, 69 insertions(+), 34 deletions(-) diff --git a/functions/imap.php b/functions/imap.php index 267bce91..88189760 100644 --- a/functions/imap.php +++ b/functions/imap.php @@ -46,13 +46,13 @@ /** Parse the incoming mailbox name and return a string that is the FOLDER.MAILBOX **/ function findMailboxName($mailbox) { $mailbox = trim($mailbox); - if (substr($mailbox, strlen($mailbox)-1, strlen($mailbox)) == "\"") { - $mailbox = substr($mailbox, 0, strlen($mailbox) - 1); - $pos = strrpos($mailbox, "\"") + 1; - $box = substr($mailbox, $pos, strlen($mailbox)); - } else { +// if (substr($mailbox, strlen($mailbox)-1, strlen($mailbox)) == "\"") { +// $mailbox = substr($mailbox, 0, strlen($mailbox) - 1); +// $pos = strrpos($mailbox, "\"") + 1; +// $box = substr($mailbox, $pos, strlen($mailbox)); +// } else { $box = substr($mailbox, strrpos($mailbox, " ")+1, strlen($mailbox)); - } +// } return $box; } @@ -82,7 +82,11 @@ return $read; } - function getMailboxFlags($mailbox) { + function getMailboxFlags($imapConnection, $mailbox) { + $name = findMailboxName($mailbox); + fputs ($imapConnection, "1 LIST \"$name\" *\n"); + $data = imapReadData($imapConnection, "1", true, $response, $message); + $mailbox = $data[0]; $mailbox = trim($mailbox); $mailbox = substr($mailbox, strpos($mailbox, "(")+1, strlen($mailbox)); $mailbox = substr($mailbox, 0, strpos($mailbox, ")")); @@ -170,6 +174,9 @@ } function removeFolder($imapConnection, $folder) { + fputs ($imapConnection, "1 unsubscribe \"$folder\"\n"); + $data = imapReadData($imapConnection, "1", true, $response, $message); + echo $data[0] . "
"; fputs($imapConnection, "1 delete \"$folder\"\n"); $data = imapReadData($imapConnection, "1", false, $response, $message); if ($response == "NO") { @@ -201,6 +208,8 @@ $mailbox = findMailboxName($mailbox); $periodCount = countCharInString($mailbox, $dm); + if (substr($mailbox, -1) == $dm) + $periodCount--; // indent the correct number of spaces. for ($j = 0;$j < $periodCount;$j++) @@ -222,8 +231,11 @@ if (substr(findMailboxName($mailbox), 0, 1) != ".") { $boxes[$g]["RAW"] = $mailbox; + // Get the mailbox name and format it. If there is a $dm at the end of it, remove it. $mailbox = findMailboxName($mailbox); $periodCount = countCharInString($mailbox, $dm); + if (substr($mailbox, -1) == $dm) + $periodCount = $periodCount - 1; // indent the correct number of spaces. for ($j = 0;$j < $periodCount;$j++) diff --git a/functions/strings.php b/functions/strings.php index 5c633d44..11e30f92 100644 --- a/functions/strings.php +++ b/functions/strings.php @@ -17,6 +17,9 @@ // of the $haystack is reached. //************************************************************************* function readShortMailboxName($haystack, $needle) { + if (substr($haystack, -1) == $needle) + $haystack = substr($haystack, 0, strlen($haystack) - 1); + if (strpos($haystack, $needle)) { $pos = strrpos($haystack, $needle) + 1; $data = substr($haystack, $pos, strlen($haystack)); diff --git a/po/squirrelmail.po b/po/squirrelmail.po index 5f2e7448..8b93c988 100644 --- a/po/squirrelmail.po +++ b/po/squirrelmail.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2000-02-08 07:02-0500\n" +"POT-Creation-Date: 2000-02-09 07:13-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -114,7 +114,28 @@ msgid "" msgstr "" #: squirrelmail/src/folders_create.php:35 -#: squirrelmail/src/folders_delete.php:77 +msgid "Folder Created!" +msgstr "" + +#: squirrelmail/src/folders_create.php:36 +#: squirrelmail/src/folders_delete.php:80 +msgid "You will be automatically forwarded." +msgstr "" + +#: squirrelmail/src/folders_create.php:36 +#: squirrelmail/src/folders_delete.php:80 +msgid "If not," +msgstr "" + +#: squirrelmail/src/folders_create.php:36 +#: squirrelmail/src/folders_delete.php:80 +msgid "click here" +msgstr "" + +#: squirrelmail/src/folders_delete.php:79 +msgid "Folder Deleted!" +msgstr "" + #: squirrelmail/src/folders_rename_do.php:67 msgid "Return" msgstr "" @@ -128,7 +149,7 @@ msgid "New name:" msgstr "" #: squirrelmail/src/folders_rename_getname.php:34 -#: squirrelmail/src/options.php:259 +#: squirrelmail/src/options.php:258 msgid "Submit" msgstr "" @@ -196,11 +217,11 @@ msgstr "" msgid " Size of editor window (in characters):" msgstr "" -#: squirrelmail/src/options.php:147 +#: squirrelmail/src/options.php:146 msgid " Time between auto refresh of folder list:" msgstr "" -#: squirrelmail/src/options.php:245 +#: squirrelmail/src/options.php:244 msgid "Use a signature?" msgstr "" diff --git a/src/folders_create.php b/src/folders_create.php index 14ef7636..e668ac2d 100644 --- a/src/folders_create.php +++ b/src/folders_create.php @@ -27,13 +27,15 @@ if (trim($subfolder) == "[ None ]") { createFolder($imapConnection, "$folder_name"); } else { - createFolder($imapConnection, "$subfolder$dm$folder_name"); + createFolder($imapConnection, "$subfolder$folder_name"); } fputs($imapConnection, "1 logout\n"); - echo "

"; - echo _("Return"); - echo ""; + echo ""; + echo "

" . _("Folder Created!") . "

"; + echo _("You will be automatically forwarded.") . "
" . _("If not,") . " " . _("click here") . "."; + echo "
"; + ?> diff --git a/src/folders_delete.php b/src/folders_delete.php index caebfcb2..9b836009 100644 --- a/src/folders_delete.php +++ b/src/folders_delete.php @@ -9,6 +9,8 @@ include("../src/load_prefs.php"); echo "\n"; + displayPageHeader($color, "None"); + $imapConnection = loginToImapServer($username, $key, $imapServerAddress, 0); getFolderList($imapConnection, $boxes); @@ -19,7 +21,7 @@ $tmp_trash_folder = $boxes[$i]["RAW"]; } - $tmpflags = getMailboxFlags($tmp_trash_folder); + $tmpflags = getMailboxFlags($imapConnection, $tmp_trash_folder); $can_move_to_trash = true; for ($i = 0; $i < count($tmpflags); $i++) { if (strtolower($tmpflags[$i]) == "noinferiors") @@ -33,7 +35,7 @@ if (($boxes[$i]["UNFORMATTED"] == $mailbox) || (substr($boxes[$i]["UNFORMATTED"], 0, strlen($mailbox . $dm)) == $mailbox . $dm)) { $folderWithoutINBOX = getFolderNameMinusINBOX($boxes[$i]["UNFORMATTED"], $dm); - $flags = getMailboxFlags($boxes[$i]["RAW"]); + $flags = getMailboxFlags($imapConnection, $boxes[$i]["RAW"]); for ($b = 0; $b < count($flags); $b++) { $type = $flags[$b]; } @@ -73,9 +75,11 @@ /** Log out this session **/ fputs($imapConnection, "1 logout"); - echo "

"; - echo _("Return"); - echo ""; + echo ""; + echo "

" . _("Folder Deleted!") . "

"; + echo _("You will be automatically forwarded.") . "
" . _("If not,") . " " . _("click here") . ""; + echo "
"; + echo ""; ?> diff --git a/src/left_main.php b/src/left_main.php index dfbbb7fc..c9ba3d6a 100644 --- a/src/left_main.php +++ b/src/left_main.php @@ -20,11 +20,11 @@ include("../functions/imap.php"); include("../functions/mailbox.php"); - function formatMailboxName($imapConnection, $mailbox, $delimeter, $color, $move_to_trash) { + function formatMailboxName($imapConnection, $mailbox, $real_box, $delimeter, $color, $move_to_trash) { require ("../config/config.php"); $mailboxURL = urlencode($mailbox); - selectMailbox($imapConnection, $mailbox, $numNessages); + selectMailbox($imapConnection, $real_box, $numNessages); $unseen = unseenMessages($imapConnection, $numUnseen); echo ""; @@ -87,15 +87,9 @@ echo "\n"; $delimeter = findMailboxDelimeter($imapConnection); for ($i = 0;$i < count($boxes); $i++) { - $mailbox = $boxes[$i]["UNFORMATTED"]; - $boxFlags = getMailboxFlags($boxes[$i]["RAW"]); - - $boxCount = countCharInString($mailbox, $delimeter); - $line = ""; - // indent the correct number of spaces. - for ($j = 0;$j < $boxCount;$j++) - $line .= "  "; + $mailbox = $boxes[$i]["FORMATTED"]; + $boxFlags = getMailboxFlags($imapConnection, $boxes[$i]["RAW"]); if (trim($boxFlags[0]) != "") { $noselect = false; @@ -103,16 +97,15 @@ if (strtolower($boxFlags[$h]) == "noselect") $noselect = true; } - if ($noselect == true) { $line .= ""; $line .= readShortMailboxName($mailbox, $delimeter); $line .= ""; } else { - $line .= formatMailboxName($imapConnection, $mailbox, $delimeter, $color, $move_to_trash); + $line .= formatMailboxName($imapConnection, $mailbox, $boxes[$i]["UNFORMATTED"], $delimeter, $color, $move_to_trash); } } else { - $line .= formatMailboxName($imapConnection, $mailbox, $delimeter, $color, $move_to_trash); + $line .= formatMailboxName($imapConnection, $mailbox, $boxes[$i]["UNFORMATTED"], $delimeter, $color, $move_to_trash); } echo "$line
"; } -- 2.25.1