Added "Themes" to personal preferences
[squirrelmail.git] / src / left_main.php
1 <?
2 /**
3 ** left_main.php
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>
16 <?
17 include("../config/config.php");
18 include("../functions/array.php");
19 include("../functions/strings.php");
20 include("../functions/imap.php");
21 include("../functions/mailbox.php");
22
23 include("../src/load_prefs.php");
24
25 function formatMailboxName($imapConnection, $mailbox, $delimeter, $color) {
26 require ("../config/config.php");
27
28 $mailboxURL = urlencode($mailbox);
29 selectMailbox($imapConnection, $mailbox, $numNessages);
30 $unseen = unseenMessages($imapConnection, $numUnseen);
31
32 echo "<NOBR>";
33 if ($unseen)
34 $line .= "<B>";
35
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>";
50 }
51
52 if ($unseen)
53 $line .= "</B>";
54
55 if ($numUnseen > 0) {
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";
64 }
65
66 echo "</NOBR>";
67 return $line;
68 }
69
70 echo "<BODY BGCOLOR=\"$color[3]\" TEXT=\"$color[6]\" LINK=\"$color[6]\" VLINK=\"$color[6]\" ALINK=\"$color[6]\">";
71 echo "<FONT FACE=\"Arial,Helvetica\">";
72 // open a connection on the imap port (143)
73 $imapConnection = loginToImapServer($username, $key, $imapServerAddress, 10); // the 10 is to hide the output
74
75 getFolderList($imapConnection, $boxes);
76
77 echo "<FONT FACE=\"Arial,Helvetica\" SIZE=4><B><CENTER>";
78 echo "Folders</B><BR></FONT>";
79
80 echo "<FONT FACE=\"Arial,Helvetica\" SIZE=2>(<A HREF=\"../src/left_main.php\" TARGET=left>refresh folder list</A>)</FONT></CENTER><BR>";
81 echo "<FONT FACE=\"Arial,Helvetica\">\n";
82 $delimeter = findMailboxDelimeter($imapConnection);
83 for ($i = 0;$i < count($boxes); $i++) {
84 $mailbox = $boxes[$i]["UNFORMATTED"];
85 $boxFlags = getMailboxFlags($boxes[$i]["RAW"]);
86
87 $boxCount = countCharInString($mailbox, $delimeter);
88
89 $line = "";
90 // indent the correct number of spaces.
91 for ($j = 0;$j < $boxCount;$j++)
92 $line .= "&nbsp;&nbsp;";
93
94 if (trim($boxFlags[0]) != "") {
95 $noselect = false;
96 for ($h = 0; $h < count($boxFlags); $h++) {
97 if (strtolower($boxFlags[$h]) == "noselect")
98 $noselect = true;
99 }
100
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 {
106 $line .= formatMailboxName($imapConnection, $mailbox, $delimeter, $color);
107 }
108 } else {
109 $line .= formatMailboxName($imapConnection, $mailbox, $delimeter, $color);
110 }
111 echo "$line<BR>";
112 }
113
114 echo "</FONT>";
115
116 fclose($imapConnection);
117
118 ?>
119 </FONT></BODY></HTML>