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