59177427 |
1 | <?php |
895905c0 |
2 | |
35586184 |
3 | /** |
4 | * left_main.php |
5 | * |
82d304a0 |
6 | * Copyright (c) 1999-2004 The SquirrelMail Project Team |
35586184 |
7 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
8 | * |
9 | * This is the code for the left bar. The left bar shows the folders |
10 | * available, and has cookie information. |
11 | * |
30967a1e |
12 | * @version $Id$ |
8f6f9ba5 |
13 | * @package squirrelmail |
1c52ba77 |
14 | */ |
35586184 |
15 | |
30967a1e |
16 | /** |
17 | * Path for SquirrelMail required files. |
18 | * @ignore |
19 | */ |
dcc1cc82 |
20 | define('SM_PATH','../'); |
86725763 |
21 | |
22 | /* SquirrelMail required files. */ |
08185f2a |
23 | require_once(SM_PATH . 'include/validate.php'); |
86725763 |
24 | require_once(SM_PATH . 'functions/imap.php'); |
25 | require_once(SM_PATH . 'functions/plugin.php'); |
26 | require_once(SM_PATH . 'functions/page_header.php'); |
27 | require_once(SM_PATH . 'functions/html.php'); |
b6d26135 |
28 | require_once(SM_PATH . 'functions/date.php'); |
142499d4 |
29 | |
95e93571 |
30 | /* These constants are used for folder stuff. */ |
31 | define('SM_BOX_UNCOLLAPSED', 0); |
32 | define('SM_BOX_COLLAPSED', 1); |
a6d2e0de |
33 | |
2d367c68 |
34 | /* --------------------- FUNCTIONS ------------------------- */ |
525b7ae6 |
35 | |
95e93571 |
36 | function formatMailboxName($imapConnection, $box_array) { |
1c52ba77 |
37 | |
90de1755 |
38 | global $folder_prefix, $trash_folder, $sent_folder, |
39 | $color, $move_to_sent, $move_to_trash, |
40 | $unseen_notify, $unseen_type, $collapse_folders, |
41 | $draft_folder, $save_as_draft, |
dcc1cc82 |
42 | $use_special_folder_color; |
95e93571 |
43 | $real_box = $box_array['unformatted']; |
44 | $mailbox = str_replace(' ','',$box_array['formatted']); |
45 | $mailboxURL = urlencode($real_box); |
dcc1cc82 |
46 | |
95e93571 |
47 | /* Strip down the mailbox name. */ |
48 | if (ereg("^( *)([^ ]*)$", $mailbox, $regs)) { |
49 | $mailbox = $regs[2]; |
50 | } |
ae012102 |
51 | $unseen = 0; |
ae37633c |
52 | $status = array('',''); |
ae012102 |
53 | if (($unseen_notify == 2 && $real_box == 'INBOX') || |
54 | $unseen_notify == 3) { |
a6172cd5 |
55 | $tmp_status = create_unseen_string($real_box, $box_array, $imapConnection, $unseen_type ); |
56 | if ($status !== false) { |
57 | $status = $tmp_status; |
58 | } |
474fc5fa |
59 | } |
ae37633c |
60 | list($unseen_string, $unseen) = $status; |
ffb1a3d9 |
61 | $special_color = ($use_special_folder_color && isSpecialMailbox($real_box)); |
f7b1b3b1 |
62 | |
95e93571 |
63 | /* Start off with a blank line. */ |
64 | $line = ''; |
235a65d5 |
65 | |
95e93571 |
66 | /* If there are unseen message, bold the line. */ |
67 | if ($unseen > 0) { $line .= '<B>'; } |
a6d2e0de |
68 | |
fb0ca797 |
69 | /* Create the link for this folder. */ |
474fc5fa |
70 | if ($status !== false) { |
324ac3c5 |
71 | $line .= '<a href="right_main.php?PG_SHOWALL=0&startMessage=1&mailbox='. |
dcc1cc82 |
72 | $mailboxURL.'" TARGET="right" STYLE="text-decoration:none">'; |
a6172cd5 |
73 | } |
1c52ba77 |
74 | if ($special_color) { |
3fde693b |
75 | $line .= "<font color=\"$color[11]\">"; |
1c52ba77 |
76 | } |
a551489c |
77 | if ( $mailbox == 'INBOX' ) { |
78 | $line .= _("INBOX"); |
79 | } else { |
91727f6a |
80 | $line .= str_replace(array(' ','<','>'),array(' ','<','>'),$mailbox); |
a551489c |
81 | } |
90de1755 |
82 | if ($special_color == TRUE) |
3fde693b |
83 | $line .= '</font>'; |
474fc5fa |
84 | if ($status !== false) { |
a6172cd5 |
85 | $line .= '</a>'; |
474fc5fa |
86 | } |
a6d2e0de |
87 | |
95e93571 |
88 | /* If there are unseen message, close bolding. */ |
89 | if ($unseen > 0) { $line .= "</B>"; } |
2d367c68 |
90 | |
95e93571 |
91 | /* Print unseen information. */ |
ffb1a3d9 |
92 | if ($unseen_string != '') { |
95e93571 |
93 | $line .= " <SMALL>$unseen_string</SMALL>"; |
2016e645 |
94 | } |
95 | |
a6172cd5 |
96 | /* If it's the trash folder, show a purge link when needed */ |
1c52ba77 |
97 | if (($move_to_trash) && ($real_box == $trash_folder)) { |
95e93571 |
98 | if (! isset($numMessages)) { |
99 | $numMessages = sqimap_get_num_messages($imapConnection, $real_box); |
a6d2e0de |
100 | } |
a6d2e0de |
101 | |
4d5537d1 |
102 | if (($numMessages > 0) or ($box_array['parent'] == 1)) { |
95e93571 |
103 | $urlMailbox = urlencode($real_box); |
104 | $line .= "\n<small>\n" . |
dcc1cc82 |
105 | " (<A HREF=\"empty_trash.php\" style=\"text-decoration:none\">"._("purge")."</A>)" . |
7fb54066 |
106 | "</small>"; |
a6d2e0de |
107 | } |
108 | } |
a6d2e0de |
109 | |
8fc208f8 |
110 | |
111 | // let plugins fiddle with end of line |
112 | $line .= concat_hook_function('left_main_after_each_folder', |
113 | array(isset($numMessages) ? $numMessages : '', $real_box, $imapConnection)); |
114 | |
115 | |
95e93571 |
116 | /* Return the final product. */ |
117 | return ($line); |
118 | } |
a6d2e0de |
119 | |
95e93571 |
120 | /** |
121 | * Recursive function that computes the collapsed status and parent |
122 | * (or not parent) status of this box, and the visiblity and collapsed |
123 | * status and parent (or not parent) status for all children boxes. |
124 | */ |
125 | function compute_folder_children(&$parbox, $boxcount) { |
126 | global $boxes, $data_dir, $username, $collapse_folders; |
127 | $nextbox = $parbox + 1; |
128 | |
129 | /* Retreive the name for the parent box. */ |
130 | $parbox_name = $boxes[$parbox]['unformatted']; |
131 | |
132 | /* 'Initialize' this parent box to childless. */ |
1c52ba77 |
133 | $boxes[$parbox]['parent'] = FALSE; |
95e93571 |
134 | |
135 | /* Compute the collapse status for this box. */ |
136 | if( isset($collapse_folders) && $collapse_folders ) { |
137 | $collapse = getPref($data_dir, $username, 'collapse_folder_' . $parbox_name); |
138 | $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED : $collapse); |
139 | } else { |
140 | $collapse = SM_BOX_UNCOLLAPSED; |
a6d2e0de |
141 | } |
95e93571 |
142 | $boxes[$parbox]['collapse'] = $collapse; |
2d367c68 |
143 | |
95e93571 |
144 | /* Otherwise, get the name of the next box. */ |
1c52ba77 |
145 | if (isset($boxes[$nextbox]['unformatted'])) { |
95e93571 |
146 | $nextbox_name = $boxes[$nextbox]['unformatted']; |
1c52ba77 |
147 | } else { |
95e93571 |
148 | $nextbox_name = ''; |
1c52ba77 |
149 | } |
a6d2e0de |
150 | |
95e93571 |
151 | /* Compute any children boxes for this box. */ |
152 | while (($nextbox < $boxcount) && |
153 | (is_parent_box($boxes[$nextbox]['unformatted'], $parbox_name))) { |
a6d2e0de |
154 | |
95e93571 |
155 | /* Note that this 'parent' box has at least one child. */ |
1c52ba77 |
156 | $boxes[$parbox]['parent'] = TRUE; |
a6d2e0de |
157 | |
95e93571 |
158 | /* Compute the visiblity of this box. */ |
1c52ba77 |
159 | $boxes[$nextbox]['visible'] = ($boxes[$parbox]['visible'] && |
160 | ($boxes[$parbox]['collapse'] != SM_BOX_COLLAPSED)); |
a6d2e0de |
161 | |
95e93571 |
162 | /* Compute the visibility of any child boxes. */ |
163 | compute_folder_children($nextbox, $boxcount); |
164 | } |
2d367c68 |
165 | |
95e93571 |
166 | /* Set the parent box to the current next box. */ |
167 | $parbox = $nextbox; |
168 | } |
2d367c68 |
169 | |
95e93571 |
170 | /** |
171 | * Create the link for a parent folder that will allow that |
172 | * parent folder to either be collapsed or expaned, as is |
173 | * currently appropriate. |
174 | */ |
175 | function create_collapse_link($boxnum) { |
6395c46d |
176 | global $boxes, $imapConnection, $unseen_notify, $color, $use_icons, $icon_theme; |
95e93571 |
177 | $mailbox = urlencode($boxes[$boxnum]['unformatted']); |
a6172cd5 |
178 | |
95e93571 |
179 | /* Create the link for this collapse link. */ |
90de1755 |
180 | $link = '<a target="left" style="text-decoration:none" ' . |
dcc1cc82 |
181 | 'href="left_main.php?'; |
95e93571 |
182 | if ($boxes[$boxnum]['collapse'] == SM_BOX_COLLAPSED) { |
6395c46d |
183 | if ($use_icons && $icon_theme != 'none') { |
184 | $link .= "unfold=$mailbox\"><IMG src=\"" . SM_PATH . "images/plus.png\" border=\"0\" height=\"7\" width=\"7\">"; |
185 | } else { |
186 | $link .= "unfold=$mailbox\">+"; |
187 | } |
ffb1a3d9 |
188 | } else { |
6395c46d |
189 | if ($use_icons && $icon_theme != 'none') { |
190 | $link .= "fold=$mailbox\"><IMG src=\"" . SM_PATH . "images/minus.png\" border=\"0\" height=\"7\" width=\"7\">"; |
191 | } else { |
192 | $link .= "fold=$mailbox\">-"; |
193 | } |
ffb1a3d9 |
194 | } |
195 | $link .= '</a>'; |
196 | |
197 | /* Return the finished product. */ |
198 | return ($link); |
199 | } |
200 | |
201 | /** |
202 | * create_unseen_string: |
203 | * |
204 | * Create unseen and total message count for both this folder and |
205 | * it's subfolders. |
206 | * |
207 | * @param string $boxName name of the current mailbox |
208 | * @param array $boxArray array for the current mailbox |
209 | * @param $imapConnection current imap connection in use |
8f6f9ba5 |
210 | * @return array unseen message string (for display), unseen message count |
ffb1a3d9 |
211 | */ |
ae012102 |
212 | function create_unseen_string($boxName, $boxArray, $imapConnection, $unseen_type) { |
474fc5fa |
213 | global $boxes, $unseen_type, $color, $unseen_cum; |
ffb1a3d9 |
214 | |
215 | /* Initialize the return value. */ |
0210ab4d |
216 | $result = array(0,0); |
ffb1a3d9 |
217 | |
218 | /* Initialize the counts for this folder. */ |
219 | $boxUnseenCount = 0; |
220 | $boxMessageCount = 0; |
221 | $totalUnseenCount = 0; |
222 | $totalMessageCount = 0; |
223 | |
224 | /* Collect the counts for this box alone. */ |
474fc5fa |
225 | $status = sqimap_status_messages($imapConnection, $boxName); |
226 | $boxUnseenCount = $status['UNSEEN']; |
227 | if ($boxUnseenCount === false) { |
a6172cd5 |
228 | return false; |
474fc5fa |
229 | } |
ffb1a3d9 |
230 | if ($unseen_type == 2) { |
474fc5fa |
231 | $boxMessageCount = $status['MESSAGES']; |
ffb1a3d9 |
232 | } |
70bf5a7f |
233 | |
22986991 |
234 | /* Initialize the total counts. */ |
235 | |
474fc5fa |
236 | if ($boxArray['collapse'] == SM_BOX_COLLAPSED && $unseen_cum) { |
ffb1a3d9 |
237 | /* Collect the counts for this boxes subfolders. */ |
238 | $curBoxLength = strlen($boxName); |
239 | $boxCount = count($boxes); |
22986991 |
240 | |
ffb1a3d9 |
241 | for ($i = 0; $i < $boxCount; ++$i) { |
242 | /* Initialize the counts for this subfolder. */ |
243 | $subUnseenCount = 0; |
244 | $subMessageCount = 0; |
245 | |
246 | /* Collect the counts for this subfolder. */ |
247 | if (($boxName != $boxes[$i]['unformatted']) |
248 | && (substr($boxes[$i]['unformatted'], 0, $curBoxLength) == $boxName) |
249 | && !in_array('noselect', $boxes[$i]['flags'])) { |
a6172cd5 |
250 | $status = sqimap_status_messages($imapConnection, $boxes[$i]['unformatted']); |
251 | $subUnseenCount = $status['UNSEEN']; |
ffb1a3d9 |
252 | if ($unseen_type == 2) { |
474fc5fa |
253 | $subMessageCount = $status['MESSAGES'];; |
70bf5a7f |
254 | } |
22986991 |
255 | /* Add the counts for this subfolder to the total. */ |
256 | $totalUnseenCount += $subUnseenCount; |
257 | $totalMessageCount += $subMessageCount; |
258 | } |
70bf5a7f |
259 | } |
22986991 |
260 | |
261 | /* Add the counts for all subfolders to that of the box. */ |
262 | $boxUnseenCount += $totalUnseenCount; |
263 | $boxMessageCount += $totalMessageCount; |
ffb1a3d9 |
264 | } |
265 | |
266 | /* And create the magic unseen count string. */ |
267 | /* Really a lot more then just the unseen count. */ |
268 | if (($unseen_type == 1) && ($boxUnseenCount > 0)) { |
22986991 |
269 | $result[0] = "($boxUnseenCount)"; |
ffb1a3d9 |
270 | } else if ($unseen_type == 2) { |
22986991 |
271 | $result[0] = "($boxUnseenCount/$boxMessageCount)"; |
ffb1a3d9 |
272 | $result[0] = "<font color=\"$color[11]\">$result[0]</font>"; |
70bf5a7f |
273 | } |
ffb1a3d9 |
274 | |
22986991 |
275 | /* Set the unseen count to return to the outside world. */ |
ffb1a3d9 |
276 | $result[1] = $boxUnseenCount; |
2d367c68 |
277 | |
ffb1a3d9 |
278 | /* Return our happy result. */ |
279 | return ($result); |
95e93571 |
280 | } |
281 | |
282 | /** |
283 | * This simple function checks if a box is another box's parent. |
284 | */ |
285 | function is_parent_box($curbox_name, $parbox_name) { |
286 | global $delimiter; |
287 | |
288 | /* Extract the name of the parent of the current box. */ |
289 | $curparts = explode($delimiter, $curbox_name); |
290 | $curname = array_pop($curparts); |
291 | $actual_parname = implode($delimiter, $curparts); |
292 | $actual_parname = substr($actual_parname,0,strlen($parbox_name)); |
293 | |
294 | /* Compare the actual with the given parent name. */ |
295 | return ($parbox_name == $actual_parname); |
296 | } |
297 | |
3170c448 |
298 | function ListBoxes ($boxes, $j=0 ) { |
f23f6a3a |
299 | global $data_dir, $username, $startmessage, $color, $unseen_notify, $unseen_type, |
324ac3c5 |
300 | $move_to_trash, $trash_folder, $collapse_folders, $imapConnection, |
a259636c |
301 | $use_icons, $icon_theme, $use_special_folder_color; |
c5a52f46 |
302 | |
ccc4580f |
303 | if (!isset($boxes) || empty($boxes)) |
304 | return; |
305 | |
e4c5976a |
306 | $pre = '<nobr>'; |
f23f6a3a |
307 | $end = ''; |
308 | $collapse = false; |
ccc4580f |
309 | $unseen_found = false; |
6c8fee24 |
310 | $unseen = 0; |
e4c5976a |
311 | |
ccc4580f |
312 | $mailbox = $boxes->mailboxname_full; |
313 | $leader = '<tt>'; |
314 | $leader .= str_repeat(' ',$j); |
315 | $mailboxURL = urlencode($mailbox); |
6c8fee24 |
316 | |
ccc4580f |
317 | /* get unseen/total messages information */ |
318 | /* Only need to display info when option is set */ |
319 | if (isset($unseen_notify) && ($unseen_notify > 1) && |
320 | (($boxes->unseen !== false) || ($boxes->total !== false))) { |
e4c5976a |
321 | |
ccc4580f |
322 | if ($boxes->unseen !== false) |
323 | $unseen = $boxes->unseen; |
dcc1cc82 |
324 | |
ccc4580f |
325 | /* |
326 | Should only display unseen info if the folder is inbox |
327 | or you set the option for all folders |
328 | */ |
329 | |
330 | if ((strtolower($mailbox) == 'inbox') || ($unseen_notify == 3)) { |
331 | $unseen_string = $unseen; |
332 | |
333 | /* If users requests, display message count too */ |
334 | if (isset($unseen_type) && ($unseen_type == 2) && ($boxes->total !== false)) { |
335 | $unseen_string .= '/' . $boxes->total; |
e4c5976a |
336 | } |
ccc4580f |
337 | |
338 | $unseen_string = "<font color=\"$color[11]\">($unseen_string)</font>"; |
339 | |
340 | /* |
341 | Finally allow the script to display the values by setting a boolean. |
342 | This can only occur if the unseen count is great than 0 (if you have |
343 | unseen count only), or you have the message count too. |
344 | */ |
345 | if (($unseen > 0) || (isset($unseen_type) && ($unseen_type ==2))) { |
346 | $unseen_found = true; |
347 | } |
348 | } |
349 | } |
350 | |
351 | if (isset($boxes->mbxs[0]) && $collapse_folders) { |
352 | $collapse = getPref($data_dir, $username, 'collapse_folder_' . $mailbox); |
353 | $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED : $collapse); |
354 | |
355 | $link = '<a target="left" style="text-decoration:none" ' .'href="left_main.php?'; |
356 | if ($collapse) { |
6395c46d |
357 | if ($use_icons && $icon_theme != 'none') { |
358 | $link .= "unfold=$mailboxURL\">$leader<IMG src=\"" . SM_PATH . "images/plus.png\" border=\"0\" height=\"7\" width=\"7\"> </tt>"; |
359 | } else { |
360 | $link .= "unfold=$mailboxURL\">$leader+ </tt>"; |
361 | } |
a6172cd5 |
362 | } else { |
6395c46d |
363 | if ($use_icons && $icon_theme != 'none') { |
364 | $link .= "fold=$mailboxURL\">$leader<IMG src=\"" . SM_PATH . "images/minus.png\" border=\"0\" height=\"7\" width=\"7\"> </tt>"; |
365 | } else { |
366 | $link .= "fold=$mailboxURL\">$leader- </tt>"; |
367 | } |
a6172cd5 |
368 | } |
ccc4580f |
369 | $link .= '</a>'; |
370 | $pre .= $link; |
371 | } else { |
372 | $pre.= $leader . ' </tt>'; |
373 | } |
a6172cd5 |
374 | |
ccc4580f |
375 | /* If there are unseen message, bold the line. */ |
376 | if (($move_to_trash) && ($mailbox == $trash_folder)) { |
377 | if (! isset($boxes->total)) { |
378 | $boxes->total = sqimap_status_messages($imapConnection, $mailbox); |
379 | } |
380 | if ($unseen > 0) { |
381 | $pre .= '<b>'; |
382 | } |
324ac3c5 |
383 | $pre .= "<a href=\"right_main.php?PG_SHOWALL=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\">"; |
ccc4580f |
384 | if ($unseen > 0) { |
385 | $end .= '</b>'; |
386 | } |
387 | $end .= '</a>'; |
388 | if ($boxes->total > 0) { |
e4c5976a |
389 | if ($unseen > 0) { |
390 | $pre .= '<b>'; |
391 | } |
324ac3c5 |
392 | $pre .= "<a href=\"right_main.php?PG_SHOWALL=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\">"; |
e4c5976a |
393 | if ($unseen > 0) { |
394 | $end .= '</b>'; |
395 | } |
3170c448 |
396 | /* Print unseen information. */ |
ccc4580f |
397 | if ($unseen_found) { |
3170c448 |
398 | $end .= " <small>$unseen_string</small>"; |
399 | } |
ccc4580f |
400 | $end .= "\n<small>\n" . |
401 | " (<a href=\"empty_trash.php\" style=\"text-decoration:none\">"._("purge")."</a>)" . |
402 | "</small>"; |
e4c5976a |
403 | } |
ccc4580f |
404 | } else { |
405 | if (!$boxes->is_noselect) { |
406 | if ($unseen > 0) { |
407 | $pre .= '<b>'; |
408 | } |
324ac3c5 |
409 | $pre .= "<a href=\"right_main.php?PG_SHOWALL=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\">"; |
ccc4580f |
410 | if ($unseen > 0) { |
411 | $end .= '</b>'; |
412 | } |
413 | $end .= '</a>'; |
e4c5976a |
414 | } |
ccc4580f |
415 | /* Print unseen information. */ |
416 | if ($unseen_found) { |
417 | $end .= " <small>$unseen_string</small>"; |
39027844 |
418 | } |
419 | |
ccc4580f |
420 | } |
421 | |
422 | $font = ''; |
423 | $fontend = ''; |
a259636c |
424 | if ($use_special_folder_color && $boxes->is_special) { |
ccc4580f |
425 | $font = "<font color=\"$color[11]\">"; |
426 | $fontend = "</font>"; |
427 | } |
8fc208f8 |
428 | |
429 | // let plugins fiddle with end of line |
430 | $end .= concat_hook_function('left_main_after_each_folder', |
324ac3c5 |
431 | array(isset($numMessages) ? $numMessages : '', |
8fc208f8 |
432 | $boxes->mailboxname_full, $imapConnection)); |
433 | |
ccc4580f |
434 | $end .= '</nobr>'; |
435 | |
436 | if (!$boxes->is_root) { |
304141cb |
437 | echo "" . $pre .$font. str_replace(array(' ','<','>'),array(' ','<','>'),$boxes->mailboxname_sub) .$fontend . $end. '<br />' . "\n"; |
ccc4580f |
438 | $j++; |
439 | } |
440 | |
441 | if (!$collapse || $boxes->is_root) { |
442 | for ($i = 0; $i <count($boxes->mbxs); $i++) { |
443 | listBoxes($boxes->mbxs[$i],$j); |
e4c5976a |
444 | } |
f23f6a3a |
445 | } |
446 | } |
447 | |
c8fa94cf |
448 | function ListAdvancedBoxes ($boxes, $mbx, $j='ID.0000' ) { |
f23f6a3a |
449 | global $data_dir, $username, $startmessage, $color, $unseen_notify, $unseen_type, |
a259636c |
450 | $move_to_trash, $trash_folder, $collapse_folders, $use_special_folder_color; |
f23f6a3a |
451 | |
ccc4580f |
452 | if (!isset($boxes) || empty($boxes)) |
453 | return; |
4bdcd5e0 |
454 | |
f23f6a3a |
455 | /* use_folder_images only works if the images exist in ../images */ |
c8fa94cf |
456 | $use_folder_images = true; |
f23f6a3a |
457 | |
458 | $pre = ''; |
459 | $end = ''; |
460 | $collapse = false; |
6c8fee24 |
461 | $unseen_found = false; |
462 | $unseen = 0; |
a6172cd5 |
463 | |
a6172cd5 |
464 | $mailbox = $boxes->mailboxname_full; |
465 | $mailboxURL = urlencode($mailbox); |
f23f6a3a |
466 | |
ccc4580f |
467 | /* get unseen/total messages information */ |
6c8fee24 |
468 | /* Only need to display info when option is set */ |
ccc4580f |
469 | if (isset($unseen_notify) && ($unseen_notify > 1) && |
470 | (($boxes->unseen !== false) || ($boxes->total !== false))) { |
6c8fee24 |
471 | |
51ea258b |
472 | if ($boxes->unseen !== false) |
6c8fee24 |
473 | $unseen = $boxes->unseen; |
6c8fee24 |
474 | |
ccc4580f |
475 | /* |
6c8fee24 |
476 | Should only display unseen info if the folder is inbox |
477 | or you set the option for all folders |
478 | */ |
479 | |
480 | if ((strtolower($mailbox) == 'inbox') || ($unseen_notify == 3)) { |
481 | $unseen_string = $unseen; |
482 | |
6c8fee24 |
483 | /* If users requests, display message count too */ |
ccc4580f |
484 | if (isset($unseen_type) && ($unseen_type == 2) && ($boxes->total !== false)) { |
51ea258b |
485 | $unseen_string .= '/' . $boxes->total; |
ccc4580f |
486 | } |
6c8fee24 |
487 | |
488 | $unseen_string = "<font color=\"$color[11]\">($unseen_string)</font>"; |
489 | |
490 | /* |
491 | Finally allow the script to display the values by setting a boolean. |
492 | This can only occur if the unseen count is great than 0 (if you have |
493 | unseen count only), or you have the message count too. |
494 | */ |
495 | if (($unseen > 0) || (isset($unseen_type) && ($unseen_type ==2))) { |
496 | $unseen_found = true; |
497 | } |
ccc4580f |
498 | } |
6c8fee24 |
499 | } |
a6172cd5 |
500 | |
501 | /* If there are unseen message, bold the line. */ |
502 | if ($unseen > 0) { $pre .= '<b>'; } |
503 | |
504 | /* color special boxes */ |
a259636c |
505 | if ($use_special_folder_color && $boxes->is_special) { |
4bdcd5e0 |
506 | $pre .= "<font color=\"$color[11]\">"; |
a6172cd5 |
507 | $end .= '</font>'; |
508 | } |
509 | |
510 | /* If there are unseen message, close bolding. */ |
511 | if ($unseen > 0) { $end .= '</b>'; } |
512 | |
513 | /* Print unseen information. */ |
ccc4580f |
514 | if ($unseen_found) { |
515 | $end .= " $unseen_string"; |
a6172cd5 |
516 | } |
517 | |
518 | if (($move_to_trash) && ($mailbox == $trash_folder)) { |
4bdcd5e0 |
519 | if (! isset($numMessages)) { |
a6172cd5 |
520 | $numMessages = $boxes->total; |
4bdcd5e0 |
521 | } |
324ac3c5 |
522 | $pre = "<a class=\"mbx_link\" href=\"right_main.php?PG_SHOWALL=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\">" . $pre; |
4bdcd5e0 |
523 | $end .= '</a>'; |
524 | if ($numMessages > 0) { |
a6172cd5 |
525 | $urlMailbox = urlencode($mailbox); |
d1dbd575 |
526 | $end .= "\n<small>\n" . |
dcc1cc82 |
527 | " (<a class=\"mbx_link\" href=\"empty_trash.php\">"._("purge")."</a>)" . |
a6172cd5 |
528 | "</small>"; |
4bdcd5e0 |
529 | } |
a6172cd5 |
530 | } else { |
531 | if (!$boxes->is_noselect) { /* \Noselect boxes can't be selected */ |
324ac3c5 |
532 | $pre = "<a class=\"mbx_link\" href=\"right_main.php?PG_SHOWALL=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\">" . $pre; |
4bdcd5e0 |
533 | $end .= '</a>'; |
a6172cd5 |
534 | } |
535 | } |
536 | |
8fc208f8 |
537 | // let plugins fiddle with end of line |
538 | global $imapConnection; |
539 | $end .= concat_hook_function('left_main_after_each_folder', |
324ac3c5 |
540 | array(isset($numMessages) ? $numMessages : '', |
8fc208f8 |
541 | $boxes->mailboxname_full, $imapConnection)); |
542 | |
a6172cd5 |
543 | if (!$boxes->is_root) { |
544 | if ($use_folder_images) { |
ccc4580f |
545 | if ($boxes->is_inbox) { |
546 | $folder_img = '../images/inbox.png'; |
547 | } else if ($boxes->is_sent) { |
548 | $folder_img = '../images/senti.png'; |
549 | } else if ($boxes->is_trash) { |
550 | $folder_img = '../images/delitem.png'; |
551 | } else if ($boxes->is_draft) { |
552 | $folder_img = '../images/draft.png'; |
553 | } else if ($boxes->is_noinferiors) { |
554 | $folder_img = '../images/folder_noinf.png'; |
555 | } else { |
556 | $folder_img = '../images/folder.png'; |
557 | } |
558 | $folder_img = ' <img src="'.$folder_img.'" height="15" valign="center" /> '; |
559 | } else { |
560 | $folder_img = ''; |
561 | } |
a6172cd5 |
562 | if (!isset($boxes->mbxs[0])) { |
563 | echo ' ' . html_tag( 'div', |
304141cb |
564 | '<tt>'. $pre . $folder_img . '</tt>'. str_replace(array(' ','<','>'),array(' ','<','>'),$boxes->mailboxname_sub) . $end, |
3170c448 |
565 | 'left', '', 'class="mbx_sub" id="' .$j. '"' ) . "\n"; |
ccc4580f |
566 | } else { |
a6172cd5 |
567 | /* get collapse information */ |
3170c448 |
568 | if ($collapse_folders) { |
569 | $form_entry = $j.'F'; |
570 | if (isset($mbx) && isset($mbx[$form_entry])) { |
571 | $collapse = $mbx[$form_entry]; |
572 | setPref($data_dir, $username, 'collapse_folder_'.$boxes->mailboxname_full , $collapse ? SM_BOX_COLLAPSED : SM_BOX_UNCOLLAPSED); |
ccc4580f |
573 | } else { |
3170c448 |
574 | $collapse = getPref($data_dir, $username, 'collapse_folder_' . $mailbox); |
575 | $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED : $collapse); |
576 | } |
577 | $img_src = ($collapse ? '../images/plus.png' : '../images/minus.png'); |
578 | $collapse_link = '<a href="javascript:void(0)">'." <img src=\"$img_src\" border=\"1\" id=$j onclick=\"hidechilds(this)\" style=\"cursor:hand\" /></a>"; |
ccc4580f |
579 | } else { |
3170c448 |
580 | $collapse_link=''; |
ccc4580f |
581 | } |
582 | echo ' ' . html_tag( 'div', |
a6172cd5 |
583 | $collapse_link . $pre . $folder_img . ' '. $boxes->mailboxname_sub . $end , |
3170c448 |
584 | 'left', '', 'class="mbx_par" id="' .$j. 'P"' ) . "\n"; |
ccc4580f |
585 | echo ' <input type="hidden" name="mbx['.$j. 'F]" value="'.$collapse.'" id="mbx['.$j.'F]" />'."\n"; |
a6172cd5 |
586 | } |
587 | } |
a6172cd5 |
588 | |
4bdcd5e0 |
589 | $visible = ($collapse ? ' style="display:none"' : ' style="display:block"'); |
590 | if (isset($boxes->mbxs[0]) && !$boxes->is_root) /* mailbox contains childs */ |
591 | echo html_tag( 'div', '', 'left', '', 'class="par_area" id='.$j.'.0000 '. $visible ) . "\n"; |
a6172cd5 |
592 | |
4bdcd5e0 |
593 | if ($j !='ID.0000') |
594 | $j = $j .'.0000'; |
595 | for ($i = 0; $i <count($boxes->mbxs); $i++) { |
596 | $j++; |
597 | ListAdvancedBoxes($boxes->mbxs[$i],$mbx,$j); |
f23f6a3a |
598 | } |
4bdcd5e0 |
599 | if (isset($boxes->mbxs[0]) && !$boxes->is_root) |
600 | echo '</div>'."\n\n"; |
f23f6a3a |
601 | } |
602 | |
603 | |
604 | |
95e93571 |
605 | |
606 | /* -------------------- MAIN ------------------------ */ |
607 | |
f38b7cf0 |
608 | /* get globals */ |
609 | sqgetGlobalVar('username', $username, SQ_SESSION); |
610 | sqgetGlobalVar('key', $key, SQ_COOKIE); |
611 | sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION); |
612 | sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION); |
a32985a5 |
613 | |
f38b7cf0 |
614 | sqgetGlobalVar('fold', $fold, SQ_GET); |
615 | sqgetGlobalVar('unfold', $unfold, SQ_GET); |
616 | |
617 | /* end globals */ |
95e93571 |
618 | |
619 | // open a connection on the imap port (143) |
620 | $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 10); // the 10 is to hide the output |
621 | |
f43c35f8 |
622 | /** |
623 | * Using stristr since older preferences may contain "None" and "none". |
624 | */ |
625 | if (isset($left_refresh) && ($left_refresh != '') && |
d68323ff |
626 | !stristr($left_refresh, 'none')){ |
627 | $xtra = "\n<meta http-equiv=\"Expires\" content=\"Thu, 01 Dec 1994 16:00:00 GMT\" />\n" . |
628 | "<meta http-equiv=\"Pragma\" content=\"no-cache\" />\n". |
dcc1cc82 |
629 | "<meta http-equiv=\"REFRESH\" content=\"$left_refresh;URL=left_main.php\" />\n"; |
95e93571 |
630 | } else { |
631 | $xtra = ''; |
632 | } |
633 | |
f23f6a3a |
634 | /** |
a6172cd5 |
635 | * $advanced_tree and $oldway are boolean vars which are default set to default |
636 | * SM behaviour. |
c72be5a6 |
637 | * Setting $oldway to false causes left_main.php to use the new experimental |
f23f6a3a |
638 | * way of getting the mailbox-tree. |
a6172cd5 |
639 | * Setting $advanced tree to true causes SM to display a experimental |
f23f6a3a |
640 | * mailbox-tree with dhtml behaviour. |
a6172cd5 |
641 | * It only works on browsers which supports css and javascript. The used |
c72be5a6 |
642 | * javascript is experimental and doesn't support all browsers. |
643 | * It has been tested on IE6 an Konquerer 3.0.0-2. |
644 | * It is now tested and working on: (please test and update this list) |
645 | * Windows: IE 5.5 SP2, IE 6 SP1, Gecko based (Mozilla, Firebird) and Opera7 |
646 | * XWindow: ? |
647 | * Mac: ? |
f23f6a3a |
648 | * In the function ListAdvancedBoxes there is another var $use_folder_images. |
649 | * setting this to true is only usefull if the images exists in ../images. |
a6172cd5 |
650 | * |
f23f6a3a |
651 | * Feel free to experiment with the code and report bugs and enhancements |
652 | * to marc@its-projects.nl |
a6172cd5 |
653 | **/ |
f23f6a3a |
654 | |
78e5377d |
655 | /* set this to true if you want to see a nicer mailboxtree */ |
656 | if (! isset($advanced_tree) || $advanced_tree=="" ) { |
ccc4580f |
657 | $advanced_tree=false; |
658 | } |
78e5377d |
659 | /* default SM behaviour */ |
660 | if (! isset($oldway) || $oldway=="" ) { |
ccc4580f |
661 | $oldway=false; |
662 | } |
f23f6a3a |
663 | |
664 | if ($advanced_tree) { |
665 | $xtra .= <<<ECHO |
599038d5 |
666 | <script language="Javascript" TYPE="text/javascript"> |
f23f6a3a |
667 | |
599038d5 |
668 | <!-- |
f23f6a3a |
669 | |
51ea258b |
670 | function preload() { |
671 | if (document.images) { |
672 | var treeImages = new Array; |
673 | var arguments = preload.arguments; |
674 | for (var i = 0; i<arguments.length; i++) { |
675 | treeImages[i] = new Image(); |
676 | treeImages[i].src = arguments[i]; |
677 | } |
678 | } |
679 | } |
680 | |
99034855 |
681 | var vTreeImg; |
682 | var vTreeDiv; |
683 | var vTreeSrc; |
684 | |
685 | function fTreeTimeout() { |
686 | if (vTreeDiv.readyState == "complete") |
687 | vTreeImg.src = vTreeSrc; |
688 | else |
689 | setTimeout("fTreeTimeout()", 100); |
690 | } |
691 | |
692 | function hidechilds(img) { |
693 | id = img.id + ".0000"; |
694 | form_id = "mbx[" + img.id +"F]"; |
c72be5a6 |
695 | if (document.all) { //IE, Opera7 |
99034855 |
696 | div = document.all[id]; |
697 | if (div) { |
698 | if (div.style.display == "none") { |
699 | vTreeSrc = "../images/minus.png"; |
700 | style = "block"; |
701 | value = 0; |
702 | } |
703 | else { |
704 | vTreeSrc = "../images/plus.png"; |
705 | style = "none"; |
706 | value = 1; |
a6172cd5 |
707 | } |
99034855 |
708 | vTreeImg = img; |
709 | vTreeDiv = div; |
c72be5a6 |
710 | if (typeof vTreeDiv.readyState != "undefined") //IE |
711 | setTimeout("fTreeTimeout()",100); |
712 | else //Non IE |
713 | vTreeImg.src = vTreeSrc; |
99034855 |
714 | div.style.display = style; |
715 | document.all[form_id].value = value; |
a6172cd5 |
716 | } |
99034855 |
717 | } |
c72be5a6 |
718 | else if (document.getElementById) { //Gecko |
99034855 |
719 | div = document.getElementById(id); |
720 | if (div) { |
721 | if (div.style.display == "none") { |
722 | src = "../images/minus.png"; |
723 | style = "block"; |
724 | value = 0; |
725 | } |
726 | else { |
727 | src = "../images/plus.png"; |
728 | style = "none"; |
729 | value = 1; |
a6172cd5 |
730 | } |
99034855 |
731 | div.style.display = style; |
732 | img.src = src; |
733 | document.getElementById(form_id).value = value; |
a6172cd5 |
734 | } |
51ea258b |
735 | } |
a6172cd5 |
736 | } |
a6172cd5 |
737 | |
f23f6a3a |
738 | function buttonover(el,on) { |
739 | if (!on) { |
c72be5a6 |
740 | // el.style.borderColor="$color[9]";} |
741 | el.style.background="$color[0]";} |
f23f6a3a |
742 | else { |
c72be5a6 |
743 | el.style.background="$color[9]";} |
f23f6a3a |
744 | } |
745 | |
746 | function buttonclick(el,on) { |
a6172cd5 |
747 | if (!on) { |
c72be5a6 |
748 | el.style.border="groove";} |
f23f6a3a |
749 | else { |
750 | el.style.border="ridge";} |
751 | } |
599038d5 |
752 | |
753 | function hideframe(hide) { |
a6172cd5 |
754 | |
599038d5 |
755 | ECHO; |
756 | $xtra .= " left_size = \"$left_size\";\n"; |
757 | $xtra .= <<<ECHO |
758 | if (document.all) { |
a6172cd5 |
759 | masterf = window.parent.document.all["fs1"]; |
760 | leftf = window.parent.document.all["left"]; |
761 | leftcontent = document.all["leftframe"]; |
762 | leftbutton = document.all["showf"]; |
599038d5 |
763 | } else if (document.getElementById) { |
a6172cd5 |
764 | masterf = window.parent.document.getElementById("fs1"); |
765 | leftf = window.parent.document.getElementById("left"); |
766 | leftcontent = document.getElementById("leftframe"); |
767 | leftbutton = document.getElementById("showf"); |
599038d5 |
768 | } else { |
769 | return false; |
a6172cd5 |
770 | } |
599038d5 |
771 | if(hide) { |
772 | new_col = calc_col("20"); |
773 | masterf.cols = new_col; |
a6172cd5 |
774 | document.body.scrollLeft=0; |
775 | document.body.style.overflow='hidden'; |
776 | leftcontent.style.display = 'none'; |
777 | leftbutton.style.display='block'; |
599038d5 |
778 | } else { |
779 | masterf.cols = calc_col(left_size); |
a6172cd5 |
780 | document.body.style.overflow=''; |
781 | leftbutton.style.display='none'; |
782 | leftcontent.style.display='block'; |
783 | |
599038d5 |
784 | } |
785 | } |
a6172cd5 |
786 | |
599038d5 |
787 | function calc_col(c_w) { |
788 | |
789 | ECHO; |
790 | if ($location_of_bar == 'right') { |
791 | $xtra .= ' right=true;'; |
a6172cd5 |
792 | } else { |
599038d5 |
793 | $xtra .= ' right=false;'; |
794 | } |
795 | $xtra .= "\n"; |
796 | $xtra .= <<<ECHO |
797 | if (right) { |
798 | new_col = '*,'+c_w; |
799 | } else { |
800 | new_col = c_w+',*'; |
801 | } |
802 | return new_col; |
a6172cd5 |
803 | } |
804 | |
599038d5 |
805 | function resizeframe(direction) { |
806 | if (document.all) { |
a6172cd5 |
807 | masterf = window.parent.document.all["fs1"]; |
599038d5 |
808 | } else if (document.getElementById) { |
a6172cd5 |
809 | window.parent.document.getElementById("fs1"); |
599038d5 |
810 | } else { |
811 | return false; |
812 | } |
a6172cd5 |
813 | |
599038d5 |
814 | ECHO; |
815 | if ($location_of_bar == 'right') { |
816 | $xtra .= ' colPat=/^\*,(\d+)$/;'; |
a6172cd5 |
817 | } else { |
599038d5 |
818 | $xtra .= ' colPat=/^(\d+),.*$/;'; |
819 | } |
820 | $xtra .= "\n"; |
a6172cd5 |
821 | |
599038d5 |
822 | $xtra .= <<<ECHO |
823 | old_col = masterf.cols; |
824 | colPat.exec(old_col); |
a6172cd5 |
825 | |
599038d5 |
826 | if (direction) { |
827 | new_col_width = parseInt(RegExp.$1) + 25; |
a6172cd5 |
828 | |
599038d5 |
829 | } else { |
830 | if (parseInt(RegExp.$1) > 35) { |
831 | new_col_width = parseInt(RegExp.$1) - 25; |
832 | } |
833 | } |
a6172cd5 |
834 | masterf.cols = calc_col(new_col_width); |
599038d5 |
835 | } |
836 | |
837 | //--> |
a6172cd5 |
838 | |
f23f6a3a |
839 | </script> |
840 | |
841 | ECHO; |
842 | |
843 | /* style definitions */ |
386e556f |
844 | |
f23f6a3a |
845 | $xtra .= <<<ECHO |
846 | |
d68323ff |
847 | <style type="text/css"> |
f23f6a3a |
848 | <!-- |
599038d5 |
849 | body { |
850 | margin: 0px 0px 0px 0px; |
851 | padding: 5px 5px 5px 5px; |
852 | } |
c8fa94cf |
853 | |
f23f6a3a |
854 | .button { |
855 | border:outset; |
c72be5a6 |
856 | border-color: $color[9]; |
857 | background:$color[0]; |
858 | color:$color[6]; |
f23f6a3a |
859 | width:99%; |
860 | heigth:99%; |
861 | } |
862 | |
863 | .mbx_par { |
d1dbd575 |
864 | font-size:1.0em; |
599038d5 |
865 | margin-left:4px; |
866 | margin-right:0px; |
c8fa94cf |
867 | } |
599038d5 |
868 | |
c8fa94cf |
869 | a.mbx_link { |
870 | text-decoration: none; |
871 | background-color: $color[0]; |
872 | display: inline; |
873 | } |
874 | |
875 | a:hover.mbx_link { |
876 | background-color: $color[9]; |
877 | } |
878 | |
879 | a.mbx_link img { |
880 | border-style: none; |
f23f6a3a |
881 | } |
882 | |
883 | .mbx_sub { |
f23f6a3a |
884 | padding-left:5px; |
599038d5 |
885 | padding-right:0px; |
f23f6a3a |
886 | margin-left:4px; |
599038d5 |
887 | margin-right:0px; |
d1dbd575 |
888 | font-size:0.9em; |
f23f6a3a |
889 | } |
890 | |
891 | .par_area { |
599038d5 |
892 | margin-top:0px; |
893 | margin-left:4px; |
894 | margin-right:0px; |
f23f6a3a |
895 | padding-left:10px; |
599038d5 |
896 | padding-bottom:5px; |
f23f6a3a |
897 | border-left: solid; |
898 | border-left-width:0.1em; |
51ea258b |
899 | border-left-color:$color[9]; |
f23f6a3a |
900 | border-bottom: solid; |
901 | border-bottom-width:0.1em; |
51ea258b |
902 | border-bottom-color:$color[9]; |
c8fa94cf |
903 | display: block; |
f23f6a3a |
904 | } |
905 | |
906 | .mailboxes { |
f23f6a3a |
907 | padding-bottom:3px; |
599038d5 |
908 | margin-right:4px; |
909 | padding-right:4px; |
910 | margin-left:4px; |
911 | padding-left:4px; |
f23f6a3a |
912 | border: groove; |
913 | border-width:0.1em; |
c72be5a6 |
914 | border-color:$color[9]; |
c8fa94cf |
915 | background: $color[0]; |
f23f6a3a |
916 | } |
917 | |
918 | --> |
919 | |
d68323ff |
920 | </style> |
f23f6a3a |
921 | |
922 | ECHO; |
923 | |
924 | } |
925 | |
dcc1cc82 |
926 | displayHtmlHeader( 'SquirrelMail', $xtra ); |
852abae7 |
927 | sqgetGlobalVar('auto_create_done',$auto_create_done,SQ_SESSION); |
95e93571 |
928 | /* If requested and not yet complete, attempt to autocreate folders. */ |
929 | if ($auto_create_special && !isset($auto_create_done)) { |
a3439b27 |
930 | $autocreate = array($sent_folder, $trash_folder, $draft_folder); |
95e93571 |
931 | foreach( $autocreate as $folder ) { |
a3439b27 |
932 | if (($folder != '') && ($folder != 'none')) { |
95e93571 |
933 | if ( !sqimap_mailbox_exists($imapConnection, $folder)) { |
934 | sqimap_mailbox_create($imapConnection, $folder, ''); |
852abae7 |
935 | } else { |
936 | //if (!sqimap_mailbox_is_subscribed($imapConnection, $folder)) { |
324ac3c5 |
937 | // check for subscription is useless and expensive just |
852abae7 |
938 | // surpress the NO response |
939 | sqimap_subscribe($imapConnection, $folder, false); |
2d367c68 |
940 | } |
ebf18afa |
941 | } |
2d367c68 |
942 | } |
a6d2e0de |
943 | |
95e93571 |
944 | /* Let the world know that autocreation is complete! Hurrah! */ |
90de1755 |
945 | $auto_create_done = TRUE; |
a32985a5 |
946 | sqsession_register($auto_create_done, 'auto_create_done'); |
95e93571 |
947 | } |
dcc1cc82 |
948 | |
949 | if ($advanced_tree) |
950 | echo "\n<body" . |
51ea258b |
951 | ' onload="preload(\'../images/minus.png\',\'../images/plus.png\')"' . |
dcc1cc82 |
952 | " bgcolor=\"$color[3]\" text=\"$color[6]\" link=\"$color[6]\" vlink=\"$color[6]\" alink=\"$color[6]\">\n"; |
953 | else |
954 | echo "\n<body bgcolor=\"$color[3]\" text=\"$color[6]\" link=\"$color[6]\" vlink=\"$color[6]\" alink=\"$color[6]\">\n"; |
955 | |
956 | do_hook('left_main_before'); |
957 | if ($advanced_tree) { |
958 | /* nice future feature, needs layout !! volunteers? */ |
959 | $right_pos = $left_size - 20; |
960 | /* echo '<div style="position:absolute;top:0;border=solid;border-width:0.1em;border-color:blue;"><div ID="hidef" style="width=20;font-size:12"><A HREF="javascript:hideframe(true)"><b><<</b></a></div>'; |
961 | echo '<div ID="showf" style="width=20;font-size:12;display:none;"><a href="javascript:hideframe(false)"><b>>></b></a></div>'; |
962 | echo '<div ID="incrf" style="width=20;font-size:12"><a href="javascript:resizeframe(true)"><b>></b></a></div>'; |
963 | echo '<div ID="decrf" style="width=20;font-size:12"><a href="javascript:resizeframe(false)"><b><</b></a></div></div>'; |
964 | echo '<div ID="leftframe"><br /><br />';*/ |
599038d5 |
965 | } |
dcc1cc82 |
966 | |
a6172cd5 |
967 | echo "\n\n" . html_tag( 'table', '', 'left', '', 'border="0" cellspacing="0" cellpadding="0" width="99%"' ) . |
968 | html_tag( 'tr' ) . |
dcc1cc82 |
969 | html_tag( 'td', '', 'left' ) . |
69319017 |
970 | html_tag( 'table', '', '', '', 'border="0" cellspacing="0" cellpadding="0"' ) . |
971 | html_tag( 'tr' ) . |
972 | html_tag( 'td', '', 'center' ) . |
973 | '<font size="4"><b>'. _("Folders") . "</b><br /></font>\n\n"; |
a6d2e0de |
974 | |
95e93571 |
975 | if ($date_format != 6) { |
976 | /* First, display the clock. */ |
977 | if ($hour_format == 1) { |
978 | $hr = 'G:i'; |
979 | if ($date_format == 4) { |
980 | $hr .= ':s'; |
a6d2e0de |
981 | } |
95e93571 |
982 | } else { |
983 | if ($date_format == 4) { |
984 | $hr = 'g:i:s a'; |
985 | } else { |
986 | $hr = 'g:i a'; |
2d367c68 |
987 | } |
988 | } |
989 | |
95e93571 |
990 | switch( $date_format ) { |
e4f5158a |
991 | case 0: |
992 | $clk = date('Y-m-d '.$hr. ' T', time()); |
993 | break; |
95e93571 |
994 | case 1: |
995 | $clk = date('m/d/y '.$hr, time()); |
996 | break; |
997 | case 2: |
998 | $clk = date('d/m/y '.$hr, time()); |
999 | break; |
1000 | case 4: |
1001 | case 5: |
1002 | $clk = date($hr, time()); |
1003 | break; |
1004 | default: |
67eb95d7 |
1005 | $clk = getDayAbrv( date( 'w', time() ) ) . date( ', ' . $hr, time() ); |
2d367c68 |
1006 | } |
95e93571 |
1007 | $clk = str_replace(' ',' ',$clk); |
1008 | |
69319017 |
1009 | echo '<nobr><small>' . str_replace(' ',' ',_("Last Refresh")) . |
1010 | ": $clk</small></nobr><br />"; |
95e93571 |
1011 | } |
1012 | |
1013 | /* Next, display the refresh button. */ |
69319017 |
1014 | echo '<nobr><small>(<a href="../src/left_main.php" target="left">'. |
1015 | _("Check mail") . '</a>)</small></nobr></td></tr></table><br />'; |
95e93571 |
1016 | |
1017 | /* Lastly, display the folder list. */ |
1018 | if ( $collapse_folders ) { |
1019 | /* If directed, collapse or uncollapse a folder. */ |
1020 | if (isset($fold)) { |
1021 | setPref($data_dir, $username, 'collapse_folder_' . $fold, SM_BOX_COLLAPSED); |
1022 | } else if (isset($unfold)) { |
1023 | setPref($data_dir, $username, 'collapse_folder_' . $unfold, SM_BOX_UNCOLLAPSED); |
1024 | } |
1025 | } |
1026 | |
c5a52f46 |
1027 | /* Get unseen/total display prefs */ |
1028 | $unseen_type = getPref( $data_dir , $username , 'unseen_type' ); |
1029 | $unseen_notify = getPref( $data_dir , $username , 'unseen_notify' ); |
1030 | |
1031 | if (!isset($unseen_type) || empty($unseen_type)) { |
1032 | if (isset($default_unseen_type) && !empty($default_unseen_type)) { |
1033 | $unseen_type = $default_unseen_type; |
1034 | } else { |
1035 | $unseen_type = 1; |
1036 | } |
1037 | } |
1038 | |
1039 | if (!isset($unseen_notify) || empty($unseen_notify)) { |
1040 | if (isset($default_unseen_notify) && !empty($default_unseen_notify)) { |
1041 | $unseen_notify = $default_unseen_notify; |
1042 | } else { |
1043 | $unseen_notify = 0; |
1044 | } |
1045 | } |
1046 | |
f23f6a3a |
1047 | if ($oldway) { /* normal behaviour SM */ |
a6172cd5 |
1048 | |
f23f6a3a |
1049 | $boxes = sqimap_mailbox_list($imapConnection); |
95e93571 |
1050 | /* Prepare do do out collapsedness and visibility computation. */ |
1051 | $curbox = 0; |
1052 | $boxcount = count($boxes); |
1053 | |
1054 | /* Compute the collapsedness and visibility of each box. */ |
90de1755 |
1055 | |
95e93571 |
1056 | while ($curbox < $boxcount) { |
1057 | $boxes[$curbox]['visible'] = TRUE; |
1058 | compute_folder_children($curbox, $boxcount); |
1059 | } |
1060 | |
1c52ba77 |
1061 | for ($i = 0; $i < count($boxes); $i++) { |
95e93571 |
1062 | if ( $boxes[$i]['visible'] ) { |
1063 | $mailbox = $boxes[$i]['formatted']; |
1064 | $mblevel = substr_count($boxes[$i]['unformatted'], $delimiter) + 1; |
1065 | |
1066 | /* Create the prefix for the folder name and link. */ |
1067 | $prefix = str_repeat(' ',$mblevel); |
1068 | if (isset($collapse_folders) && $collapse_folders && $boxes[$i]['parent']) { |
1069 | $prefix = str_replace(' ',' ',substr($prefix,0,strlen($prefix)-2)). |
1070 | create_collapse_link($i) . ' '; |
1071 | } else { |
1072 | $prefix = str_replace(' ',' ',$prefix); |
1073 | } |
d68323ff |
1074 | $line = "<nobr><tt>$prefix</tt>"; |
95e93571 |
1075 | |
1076 | /* Add the folder name and link. */ |
1c52ba77 |
1077 | if (! isset($color[15])) { |
05611cba |
1078 | $color[15] = $color[6]; |
1c52ba77 |
1079 | } |
90de1755 |
1080 | |
95e93571 |
1081 | if (in_array('noselect', $boxes[$i]['flags'])) { |
1c52ba77 |
1082 | if( isSpecialMailbox( $boxes[$i]['unformatted']) ) { |
d68323ff |
1083 | $line .= "<font color=\"$color[11]\">"; |
1c52ba77 |
1084 | } else { |
d68323ff |
1085 | $line .= "<font color=\"$color[15]\">"; |
1c52ba77 |
1086 | } |
95e93571 |
1087 | if (ereg("^( *)([^ ]*)", $mailbox, $regs)) { |
1088 | $mailbox = str_replace(' ','',$mailbox); |
1089 | $line .= str_replace(' ', ' ', $mailbox); |
2d367c68 |
1090 | } |
d68323ff |
1091 | $line .= '</font>'; |
95e93571 |
1092 | } else { |
1093 | $line .= formatMailboxName($imapConnection, $boxes[$i]); |
1094 | } |
2d367c68 |
1095 | |
95e93571 |
1096 | /* Put the final touches on our folder line. */ |
d68323ff |
1097 | $line .= "</nobr><br>\n"; |
2d367c68 |
1098 | |
95e93571 |
1099 | /* Output the line for this folder. */ |
1100 | echo $line; |
2d367c68 |
1101 | } |
95e93571 |
1102 | } |
a6172cd5 |
1103 | } else { /* expiremental code */ |
f23f6a3a |
1104 | $boxes = sqimap_mailbox_tree($imapConnection); |
1105 | if (isset($advanced_tree) && $advanced_tree) { |
dcc1cc82 |
1106 | echo '<form name="collapse" action="left_main.php" method="post" ' . |
e4c5976a |
1107 | 'enctype="multipart/form-data"'."\n"; |
b6d26135 |
1108 | echo '<small>'; |
4bdcd5e0 |
1109 | echo '<button type="submit" class="button" onmouseover="buttonover(this,true)" onmouseout="buttonover(this,false)" onmousedown="buttonclick(this,true)" onmouseup="buttonclick(this,false)">'. _("Save folder tree") .'</button><br /><br />'; |
e4c5976a |
1110 | echo '<div id="mailboxes" class="mailboxes">'."\n\n"; |
3170c448 |
1111 | sqgetGlobalVar('mbx', $mbx, SQ_POST); |
e4c5976a |
1112 | if (!isset($mbx)) $mbx=NULL; |
a6172cd5 |
1113 | ListAdvancedBoxes($boxes, $mbx); |
3170c448 |
1114 | echo '</div>'; |
1115 | echo '</small>'; |
e4c5976a |
1116 | echo '</form>'."\n"; |
f23f6a3a |
1117 | } else { |
324ac3c5 |
1118 | //sqimap_get_status_mbx_tree($imap_stream,$boxes) |
e4c5976a |
1119 | ListBoxes($boxes); |
f23f6a3a |
1120 | } |
1121 | } /* if ($oldway) else ... */ |
dcc1cc82 |
1122 | do_hook('left_main_after'); |
1123 | sqimap_logout($imapConnection); |
1124 | |
1125 | echo '</td></tr></table>' . "\n". |
1126 | "</div></body></html>\n"; |
2d367c68 |
1127 | |
dcc1cc82 |
1128 | ?> |