updated changelog, todo
[squirrelmail.git] / src / left_main.php
CommitLineData
21c3249f 1<?
2 /**
a09387f4 3 ** left_main.php
21c3249f 4 **
5 ** This is the code for the left bar. The left bar shows the folders
6 ** available, and has cookie information.
7 **
8 **/
9
10 if(!isset($username)) {
11 echo "You need a valid user and password to access this page!";
12 exit;
13 }
142499d4 14
d068c0ec 15 if (!isset($config_php))
16 include("../config/config.php");
17 if (!isset($array_php))
18 include("../functions/array.php");
19 if (!isset($strings_php))
20 include("../functions/strings.php");
21 if (!isset($imap_php))
22 include("../functions/imap.php");
142499d4 23 if (!isset($page_header_php))
24 include("../functions/page_header.php");
9c1852ff 25 if (!isset($i18n_php))
26 include("../functions/i18n.php");
27
142499d4 28
29 echo "<HTML>";
21c3249f 30
91f999f6 31 function formatMailboxName($imapConnection, $mailbox, $real_box, $delimeter, $color, $move_to_trash) {
d92b6f31 32 require ("../config/config.php");
33
4c34dac5 34 $mailboxURL = urlencode($real_box);
813eba2f 35 sqimap_mailbox_select ($imapConnection, $real_box);
36 $unseen = sqimap_unseen_messages($imapConnection, $numUnseen);
d92b6f31 37
97be2168 38 echo "<NOBR>";
d92b6f31 39 if ($unseen)
40 $line .= "<B>";
41
7ce342dc 42 $special_color = false;
43 for ($i = 0; $i < count($special_folders); $i++) {
f16d469a 44 if (($special_folders[$i] == $real_box) && ($use_special_folder_color == true))
7ce342dc 45 $special_color = true;
46 }
47
48 if ($special_color == true) {
aae41ae9 49 $line .= "<a href=\"right_main.php?sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\"><FONT COLOR=\"$color[11]\">";
813eba2f 50 $line .= replace_spaces($mailbox);
7ce342dc 51 $line .= "</font></a>";
52 } else {
aae41ae9 53 $line .= "<a href=\"right_main.php?sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\">";
813eba2f 54 $line .= replace_spaces($mailbox);
7ce342dc 55 $line .= "</font></a>";
d92b6f31 56 }
7ce342dc 57
58 if ($unseen)
59 $line .= "</B>";
60
d92b6f31 61 if ($numUnseen > 0) {
aae41ae9 62 $line .= "&nbsp;<small>($numUnseen)</small>";
7ce342dc 63 }
64
0ab89329 65 if (($move_to_trash == true) && (trim($real_box) == $trash_folder)) {
66 $urlMailbox = urlencode($real_box);
aae41ae9 67 $line .= "<small>";
b6def0e7 68 $line .= "&nbsp;&nbsp;&nbsp;&nbsp;(<B><A HREF=\"empty_trash.php?numMessages=$numMessages&mailbox=$urlMailbox\" TARGET=right style=\"text-decoration:none\">"._("purge")."</A></B>)";
aae41ae9 69 $line .= "</small></a>\n";
d92b6f31 70 }
97be2168 71
72 echo "</NOBR>";
d92b6f31 73 return $line;
74 }
75
21c3249f 76 // open a connection on the imap port (143)
e1469126 77 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 10); // the 10 is to hide the output
21c3249f 78
f3d17401 79 /** If it was a successful login, lets load their preferences **/
80 include("../src/load_prefs.php");
9c1852ff 81
4c34dac5 82 if (isset($left_refresh) && ($left_refresh != "None") && ($left_refresh != "")) {
aff57ea5 83 echo "<META HTTP-EQUIV=\"Expires\" CONTENT=\"Thu, 01 Dec 1994 16:00:00 GMT\">";
84 echo "<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">";
469eb37b 85 echo "<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"$left_refresh;URL=left_main.php\">";
86 }
813eba2f 87
f3d17401 88 echo "<BODY BGCOLOR=\"$color[3]\" TEXT=\"$color[6]\" LINK=\"$color[6]\" VLINK=\"$color[6]\" ALINK=\"$color[6]\">";
f3d17401 89
813eba2f 90 $boxes = sqimap_mailbox_list($imapConnection);
21c3249f 91
aae41ae9 92 echo "<FONT SIZE=4><B><CENTER>";
813eba2f 93 echo _("Folders") . "</B><BR></FONT>";
97afcee9 94
aae41ae9 95 echo "<small>(<A HREF=\"../src/left_main.php\" TARGET=\"left\">";
ad6f805c 96 echo _("refresh folder list");
aae41ae9 97 echo "</A>)</small></CENTER><BR>";
813eba2f 98 $delimeter = sqimap_get_delimiter($imapConnection);
4c34dac5 99
7ce342dc 100 for ($i = 0;$i < count($boxes); $i++) {
d92b6f31 101 $line = "";
813eba2f 102 $mailbox = $boxes[$i]["formatted"];
d92b6f31 103
813eba2f 104 if ($boxes[$i]["flags"]) {
7ce342dc 105 $noselect = false;
813eba2f 106 for ($h = 0; $h < count($boxes[$i]["flags"]); $h++) {
107 if (strtolower($boxes[$i]["flags"][$h]) == "noselect")
7ce342dc 108 $noselect = true;
d92b6f31 109 }
7ce342dc 110 if ($noselect == true) {
aae41ae9 111 $line .= "<FONT COLOR=\"$color[10]\">";
813eba2f 112 $line .= replace_spaces(readShortMailboxName($mailbox, $delimeter));
aae41ae9 113 $line .= "</FONT>";
7ce342dc 114 } else {
813eba2f 115 $line .= formatMailboxName($imapConnection, $mailbox, $boxes[$i]["unformatted"], $delimeter, $color, $move_to_trash);
d92b6f31 116 }
7ce342dc 117 } else {
813eba2f 118 $line .= formatMailboxName($imapConnection, $mailbox, $boxes[$i]["unformatted"], $delimeter, $color, $move_to_trash);
d92b6f31 119 }
7ce342dc 120 echo "$line<BR>";
d92b6f31 121 }
122
21c3249f 123
124 fclose($imapConnection);
125
126?>
aae41ae9 127</BODY></HTML>