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