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