4 ** Copyright (c) 1999-2000 The SquirrelMail development team
5 ** Licensed under the GNU GPL. For full terms see the file COPYING.
7 ** This is the code for the left bar. The left bar shows the folders
8 ** available, and has cookie information.
14 if(!isset($username)) {
15 echo "You need a valid user and password to access this page!";
20 if (!isset($config_php))
21 include("../config/config.php");
22 if (!isset($array_php))
23 include("../functions/array.php");
24 if (!isset($strings_php))
25 include("../functions/strings.php");
26 if (!isset($imap_php))
27 include("../functions/imap.php");
28 if (!isset($page_header_php))
29 include("../functions/page_header.php");
30 if (!isset($i18n_php))
31 include("../functions/i18n.php");
36 function formatMailboxName($imapConnection, $mailbox, $real_box, $delimeter, $unseen) {
37 global $folder_prefix, $trash_folder, $sent_folder;
38 global $color, $move_to_sent, $move_to_trash;
39 global $unseen_notify, $unseen_type;
41 $mailboxURL = urlencode($real_box);
43 if ($unseen_notify == 2 && $real_box == "INBOX") {
44 $unseen = sqimap_unseen_messages($imapConnection, $numUnseen, $real_box);
45 if ($unseen_type == 1 && $unseen > 0) {
46 $unseen_string = "($unseen)";
48 } else if ($unseen_type == 2) {
49 $numMessages = sqimap_get_num_messages($imapConnection, $real_box);
50 $unseen_string = "<font color=\"$color[11]\">($unseen/$numMessages)</font>";
53 } else if ($unseen_notify == 3) {
54 $unseen = sqimap_unseen_messages($imapConnection, $numUnseen, $real_box);
55 if ($unseen_type == 1 && $unseen > 0) {
56 $unseen_string = "($unseen)";
58 } else if ($unseen_type == 2) {
59 $numMessages = sqimap_get_num_messages($imapConnection, $real_box);
60 $unseen_string = "<font color=\"$color[11]\">($unseen/$numMessages)</font>";
69 $special_color = false;
70 if ((strtolower($real_box) == "inbox") ||
71 (($real_box == $trash_folder) && ($move_to_trash)) ||
72 (($real_box == $sent_folder) && ($move_to_sent)))
73 $special_color = true;
75 if ($special_color == true) {
76 $line .= "<a href=\"right_main.php?sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\"><FONT COLOR=\"$color[11]\">";
77 $line .= replace_spaces($mailbox);
78 $line .= "</font></a>";
80 $line .= "<a href=\"right_main.php?sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\">";
81 $line .= replace_spaces($mailbox);
89 $line .= " <small>$unseen_string</small>";
92 if (($move_to_trash == true) && ($real_box == $trash_folder)) {
93 $urlMailbox = urlencode($real_box);
94 $line .= "\n<small>\n";
95 $line .= " (<B><A HREF=\"empty_trash.php\" style=\"text-decoration:none\">"._("purge")."</A></B>)";
96 $line .= "\n</small>\n";
102 // open a connection on the imap port (143)
103 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 10); // the 10 is to hide the output
105 /** If it was a successful login, lets load their preferences **/
106 include("../src/load_prefs.php");
108 if (isset($left_refresh) && ($left_refresh != "None") && ($left_refresh != "")) {
109 echo "<META HTTP-EQUIV=\"Expires\" CONTENT=\"Thu, 01 Dec 1994 16:00:00 GMT\">\n";
110 echo "<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">\n";
111 echo "<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"$left_refresh;URL=left_main.php\">\n";
114 echo "\n<BODY BGCOLOR=\"$color[3]\" TEXT=\"$color[6]\" LINK=\"$color[6]\" VLINK=\"$color[6]\" ALINK=\"$color[6]\">\n\n";
116 $boxes = sqimap_mailbox_list($imapConnection);
118 echo "<CENTER><FONT SIZE=4><B>";
119 echo _("Folders") . "</B><BR></FONT>\n\n";
121 echo "<small>(<A HREF=\"../src/left_main.php\" TARGET=\"left\">";
122 echo _("refresh folder list");
123 echo "</A>)</small></CENTER><BR>";
124 $delimeter = sqimap_get_delimiter($imapConnection);
126 for ($i = 0;$i < count($boxes); $i++
) {
128 $mailbox = $boxes[$i]["formatted"];
130 if ($boxes[$i]["flags"]) {
132 for ($h = 0; $h < count($boxes[$i]["flags"]); $h++
) {
133 if (strtolower($boxes[$i]["flags"][$h]) == "noselect")
136 if ($noselect == true) {
137 $line .= "<FONT COLOR=\"$color[10]\">";
138 $line .= replace_spaces(readShortMailboxName($mailbox, $delimeter));
141 $line .= formatMailboxName($imapConnection, $mailbox, $boxes[$i]["unformatted"], $delimeter, $boxes[$i]["unseen"]);
144 $line .= formatMailboxName($imapConnection, $mailbox, $boxes[$i]["unformatted"], $delimeter, $boxes[$i]["unseen"]);
146 echo "\n$line<BR>\n";
149 sqimap_logout($imapConnection);