fixed a couple of bugs in folder manipulation, in particular:
[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 }
14?>
15<HTML>
21c3249f 16<?
a09387f4 17 include("../config/config.php");
d92b6f31 18 include("../functions/array.php");
a09387f4 19 include("../functions/strings.php");
20 include("../functions/imap.php");
de80e95e 21 include("../functions/mailbox.php");
21c3249f 22
91f999f6 23 function formatMailboxName($imapConnection, $mailbox, $real_box, $delimeter, $color, $move_to_trash) {
d92b6f31 24 require ("../config/config.php");
25
4c34dac5 26 $mailboxURL = urlencode($real_box);
91f999f6 27 selectMailbox($imapConnection, $real_box, $numNessages);
d92b6f31 28 $unseen = unseenMessages($imapConnection, $numUnseen);
29
97be2168 30 echo "<NOBR>";
d92b6f31 31 if ($unseen)
32 $line .= "<B>";
33
7ce342dc 34 $special_color = false;
35 for ($i = 0; $i < count($special_folders); $i++) {
f16d469a 36 if (($special_folders[$i] == $real_box) && ($use_special_folder_color == true))
7ce342dc 37 $special_color = true;
38 }
39
40 if ($special_color == true) {
41 $line .= "<a href=\"right_main.php?sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\"><FONT FACE=\"Arial,Helvetica\" COLOR=\"$color[11]\">";
42 $line .= readShortMailboxName($mailbox, $delimeter);
43 $line .= "</font></a>";
44 } else {
45 $line .= "<a href=\"right_main.php?sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\"><FONT FACE=\"Arial,Helvetica\">";
46 $line .= readShortMailboxName($mailbox, $delimeter);
47 $line .= "</font></a>";
d92b6f31 48 }
7ce342dc 49
50 if ($unseen)
51 $line .= "</B>";
52
d92b6f31 53 if ($numUnseen > 0) {
7ce342dc 54 $line .= "&nbsp;<FONT FACE=\"Arial,Helvetica\" SIZE=2>($numUnseen)</FONT>";
55 }
56
57 if (($move_to_trash == true) && (trim($mailbox) == $trash_folder)) {
58 $urlMailbox = urlencode($mailbox);
59 $line .= "<FONT FACE=\"Arial,Helvetica\" SIZE=2>";
60 $line .= "&nbsp;&nbsp;&nbsp;&nbsp;(<B><A HREF=\"empty_trash.php?numMessages=$numMessages&mailbox=$urlMailbox\" TARGET=right style=\"text-decoration:none\">empty</A></B>)";
61 $line .= "</FONT></a>\n";
d92b6f31 62 }
97be2168 63
64 echo "</NOBR>";
d92b6f31 65 return $line;
66 }
67
21c3249f 68 // open a connection on the imap port (143)
d92b6f31 69 $imapConnection = loginToImapServer($username, $key, $imapServerAddress, 10); // the 10 is to hide the output
21c3249f 70
f3d17401 71 /** If it was a successful login, lets load their preferences **/
72 include("../src/load_prefs.php");
4c34dac5 73 if (isset($left_refresh) && ($left_refresh != "None") && ($left_refresh != "")) {
aff57ea5 74 echo "<META HTTP-EQUIV=\"Expires\" CONTENT=\"Thu, 01 Dec 1994 16:00:00 GMT\">";
75 echo "<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">";
469eb37b 76 echo "<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"$left_refresh;URL=left_main.php\">";
77 }
f3d17401 78 echo "<BODY BGCOLOR=\"$color[3]\" TEXT=\"$color[6]\" LINK=\"$color[6]\" VLINK=\"$color[6]\" ALINK=\"$color[6]\">";
79 echo "<FONT FACE=\"Arial,Helvetica\">";
80
7ce342dc 81 getFolderList($imapConnection, $boxes);
21c3249f 82
d92b6f31 83 echo "<FONT FACE=\"Arial,Helvetica\" SIZE=4><B><CENTER>";
ff89ac8a 84 echo "Folders</B><BR></FONT>";
97afcee9 85
ad6f805c 86 echo "<FONT FACE=\"Arial,Helvetica\" SIZE=2>(<A HREF=\"../src/left_main.php\" TARGET=\"left\">";
87 echo _("refresh folder list");
88 echo "</A>)</FONT></CENTER><BR>";
ff89ac8a 89 echo "<FONT FACE=\"Arial,Helvetica\">\n";
d92b6f31 90 $delimeter = findMailboxDelimeter($imapConnection);
4c34dac5 91
7ce342dc 92 for ($i = 0;$i < count($boxes); $i++) {
d92b6f31 93 $line = "";
91f999f6 94 $mailbox = $boxes[$i]["FORMATTED"];
95 $boxFlags = getMailboxFlags($imapConnection, $boxes[$i]["RAW"]);
d92b6f31 96
97 if (trim($boxFlags[0]) != "") {
7ce342dc 98 $noselect = false;
d92b6f31 99 for ($h = 0; $h < count($boxFlags); $h++) {
7ce342dc 100 if (strtolower($boxFlags[$h]) == "noselect")
101 $noselect = true;
d92b6f31 102 }
7ce342dc 103 if ($noselect == true) {
104 $line .= "<FONT COLOR=\"$color[10]\" FACE=\"Arial,Helvetica\">";
105 $line .= readShortMailboxName($mailbox, $delimeter);
106 $line .= "</FONT><FONT FACE=\"Arial,Helvetica\">";
107 } else {
91f999f6 108 $line .= formatMailboxName($imapConnection, $mailbox, $boxes[$i]["UNFORMATTED"], $delimeter, $color, $move_to_trash);
d92b6f31 109 }
7ce342dc 110 } else {
91f999f6 111 $line .= formatMailboxName($imapConnection, $mailbox, $boxes[$i]["UNFORMATTED"], $delimeter, $color, $move_to_trash);
d92b6f31 112 }
7ce342dc 113 echo "$line<BR>";
d92b6f31 114 }
115
ff89ac8a 116 echo "</FONT>";
21c3249f 117
118 fclose($imapConnection);
119
120?>
121</FONT></BODY></HTML>