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