fixed bug in color stuff
[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
d3cdb279 23 include("../src/load_prefs.php");
24
25 function formatMailboxName($imapConnection, $mailbox, $delimeter, $color) {
d92b6f31 26 require ("../config/config.php");
27
28 $mailboxURL = urlencode($mailbox);
29 selectMailbox($imapConnection, $mailbox, $numNessages);
30 $unseen = unseenMessages($imapConnection, $numUnseen);
31
97be2168 32 echo "<NOBR>";
d92b6f31 33 if ($unseen)
34 $line .= "<B>";
35
7ce342dc 36 $special_color = false;
37 for ($i = 0; $i < count($special_folders); $i++) {
38 if (($special_folders[$i] == $mailbox) && ($use_special_folder_color == true))
39 $special_color = true;
40 }
41
42 if ($special_color == true) {
43 $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]\">";
44 $line .= readShortMailboxName($mailbox, $delimeter);
45 $line .= "</font></a>";
46 } else {
47 $line .= "<a href=\"right_main.php?sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\"><FONT FACE=\"Arial,Helvetica\">";
48 $line .= readShortMailboxName($mailbox, $delimeter);
49 $line .= "</font></a>";
d92b6f31 50 }
7ce342dc 51
52 if ($unseen)
53 $line .= "</B>";
54
d92b6f31 55 if ($numUnseen > 0) {
7ce342dc 56 $line .= "&nbsp;<FONT FACE=\"Arial,Helvetica\" SIZE=2>($numUnseen)</FONT>";
57 }
58
59 if (($move_to_trash == true) && (trim($mailbox) == $trash_folder)) {
60 $urlMailbox = urlencode($mailbox);
61 $line .= "<FONT FACE=\"Arial,Helvetica\" SIZE=2>";
62 $line .= "&nbsp;&nbsp;&nbsp;&nbsp;(<B><A HREF=\"empty_trash.php?numMessages=$numMessages&mailbox=$urlMailbox\" TARGET=right style=\"text-decoration:none\">empty</A></B>)";
63 $line .= "</FONT></a>\n";
d92b6f31 64 }
97be2168 65
66 echo "</NOBR>";
d92b6f31 67 return $line;
68 }
69
f8f9bed9 70 echo "<BODY BGCOLOR=\"$color[3]\" TEXT=\"$color[6]\" LINK=\"$color[6]\" VLINK=\"$color[6]\" ALINK=\"$color[6]\">";
71 echo "<FONT FACE=\"Arial,Helvetica\">";
21c3249f 72 // open a connection on the imap port (143)
d92b6f31 73 $imapConnection = loginToImapServer($username, $key, $imapServerAddress, 10); // the 10 is to hide the output
21c3249f 74
7ce342dc 75 getFolderList($imapConnection, $boxes);
21c3249f 76
d92b6f31 77 echo "<FONT FACE=\"Arial,Helvetica\" SIZE=4><B><CENTER>";
ff89ac8a 78 echo "Folders</B><BR></FONT>";
97afcee9 79
d92b6f31 80 echo "<FONT FACE=\"Arial,Helvetica\" SIZE=2>(<A HREF=\"../src/left_main.php\" TARGET=left>refresh folder list</A>)</FONT></CENTER><BR>";
ff89ac8a 81 echo "<FONT FACE=\"Arial,Helvetica\">\n";
d92b6f31 82 $delimeter = findMailboxDelimeter($imapConnection);
7ce342dc 83 for ($i = 0;$i < count($boxes); $i++) {
84 $mailbox = $boxes[$i]["UNFORMATTED"];
85 $boxFlags = getMailboxFlags($boxes[$i]["RAW"]);
de80e95e 86
d92b6f31 87 $boxCount = countCharInString($mailbox, $delimeter);
88
89 $line = "";
21c3249f 90 // indent the correct number of spaces.
d92b6f31 91 for ($j = 0;$j < $boxCount;$j++)
92 $line .= "&nbsp;&nbsp;";
93
94 if (trim($boxFlags[0]) != "") {
7ce342dc 95 $noselect = false;
d92b6f31 96 for ($h = 0; $h < count($boxFlags); $h++) {
7ce342dc 97 if (strtolower($boxFlags[$h]) == "noselect")
98 $noselect = true;
d92b6f31 99 }
d92b6f31 100
7ce342dc 101 if ($noselect == true) {
102 $line .= "<FONT COLOR=\"$color[10]\" FACE=\"Arial,Helvetica\">";
103 $line .= readShortMailboxName($mailbox, $delimeter);
104 $line .= "</FONT><FONT FACE=\"Arial,Helvetica\">";
105 } else {
d3cdb279 106 $line .= formatMailboxName($imapConnection, $mailbox, $delimeter, $color);
d92b6f31 107 }
7ce342dc 108 } else {
d3cdb279 109 $line .= formatMailboxName($imapConnection, $mailbox, $delimeter, $color);
d92b6f31 110 }
7ce342dc 111 echo "$line<BR>";
d92b6f31 112 }
113
ff89ac8a 114 echo "</FONT>";
21c3249f 115
116 fclose($imapConnection);
117
118?>
119</FONT></BODY></HTML>