X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=src%2Fleft_main.php;h=112ad87b7aca3dc1a961b526acf28b002e0a17f4;hb=6b6381715922c24dc8664cc62464096814d6a291;hp=e3725eb8f151036a9403d8f1cbdb091ba0c9a6ff;hpb=f8f9bed9bb69ef0432fbc67741f82071b6582b4d;p=squirrelmail.git diff --git a/src/left_main.php b/src/left_main.php index e3725eb8..112ad87b 100644 --- a/src/left_main.php +++ b/src/left_main.php @@ -1,69 +1,154 @@ - - -"; - echo ""; - // open a connection on the imap port (143) - $imapConnection = loginToImapServer($username, $key, $imapServerAddress); - - fputs($imapConnection, "1 list \"\" *\n"); - $str = imapReadData($imapConnection); - - echo "
"; - echo "Folders
"; - echo "(refresh folder list)

"; - echo "\n"; - for ($i = 0;$i < count($str); $i++) { - $mailbox = Chop($str[$i]); - $mailbox = findMailboxName($mailbox); - - // find the quote at the begining of the mailbox name. - // i subtract 1 from the strlen so it doesn't find the quote at the end of the mailbox name. - $periodCount = countCharInString($mailbox, "."); - - // indent the correct number of spaces. - for ($j = 0;$j < $periodCount;$j++) - echo "  "; - - $mailboxURL = urlencode($mailbox); - selectMailbox($imapConnection, $mailbox, $numNessages); - $unseen = unseenMessages($imapConnection, $numUnseen); - if ($unseen) - echo ""; - echo ""; - echo readShortMailboxName($mailbox, "."); - if (($move_to_trash == true) && ($mailbox == $trash_folder)) { - $urlMailbox = urlencode($mailbox); - echo "    (empty)"; + if (!isset($config_php)) + include("../config/config.php"); + if (!isset($array_php)) + include("../functions/array.php"); + if (!isset($strings_php)) + include("../functions/strings.php"); + if (!isset($imap_php)) + include("../functions/imap.php"); + if (!isset($page_header_php)) + include("../functions/page_header.php"); + if (!isset($i18n_php)) + include("../functions/i18n.php"); + if (!isset($plugin_php)) + include("../functions/plugin.php"); + + displayHtmlHeader(); + + function formatMailboxName($imapConnection, $mailbox, $real_box, $delimeter, $unseen) { + global $folder_prefix, $trash_folder, $sent_folder; + global $color, $move_to_sent, $move_to_trash; + global $unseen_notify, $unseen_type; + + $mailboxURL = urlencode($real_box); + + if ($unseen_notify == 2 && $real_box == "INBOX") { + $unseen = sqimap_unseen_messages($imapConnection, $numUnseen, $real_box); + if ($unseen_type == 1 && $unseen > 0) { + $unseen_string = "($unseen)"; + $unseen_found = true; + } else if ($unseen_type == 2) { + $numMessages = sqimap_get_num_messages($imapConnection, $real_box); + $unseen_string = "($unseen/$numMessages)"; + $unseen_found = true; + } + } else if ($unseen_notify == 3) { + $unseen = sqimap_unseen_messages($imapConnection, $numUnseen, $real_box); + if ($unseen_type == 1 && $unseen > 0) { + $unseen_string = "($unseen)"; + $unseen_found = true; + } else if ($unseen_type == 2) { + $numMessages = sqimap_get_num_messages($imapConnection, $real_box); + $unseen_string = "($unseen/$numMessages)"; + $unseen_found = true; + } } - echo "\n"; - if ($numUnseen > 0) { - echo " ($numUnseen)"; + + $line .= ""; + if ($unseen > 0) + $line .= ""; + + $special_color = false; + if ((strtolower($real_box) == "inbox") || + (($real_box == $trash_folder) && ($move_to_trash)) || + (($real_box == $sent_folder) && ($move_to_sent))) + $special_color = true; + + if ($special_color == true) { + $line .= ""; + $line .= replace_spaces($mailbox); + $line .= ""; + } else { + $line .= ""; + $line .= replace_spaces($mailbox); + $line .= ""; } - echo "
\n"; + + if ($unseen > 0) + $line .= "
"; + + if ($unseen_found) { + $line .= " $unseen_string"; + } + + if (($move_to_trash == true) && ($real_box == $trash_folder)) { + $urlMailbox = urlencode($real_box); + $line .= "\n\n"; + $line .= "   ("._("purge").")"; + $line .= "\n\n"; + } + $line .= "
"; + return $line; } - echo "
"; - fclose($imapConnection); - + // open a connection on the imap port (143) + $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 10); // the 10 is to hide the output + + /** If it was a successful login, lets load their preferences **/ + include("../src/load_prefs.php"); + + if (isset($left_refresh) && ($left_refresh != "None") && ($left_refresh != "")) { + echo "\n"; + echo "\n"; + echo "\n"; + } + + echo "\n\n\n"; + + do_hook("left_main_before"); + + $boxes = sqimap_mailbox_list($imapConnection); + + echo "
"; + echo _("Folders") . "
\n\n"; + + echo "("; + echo _("refresh folder list"); + echo ")

"; + $delimeter = sqimap_get_delimiter($imapConnection); + + for ($i = 0;$i < count($boxes); $i++) { + $line = ""; + $mailbox = $boxes[$i]["formatted"]; + + if ($boxes[$i]["flags"]) { + $noselect = false; + for ($h = 0; $h < count($boxes[$i]["flags"]); $h++) { + if (strtolower($boxes[$i]["flags"][$h]) == "noselect") + $noselect = true; + } + if ($noselect == true) { + $line .= ""; + $line .= replace_spaces(readShortMailboxName($mailbox, $delimeter)); + $line .= ""; + } else { + $line .= formatMailboxName($imapConnection, $mailbox, $boxes[$i]["unformatted"], $delimeter, $boxes[$i]["unseen"]); + } + } else { + $line .= formatMailboxName($imapConnection, $mailbox, $boxes[$i]["unformatted"], $delimeter, $boxes[$i]["unseen"]); + } + echo "\n$line
\n"; + } + sqimap_logout($imapConnection); + do_hook("left_main_after"); ?> - +