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