Removed a lot of the warnings generated when PHP has all warnings enabled.
[squirrelmail.git] / src / left_main.php
CommitLineData
59177427 1<?php
21c3249f 2 /**
a09387f4 3 ** left_main.php
ef870322 4 ** Copyright (c) 1999-2000 The SquirrelMail development team
5 ** Licensed under the GNU GPL. For full terms see the file COPYING.
21c3249f 6 **
7 ** This is the code for the left bar. The left bar shows the folders
8 ** available, and has cookie information.
9 **
245a6892 10 ** $Id$
21c3249f 11 **/
12
2a32fc83 13 session_start();
14
6d7061ac 15 if (!isset($i18n_php))
16 include ("../functions/i18n.php");
17
21c3249f 18 if(!isset($username)) {
441f2d33 19 set_up_language($squirrelmail_language, true);
10455998 20 include ("../themes/default_theme.php");
21 printf('<html><BODY TEXT="%s" BGCOLOR="%s" LINK="%s" VLINK="%s" ALINK="%s">',
22 $color[8], $color[4], $color[7], $color[7], $color[7]);
23 echo "</body></html>";
21c3249f 24 exit;
25 }
142499d4 26
207dff25 27
245a6892 28 if (!isset($strings_php))
29 include("../functions/strings.php");
d068c0ec 30 if (!isset($config_php))
31 include("../config/config.php");
32 if (!isset($array_php))
33 include("../functions/array.php");
d068c0ec 34 if (!isset($imap_php))
35 include("../functions/imap.php");
142499d4 36 if (!isset($page_header_php))
37 include("../functions/page_header.php");
9c1852ff 38 if (!isset($i18n_php))
39 include("../functions/i18n.php");
9d0c7bee 40 if (!isset($plugin_php))
41 include("../functions/plugin.php");
142499d4 42
99ab0367 43 // open a connection on the imap port (143)
44 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 10); // the 10 is to hide the output
45
46 /** If it was a successful login, lets load their preferences **/
47 include("../src/load_prefs.php");
48
2a833d72 49 displayHtmlHeader();
21c3249f 50
d1941f35 51 function formatMailboxName($imapConnection, $mailbox, $real_box, $delimeter, $unseen) {
5bdd7223 52 global $folder_prefix, $trash_folder, $sent_folder;
53 global $color, $move_to_sent, $move_to_trash;
24fc5dd2 54 global $unseen_notify, $unseen_type;
5bdd7223 55
4c34dac5 56 $mailboxURL = urlencode($real_box);
5bdd7223 57
24fc5dd2 58 if ($unseen_notify == 2 && $real_box == "INBOX") {
5bdd7223 59 $unseen = sqimap_unseen_messages($imapConnection, $numUnseen, $real_box);
24fc5dd2 60 if ($unseen_type == 1 && $unseen > 0) {
61 $unseen_string = "($unseen)";
62 $unseen_found = true;
63 } else if ($unseen_type == 2) {
64 $numMessages = sqimap_get_num_messages($imapConnection, $real_box);
65 $unseen_string = "<font color=\"$color[11]\">($unseen/$numMessages)</font>";
66 $unseen_found = true;
67 }
68 } else if ($unseen_notify == 3) {
5bdd7223 69 $unseen = sqimap_unseen_messages($imapConnection, $numUnseen, $real_box);
24fc5dd2 70 if ($unseen_type == 1 && $unseen > 0) {
71 $unseen_string = "($unseen)";
72 $unseen_found = true;
73 } else if ($unseen_type == 2) {
74 $numMessages = sqimap_get_num_messages($imapConnection, $real_box);
75 $unseen_string = "<font color=\"$color[11]\">($unseen/$numMessages)</font>";
76 $unseen_found = true;
77 }
78 }
5bdd7223 79
245a6892 80 $line = "<NOBR>";
d1941f35 81 if ($unseen > 0)
d92b6f31 82 $line .= "<B>";
83
7ce342dc 84 $special_color = false;
5bdd7223 85 if ((strtolower($real_box) == "inbox") ||
86 (($real_box == $trash_folder) && ($move_to_trash)) ||
87 (($real_box == $sent_folder) && ($move_to_sent)))
88 $special_color = true;
89
7ce342dc 90 if ($special_color == true) {
9f2215a1 91 $line .= "<a href=\"right_main.php?sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\"><FONT COLOR=\"$color[11]\">";
813eba2f 92 $line .= replace_spaces($mailbox);
7ce342dc 93 $line .= "</font></a>";
94 } else {
9f2215a1 95 $line .= "<a href=\"right_main.php?sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\">";
813eba2f 96 $line .= replace_spaces($mailbox);
1d4fe45e 97 $line .= "</a>";
d92b6f31 98 }
7ce342dc 99
d1941f35 100 if ($unseen > 0)
7ce342dc 101 $line .= "</B>";
5bdd7223 102
245a6892 103 if (isset($unseen_found) && $unseen_found) {
24fc5dd2 104 $line .= "&nbsp;<small>$unseen_string</small>";
7ce342dc 105 }
106
1e0628fb 107 if (($move_to_trash == true) && ($real_box == $trash_folder)) {
0ab89329 108 $urlMailbox = urlencode($real_box);
1d4fe45e 109 $line .= "\n<small>\n";
24fc5dd2 110 $line .= " &nbsp;&nbsp;(<B><A HREF=\"empty_trash.php\" style=\"text-decoration:none\">"._("purge")."</A></B>)";
1d4fe45e 111 $line .= "\n</small>\n";
d92b6f31 112 }
1d4fe45e 113 $line .= "</NOBR>";
d92b6f31 114 return $line;
115 }
116
4c34dac5 117 if (isset($left_refresh) && ($left_refresh != "None") && ($left_refresh != "")) {
1d4fe45e 118 echo "<META HTTP-EQUIV=\"Expires\" CONTENT=\"Thu, 01 Dec 1994 16:00:00 GMT\">\n";
119 echo "<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">\n";
120 echo "<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"$left_refresh;URL=left_main.php\">\n";
469eb37b 121 }
813eba2f 122
04632dbc 123 echo "\n<BODY BGCOLOR=\"$color[3]\" TEXT=\"$color[6]\" LINK=\"$color[6]\" VLINK=\"$color[6]\" ALINK=\"$color[6]\">\n";
f3d17401 124
9d0c7bee 125 do_hook("left_main_before");
126
813eba2f 127 $boxes = sqimap_mailbox_list($imapConnection);
21c3249f 128
1d4fe45e 129 echo "<CENTER><FONT SIZE=4><B>";
130 echo _("Folders") . "</B><BR></FONT>\n\n";
97afcee9 131
9f2215a1 132 echo "<small>(<A HREF=\"../src/left_main.php\" TARGET=\"left\">";
ad6f805c 133 echo _("refresh folder list");
aae41ae9 134 echo "</A>)</small></CENTER><BR>";
813eba2f 135 $delimeter = sqimap_get_delimiter($imapConnection);
4c34dac5 136
7ce342dc 137 for ($i = 0;$i < count($boxes); $i++) {
d92b6f31 138 $line = "";
813eba2f 139 $mailbox = $boxes[$i]["formatted"];
5bdd7223 140
813eba2f 141 if ($boxes[$i]["flags"]) {
7ce342dc 142 $noselect = false;
813eba2f 143 for ($h = 0; $h < count($boxes[$i]["flags"]); $h++) {
144 if (strtolower($boxes[$i]["flags"][$h]) == "noselect")
7ce342dc 145 $noselect = true;
d92b6f31 146 }
7ce342dc 147 if ($noselect == true) {
aae41ae9 148 $line .= "<FONT COLOR=\"$color[10]\">";
5bdd7223 149 $line .= replace_spaces($mailbox);
aae41ae9 150 $line .= "</FONT>";
7ce342dc 151 } else {
245a6892 152 if (! isset($boxes[$i]["unseen"]))
153 $boxes[$i]["unseen"] = 0;
d1941f35 154 $line .= formatMailboxName($imapConnection, $mailbox, $boxes[$i]["unformatted"], $delimeter, $boxes[$i]["unseen"]);
d92b6f31 155 }
7ce342dc 156 } else {
d1941f35 157 $line .= formatMailboxName($imapConnection, $mailbox, $boxes[$i]["unformatted"], $delimeter, $boxes[$i]["unseen"]);
d92b6f31 158 }
04632dbc 159 echo "$line<BR>\n";
d92b6f31 160 }
1195c340 161 sqimap_logout($imapConnection);
6b638171 162 do_hook("left_main_after");
21c3249f 163?>
aae41ae9 164</BODY></HTML>