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