59177427 |
1 | <?php |
895905c0 |
2 | |
35586184 |
3 | /** |
4 | * left_main.php |
5 | * |
15e6162e |
6 | * Copyright (c) 1999-2002 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 | |
15 | require_once('../src/validate.php'); |
16 | require_once('../functions/array.php'); |
17 | require_once('../functions/imap.php'); |
18 | require_once('../functions/plugin.php'); |
19 | require_once('../functions/page_header.php'); |
142499d4 |
20 | |
95e93571 |
21 | /* These constants are used for folder stuff. */ |
22 | define('SM_BOX_UNCOLLAPSED', 0); |
23 | define('SM_BOX_COLLAPSED', 1); |
a6d2e0de |
24 | |
2d367c68 |
25 | /* --------------------- FUNCTIONS ------------------------- */ |
525b7ae6 |
26 | |
95e93571 |
27 | function formatMailboxName($imapConnection, $box_array) { |
1c52ba77 |
28 | |
90de1755 |
29 | global $folder_prefix, $trash_folder, $sent_folder, |
30 | $color, $move_to_sent, $move_to_trash, |
31 | $unseen_notify, $unseen_type, $collapse_folders, |
32 | $draft_folder, $save_as_draft, |
33 | $use_special_folder_color; |
94f3a73b |
34 | |
95e93571 |
35 | $real_box = $box_array['unformatted']; |
36 | $mailbox = str_replace(' ','',$box_array['formatted']); |
37 | $mailboxURL = urlencode($real_box); |
21c3249f |
38 | |
95e93571 |
39 | /* Strip down the mailbox name. */ |
40 | if (ereg("^( *)([^ ]*)$", $mailbox, $regs)) { |
41 | $mailbox = $regs[2]; |
42 | } |
94f3a73b |
43 | |
95e93571 |
44 | $unseen = 0; |
45 | |
46 | if (($unseen_notify == 2 && $real_box == 'INBOX') || |
47 | $unseen_notify == 3) { |
48 | $unseen = sqimap_unseen_messages($imapConnection, $real_box); |
49 | if ($unseen_type == 1 && $unseen > 0) { |
50 | $unseen_string = "($unseen)"; |
90de1755 |
51 | $unseen_found = TRUE; |
95e93571 |
52 | } else if ($unseen_type == 2) { |
53 | $numMessages = sqimap_get_num_messages($imapConnection, $real_box); |
54 | $unseen_string = "<font color=\"$color[11]\">($unseen/$numMessages)</font>"; |
90de1755 |
55 | $unseen_found = TRUE; |
94f3a73b |
56 | } |
95e93571 |
57 | } |
94f3a73b |
58 | |
1c52ba77 |
59 | $special_color = ($use_special_folder_color && isSpecialMailbox( $real_box ) ); |
f7b1b3b1 |
60 | |
95e93571 |
61 | /* Start off with a blank line. */ |
62 | $line = ''; |
235a65d5 |
63 | |
95e93571 |
64 | /* If there are unseen message, bold the line. */ |
65 | if ($unseen > 0) { $line .= '<B>'; } |
a6d2e0de |
66 | |
95e93571 |
67 | /* Crate the link for this folder. */ |
cf710efe |
68 | $line .= "<A HREF=\"right_main.php?PG_SHOWALL=0&sort=0&startMessage=1&mailbox=$mailboxURL\" TARGET=\"right\" STYLE=\"text-decoration:none\">"; |
1c52ba77 |
69 | if ($special_color) { |
95e93571 |
70 | $line .= "<FONT COLOR=\"$color[11]\">"; |
1c52ba77 |
71 | } |
a551489c |
72 | if ( $mailbox == 'INBOX' ) { |
73 | $line .= _("INBOX"); |
74 | } else { |
75 | $line .= str_replace(' ',' ',$mailbox); |
76 | } |
90de1755 |
77 | if ($special_color == TRUE) |
95e93571 |
78 | $line .= "</FONT>"; |
79 | $line .= '</A>'; |
a6d2e0de |
80 | |
95e93571 |
81 | /* If there are unseen message, close bolding. */ |
82 | if ($unseen > 0) { $line .= "</B>"; } |
2d367c68 |
83 | |
95e93571 |
84 | /* Print unseen information. */ |
85 | if (isset($unseen_found) && $unseen_found) { |
86 | $line .= " <SMALL>$unseen_string</SMALL>"; |
2016e645 |
87 | } |
88 | |
1c52ba77 |
89 | if (($move_to_trash) && ($real_box == $trash_folder)) { |
95e93571 |
90 | if (! isset($numMessages)) { |
91 | $numMessages = sqimap_get_num_messages($imapConnection, $real_box); |
a6d2e0de |
92 | } |
a6d2e0de |
93 | |
95e93571 |
94 | if ($numMessages > 0) { |
95 | $urlMailbox = urlencode($real_box); |
96 | $line .= "\n<small>\n" . |
eb3b5319 |
97 | " (<A HREF=\"empty_trash.php\" style=\"text-decoration:none\">"._("purge")."</A>)" . |
7fb54066 |
98 | "</small>"; |
a6d2e0de |
99 | } |
100 | } |
a6d2e0de |
101 | |
95e93571 |
102 | /* Return the final product. */ |
103 | return ($line); |
104 | } |
a6d2e0de |
105 | |
95e93571 |
106 | /** |
107 | * Recursive function that computes the collapsed status and parent |
108 | * (or not parent) status of this box, and the visiblity and collapsed |
109 | * status and parent (or not parent) status for all children boxes. |
110 | */ |
111 | function compute_folder_children(&$parbox, $boxcount) { |
112 | global $boxes, $data_dir, $username, $collapse_folders; |
113 | $nextbox = $parbox + 1; |
114 | |
115 | /* Retreive the name for the parent box. */ |
116 | $parbox_name = $boxes[$parbox]['unformatted']; |
117 | |
118 | /* 'Initialize' this parent box to childless. */ |
1c52ba77 |
119 | $boxes[$parbox]['parent'] = FALSE; |
95e93571 |
120 | |
121 | /* Compute the collapse status for this box. */ |
122 | if( isset($collapse_folders) && $collapse_folders ) { |
123 | $collapse = getPref($data_dir, $username, 'collapse_folder_' . $parbox_name); |
124 | $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED : $collapse); |
125 | } else { |
126 | $collapse = SM_BOX_UNCOLLAPSED; |
a6d2e0de |
127 | } |
95e93571 |
128 | $boxes[$parbox]['collapse'] = $collapse; |
2d367c68 |
129 | |
95e93571 |
130 | /* Otherwise, get the name of the next box. */ |
1c52ba77 |
131 | if (isset($boxes[$nextbox]['unformatted'])) { |
95e93571 |
132 | $nextbox_name = $boxes[$nextbox]['unformatted']; |
1c52ba77 |
133 | } else { |
95e93571 |
134 | $nextbox_name = ''; |
1c52ba77 |
135 | } |
a6d2e0de |
136 | |
95e93571 |
137 | /* Compute any children boxes for this box. */ |
138 | while (($nextbox < $boxcount) && |
139 | (is_parent_box($boxes[$nextbox]['unformatted'], $parbox_name))) { |
a6d2e0de |
140 | |
95e93571 |
141 | /* Note that this 'parent' box has at least one child. */ |
1c52ba77 |
142 | $boxes[$parbox]['parent'] = TRUE; |
a6d2e0de |
143 | |
95e93571 |
144 | /* Compute the visiblity of this box. */ |
1c52ba77 |
145 | $boxes[$nextbox]['visible'] = ($boxes[$parbox]['visible'] && |
146 | ($boxes[$parbox]['collapse'] != SM_BOX_COLLAPSED)); |
a6d2e0de |
147 | |
95e93571 |
148 | /* Compute the visibility of any child boxes. */ |
149 | compute_folder_children($nextbox, $boxcount); |
150 | } |
2d367c68 |
151 | |
95e93571 |
152 | /* Set the parent box to the current next box. */ |
153 | $parbox = $nextbox; |
154 | } |
2d367c68 |
155 | |
95e93571 |
156 | /** |
157 | * Create the link for a parent folder that will allow that |
158 | * parent folder to either be collapsed or expaned, as is |
159 | * currently appropriate. |
160 | */ |
161 | function create_collapse_link($boxnum) { |
162 | global $boxes; |
163 | $mailbox = urlencode($boxes[$boxnum]['unformatted']); |
164 | |
165 | /* Create the link for this collapse link. */ |
90de1755 |
166 | $link = '<a target="left" style="text-decoration:none" ' . |
167 | 'href="left_main.php?'; |
95e93571 |
168 | if ($boxes[$boxnum]['collapse'] == SM_BOX_COLLAPSED) { |
169 | $link .= "unfold=$mailbox\">+"; |
2d367c68 |
170 | } else { |
95e93571 |
171 | $link .= "fold=$mailbox\">-"; |
2d367c68 |
172 | } |
95e93571 |
173 | $link .= '</a>'; |
2d367c68 |
174 | |
95e93571 |
175 | /* Return the finished product. */ |
176 | return ($link); |
177 | } |
178 | |
179 | /** |
180 | * This simple function checks if a box is another box's parent. |
181 | */ |
182 | function is_parent_box($curbox_name, $parbox_name) { |
183 | global $delimiter; |
184 | |
185 | /* Extract the name of the parent of the current box. */ |
186 | $curparts = explode($delimiter, $curbox_name); |
187 | $curname = array_pop($curparts); |
188 | $actual_parname = implode($delimiter, $curparts); |
189 | $actual_parname = substr($actual_parname,0,strlen($parbox_name)); |
190 | |
191 | /* Compare the actual with the given parent name. */ |
192 | return ($parbox_name == $actual_parname); |
193 | } |
194 | |
f23f6a3a |
195 | function listBoxes ($boxes, $j=0 ) { |
196 | global $data_dir, $username, $startmessage, $color, $unseen_notify, $unseen_type, |
197 | $move_to_trash, $trash_folder, $collapse_folders; |
198 | $pre = ''; |
199 | $end = ''; |
200 | $collapse = false; |
201 | if ($boxes) { |
202 | $mailbox = $boxes->mailboxname_full; |
203 | $leader = ''; |
204 | for ($k = 0; $k < $j; $k++) { |
205 | $leader.= '   '; |
206 | } |
207 | $mailboxURL = urlencode($mailbox); |
208 | |
209 | /* get unseen/total messages information */ |
210 | if ($boxes->unseen) { |
211 | $unseen = $boxes->unseen; |
212 | $unseen_string = "($unseen)"; |
213 | if ($unseen>0) $unseen_found = TRUE; |
214 | if ($boxes->total) { |
215 | $numMessages = $boxes->total; |
216 | $unseen_string = "<font color=\"$color[11]\">($unseen/$numMessages)</font>"; |
217 | } |
218 | } else $unseen = 0; |
219 | |
220 | |
221 | |
222 | if (isset($boxes->mbxs[0]) && $collapse_folders) { |
223 | $collapse = getPref($data_dir, $username, 'collapse_folder_' . $mailbox); |
224 | $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED : $collapse); |
225 | |
226 | $link = '<a target="left" style="text-decoration:none" ' .'href="left_main.php?'; |
227 | if ($collapse) { |
228 | $link .= "unfold=$mailboxURL\">$leader + "; |
229 | } else { |
230 | $link .= "fold=$mailboxURL\">$leader - "; |
231 | } |
232 | $link .= '</a>'; |
233 | $pre .= $link; |
234 | } else { |
235 | $pre.= $leader . '   '; |
236 | } |
237 | |
238 | |
239 | /* If there are unseen message, bold the line. */ |
240 | if ($unseen > 0) { $pre .= '<B>'; } |
241 | |
242 | if (($move_to_trash) && ($mailbox == $trash_folder)) { |
243 | if (! isset($numMessages)) { |
244 | $numMessages = sqimap_get_num_messages($imapConnection, $mailbox); |
245 | } |
246 | |
247 | if ($numMessages > 0) { |
248 | $urlMailbox = urlencode($mailbox); |
249 | $pre .= "\n<small>\n" . |
250 | " (<A HREF=\"empty_trash.php\" style=\"text-decoration:none\">"._("purge")."</A>)" . |
251 | "</small>"; |
252 | } |
253 | } else { |
254 | if (!$boxes->is_noselect) { |
255 | $pre .= "<A HREF=\"right_main.php?PG_SHOWALL=0&sort=0&startMessage=1&mailbox=$mailboxURL\" TARGET=\"right\" STYLE=\"text-decoration:none\">"; |
256 | $end .= '</a>'; |
257 | } |
258 | } |
259 | |
260 | /* If there are unseen message, close bolding. */ |
261 | if ($unseen > 0) { $end .= "</B>"; } |
262 | |
263 | /* Print unseen information. */ |
264 | if (isset($unseen_found) && $unseen_found) { |
265 | $end .= " <SMALL>$unseen_string</SMALL>"; |
266 | } |
267 | |
268 | $font = ''; |
269 | $fontend = ''; |
270 | if ($boxes->is_special) { |
271 | $font = "<FONT COLOR=\"$color[11]\">"; |
272 | $fontend = "</FONT>"; |
273 | } |
274 | |
275 | if (!$boxes->is_root) { |
276 | echo "" . $pre .$font. $boxes->mailboxname_sub .$fontend . $end. '<br>'; |
277 | $j++; |
278 | } |
279 | if (!$collapse || $boxes->is_root) { |
280 | for ($i = 0; $i <count($boxes->mbxs); $i++) { |
281 | listBoxes($boxes->mbxs[$i],$j); |
282 | } |
283 | } |
284 | |
285 | } |
286 | } |
287 | |
288 | function ListAdvancedBoxes ($boxes, $mbx, $j='ID.0' ) { |
289 | global $data_dir, $username, $startmessage, $color, $unseen_notify, $unseen_type, |
290 | $move_to_trash, $trash_folder, $collapse_folders; |
291 | |
292 | /* use_folder_images only works if the images exist in ../images */ |
293 | $use_folder_images = false; |
294 | |
295 | $pre = ''; |
296 | $end = ''; |
297 | $collapse = false; |
298 | |
299 | if ($boxes) { |
300 | $mailbox = $boxes->mailboxname_full; |
301 | $mailboxURL = urlencode($mailbox); |
302 | |
303 | /* get unseen/total messages information */ |
304 | if ($boxes->unseen) { |
305 | $unseen = $boxes->unseen; |
306 | $unseen_string = "($unseen)"; |
307 | if ($unseen>0) $unseen_found = TRUE; |
308 | if ($boxes->total) { |
309 | $numMessages = $boxes->total; |
310 | $unseen_string = "<font color=\"$color[11]\">($unseen/$numMessages)</font>"; |
311 | } |
312 | } else $unseen = 0; |
313 | |
314 | |
315 | /* If there are unseen message, bold the line. */ |
316 | if ($unseen > 0) { $pre .= '<B>'; } |
317 | |
318 | if (($move_to_trash) && ($mailbox == $trash_folder)) { |
319 | if (! isset($numMessages)) { |
320 | $numMessages = $boxes->total; |
321 | } |
322 | if ($numMessages > 0) { |
323 | $urlMailbox = urlencode($mailbox); |
324 | $pre .= "\n<small>\n" . |
325 | " (<A HREF=\"empty_trash.php\" style=\"text-decoration:none\">"._("purge")."</A>)" . |
326 | "</small>"; |
327 | } |
328 | } else { |
329 | if (!$boxes->is_noselect) { /* \Noselect boxes can't be selected */ |
330 | $pre .= "<A HREF=\"right_main.php?PG_SHOWALL=0&sort=0&startMessage=1&mailbox=$mailboxURL\" TARGET=\"right\" STYLE=\"text-decoration:none\">"; |
331 | $end .= '</a>'; |
332 | } |
333 | } |
334 | |
335 | /* If there are unseen message, close bolding. */ |
336 | if ($unseen > 0) { $end .= "</B>"; } |
337 | |
338 | /* Print unseen information. */ |
339 | if (isset($unseen_found) && $unseen_found) { |
340 | $end .= " <SMALL>$unseen_string</SMALL>"; |
341 | } |
342 | |
343 | $font = ''; |
344 | $fontend = ''; |
345 | |
346 | /* color special boxes */ |
347 | if ($boxes->is_special) { |
348 | $font = "<FONT COLOR=\"$color[11]\">"; |
349 | $fontend = "</FONT>"; |
350 | } |
351 | if (!$boxes->is_root) { |
352 | if ($use_folder_images) { |
353 | if ($boxes->is_inbox) { |
354 | $folder_img = '../images/inbox.gif'; |
355 | } else if ($boxes->is_sent) { |
356 | $folder_img = '../images/senti.gif'; |
357 | } else if ($boxes->is_trash) { |
358 | $folder_img = '../images/delitem.gif'; |
359 | } else if ($boxes->is_draft) { |
360 | $folder_img = '../images/draft.gif'; |
361 | } else $folder_img = '../images/folder.gif'; |
362 | $folder_img = ' <img src="'.$folder_img.'" heigth="15" valign="center"> '; |
363 | } else $folder_img = ''; |
364 | if (!isset($boxes->mbxs[0])) { |
365 | echo ' <div class="mbx_sub" id='.$j. ' onmouseover="changerowcolor(this,true)" onmouseout="changerowcolor(this,false)">' . $folder_img .$pre .$font. $boxes->mailboxname_sub .$fontend . $end. '</div>'."\n"; |
366 | } else { |
367 | /* get collapse information */ |
368 | if ($collapse_folders) { |
369 | $link = '<a target="left" style="text-decoration:none" ' .'href="left_main.php?'; |
370 | $form_entry = $j.'F'; |
371 | if (isset($mbx) && isset($mbx[$form_entry])) { |
372 | $collapse = $mbx[$form_entry]; |
373 | if ($collapse) { |
374 | setPref($data_dir, $username, 'collapse_folder_'.$boxes->mailboxname_full , SM_BOX_COLLAPSED); |
375 | } else { |
376 | setPref($data_dir, $username, 'collapse_folder_'.$boxes->mailboxname_full , SM_BOX_UNCOLLAPSED); |
377 | } |
378 | } else { |
379 | $collapse = getPref($data_dir, $username, 'collapse_folder_' . $mailbox); |
380 | $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED : $collapse); |
381 | } |
382 | if ($collapse) { |
383 | $link = '<a href="javascript:hidechilds(this)">'." <img src=\"../images/plus.gif\" border=\"1\" id=$j onclick=\"hidechilds(this)\"></A>"; |
384 | } else { |
385 | $link = '<a href="javascript:hidechilds(this)">'."<img src=\"../images/minus.gif\" border=\"1\" id=$j onclick=\"hidechilds(this)\"></a>"; |
386 | } |
387 | $collapse_link = $link; |
388 | } else $collapse_link=''; |
389 | echo ' <div class="mbx_par" id='.$j. 'P onmouseover="changerowcolor(this,true)" onmouseout="changerowcolor(this,false)">' . $collapse_link . $folder_img .$pre. $font. '  '. $boxes->mailboxname_sub .$fontend . $end. '</div>'."\n"; |
390 | echo ' <INPUT TYPE="hidden" name=mbx['.$j. 'F] value="'.$collapse.'">'."\n"; |
391 | } |
392 | } |
393 | if ($collapse) { |
394 | $visible = ' STYLE="display:none;"'; |
395 | } else { |
396 | $visible = ' STYLE="display:inline;"'; |
397 | } |
398 | |
399 | if (isset($boxes->mbxs[0]) && !$boxes->is_root) /* mailbox contains childs */ |
400 | echo '<div class="par_area" id='.$j.'.0 '. $visible .'>'."\n"; |
401 | if ($j !='ID.0') { |
402 | $j = $j .'.0'; |
403 | } |
404 | for ($i = 0; $i <count($boxes->mbxs); $i++) { |
405 | $j++; |
406 | listAdvancedBoxes($boxes->mbxs[$i],$mbx,$j); |
407 | } |
408 | if (isset($boxes->mbxs[0]) && !$boxes->is_root ) echo '</div>'."\n\n"; |
409 | } |
410 | } |
411 | |
412 | |
413 | |
95e93571 |
414 | |
415 | /* -------------------- MAIN ------------------------ */ |
416 | |
417 | global $delimiter, $default_folder_prefix; |
418 | |
419 | // open a connection on the imap port (143) |
420 | $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 10); // the 10 is to hide the output |
421 | |
f43c35f8 |
422 | /** |
423 | * Using stristr since older preferences may contain "None" and "none". |
424 | */ |
425 | if (isset($left_refresh) && ($left_refresh != '') && |
426 | !stristr($left_refresh, "none")){ |
95e93571 |
427 | $xtra = "\n<META HTTP-EQUIV=\"Expires\" CONTENT=\"Thu, 01 Dec 1994 16:00:00 GMT\">\n" . |
428 | "<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">\n". |
429 | "<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"$left_refresh;URL=left_main.php\">\n"; |
430 | } else { |
431 | $xtra = ''; |
432 | } |
433 | |
f23f6a3a |
434 | /** |
435 | * $advanced_tree and $oldway are boolean vars which are default set to default |
436 | * SM behaviour. |
437 | * Setting $oldway to false causes left_main.php to use the new experimental |
438 | * way of getting the mailbox-tree. |
439 | * Setting $advanced tree to true causes SM to display a experimental |
440 | * mailbox-tree with dhtml behaviour. |
441 | * It only works on browsers which supports css and javascript. The used |
442 | * javascript is experimental and doesn't support all browsers. It is tested on |
443 | * IE6 an Konquerer 3.0.0-2. |
444 | * In the function ListAdvancedBoxes there is another var $use_folder_images. |
445 | * setting this to true is only usefull if the images exists in ../images. |
446 | * |
447 | * Feel free to experiment with the code and report bugs and enhancements |
448 | * to marc@its-projects.nl |
449 | **/ |
450 | |
451 | $advanced_tree = false; /* set this to true if you want to see a nicer mailboxtree */ |
452 | $oldway = true; /* default SM behaviour */ |
453 | |
454 | if ($advanced_tree) { |
455 | $xtra .= <<<ECHO |
456 | <script language="Javascript"> |
457 | |
458 | <!--' |
459 | |
460 | function hidechilds(el) { |
461 | id = el.id +".0"; |
462 | form_id = "mbx[" + el.id +"F]"; |
463 | if (document.all) { |
464 | ele = document.all[id]; |
465 | if(ele.style.display == 'none') { |
466 | ele.style.display = 'inline'; |
467 | document.all[el.id].src="../images/minus.gif"; |
468 | document.all[form_id].value=0; |
469 | } else { |
470 | ele.style.display = 'none'; |
471 | document.all[el.id].src="../images/plus.gif"; |
472 | document.all[form_id].value=1; |
473 | } |
474 | } else if (document.getElementById) { |
475 | id = el.id+".0"; |
476 | ele = document.getElementById(id); |
477 | img_ele = document.getElementById(el.id); |
478 | if(ele.style.display == 'none') { |
479 | ele.style.display = 'inline'; |
480 | img_ele.src="../images/minus.gif"; |
481 | document.getElementById(form_id).value=0; |
482 | } else { |
483 | ele.style.display = 'none'; |
484 | img_ele.src="../images/plus.gif"; |
485 | document.getElementById(form_id).value=1; |
486 | } |
487 | } |
488 | } |
489 | |
490 | function preload() { |
491 | if (!document.images) return; |
492 | var ar = new Array(); |
493 | var arguments = preload.arguments; |
494 | for (var i = 0; i<arguments.length; i++) { |
495 | ar[i] = new Image(); |
496 | ar[i].src = arguments[i]; |
497 | } |
498 | } |
499 | |
500 | function changerowcolor(el,on) { |
501 | id = el.id; |
502 | if (document.all) { |
503 | if (!on) { document.all[id].style.background="#FFFFFF"; } |
504 | else { document.all[id].style.background="#AAAAAA"; } |
505 | } else if (document.getElementById) { |
506 | if (!on) { document.getElementById(id).style.background="#FFFFFF"; } |
507 | else { document.getElementById(id).style.background="#AAAAAA"; } |
508 | } |
509 | } |
510 | |
511 | function buttonover(el,on) { |
512 | if (!on) { |
513 | el.style.borderColor="blue";} |
514 | else { |
515 | el.style.borderColor="orange";} |
516 | } |
517 | |
518 | function buttonclick(el,on) { |
519 | if (!on) { |
520 | el.style.border="groove"} |
521 | else { |
522 | el.style.border="ridge";} |
523 | } |
524 | --> |
525 | |
526 | </script> |
527 | |
528 | ECHO; |
529 | |
530 | /* style definitions */ |
531 | |
532 | $xtra .= <<<ECHO |
533 | |
534 | <STYLE> |
535 | <!-- |
536 | .button { |
537 | border:outset; |
538 | border-color:blue; |
539 | background-color:white; |
540 | width:99%; |
541 | heigth:99%; |
542 | } |
543 | |
544 | .mbx_par { |
545 | width:99%; |
546 | heigth:99%; |
547 | font-size:0.8em; |
548 | } |
549 | |
550 | .mbx_sub { |
551 | width:99%; |
552 | heigth:99%; |
553 | padding-left:5px; |
554 | margin-left:4px; |
555 | font-size:0.7em; |
556 | } |
557 | |
558 | .par_area { |
559 | margin-left:5px; |
560 | margin-right:5px; |
561 | margin-bottom:5px; |
562 | width:99%; |
563 | heigth:99%; |
564 | padding-left:10px; |
565 | padding-bottom:10px; |
566 | border-left: solid; |
567 | border-left-width:0.1em; |
568 | border-left-color:blue; |
569 | border-bottom: solid; |
570 | border-bottom-width:0.1em; |
571 | border-bottom-color:blue; |
572 | display:inline; |
573 | } |
574 | |
575 | .mailboxes { |
576 | padding-right:0.1em; |
577 | padding-bottom:3px; |
578 | width:99%; |
579 | heigth:99%; |
580 | border: groove; |
581 | border-width:0.1em; |
582 | border-color:green; |
583 | background-color:white; |
584 | } |
585 | |
586 | --> |
587 | |
588 | </STYLE> |
589 | |
590 | ECHO; |
591 | |
592 | } |
593 | |
594 | |
595 | |
596 | |
95e93571 |
597 | displayHtmlHeader( 'SquirrelMail', $xtra ); |
598 | |
599 | /* If requested and not yet complete, attempt to autocreate folders. */ |
600 | if ($auto_create_special && !isset($auto_create_done)) { |
a3439b27 |
601 | $autocreate = array($sent_folder, $trash_folder, $draft_folder); |
95e93571 |
602 | foreach( $autocreate as $folder ) { |
a3439b27 |
603 | if (($folder != '') && ($folder != 'none')) { |
95e93571 |
604 | if ( !sqimap_mailbox_exists($imapConnection, $folder)) { |
605 | sqimap_mailbox_create($imapConnection, $folder, ''); |
a3439b27 |
606 | } else if (!sqimap_mailbox_is_subscribed($imapConnection, $folder)) { |
95e93571 |
607 | sqimap_subscribe($imapConnection, $folder); |
2d367c68 |
608 | } |
ebf18afa |
609 | } |
2d367c68 |
610 | } |
a6d2e0de |
611 | |
95e93571 |
612 | /* Let the world know that autocreation is complete! Hurrah! */ |
90de1755 |
613 | $auto_create_done = TRUE; |
95e93571 |
614 | session_register('auto_create_done'); |
615 | } |
a6d2e0de |
616 | |
95e93571 |
617 | echo "\n<BODY BGCOLOR=\"$color[3]\" TEXT=\"$color[6]\" LINK=\"$color[6]\" VLINK=\"$color[6]\" ALINK=\"$color[6]\">\n"; |
a6d2e0de |
618 | |
95e93571 |
619 | do_hook('left_main_before'); |
2d367c68 |
620 | |
2d367c68 |
621 | |
95e93571 |
622 | echo '<CENTER><FONT SIZE=4><B>'. _("Folders") . "</B><BR></FONT>\n\n"; |
a6d2e0de |
623 | |
95e93571 |
624 | if ($date_format != 6) { |
625 | /* First, display the clock. */ |
626 | if ($hour_format == 1) { |
627 | $hr = 'G:i'; |
628 | if ($date_format == 4) { |
629 | $hr .= ':s'; |
a6d2e0de |
630 | } |
95e93571 |
631 | } else { |
632 | if ($date_format == 4) { |
633 | $hr = 'g:i:s a'; |
634 | } else { |
635 | $hr = 'g:i a'; |
2d367c68 |
636 | } |
637 | } |
638 | |
95e93571 |
639 | switch( $date_format ) { |
640 | case 1: |
641 | $clk = date('m/d/y '.$hr, time()); |
642 | break; |
643 | case 2: |
644 | $clk = date('d/m/y '.$hr, time()); |
645 | break; |
646 | case 4: |
647 | case 5: |
648 | $clk = date($hr, time()); |
649 | break; |
650 | default: |
fc6f062a |
651 | $clk = substr( getDayName( date( 'w', time() ) ), 0, 3 ) . date( ', ' . $hr, time() ); |
2d367c68 |
652 | } |
95e93571 |
653 | $clk = str_replace(' ',' ',$clk); |
654 | |
655 | echo '<CENTER><SMALL>' . str_replace(' ',' ',_("Last Refresh")) . |
656 | ": $clk</SMALL></CENTER>"; |
657 | } |
658 | |
659 | /* Next, display the refresh button. */ |
660 | echo '<SMALL>(<A HREF="../src/left_main.php" TARGET="left">'. |
661 | _("refresh folder list") . '</A>)</SMALL></CENTER><BR>'; |
662 | |
663 | /* Lastly, display the folder list. */ |
664 | if ( $collapse_folders ) { |
665 | /* If directed, collapse or uncollapse a folder. */ |
666 | if (isset($fold)) { |
667 | setPref($data_dir, $username, 'collapse_folder_' . $fold, SM_BOX_COLLAPSED); |
668 | } else if (isset($unfold)) { |
669 | setPref($data_dir, $username, 'collapse_folder_' . $unfold, SM_BOX_UNCOLLAPSED); |
670 | } |
671 | } |
672 | |
f23f6a3a |
673 | if ($oldway) { /* normal behaviour SM */ |
674 | |
675 | $boxes = sqimap_mailbox_list($imapConnection); |
95e93571 |
676 | /* Prepare do do out collapsedness and visibility computation. */ |
677 | $curbox = 0; |
678 | $boxcount = count($boxes); |
679 | |
680 | /* Compute the collapsedness and visibility of each box. */ |
90de1755 |
681 | |
95e93571 |
682 | while ($curbox < $boxcount) { |
683 | $boxes[$curbox]['visible'] = TRUE; |
684 | compute_folder_children($curbox, $boxcount); |
685 | } |
686 | |
90de1755 |
687 | |
1c52ba77 |
688 | for ($i = 0; $i < count($boxes); $i++) { |
95e93571 |
689 | if ( $boxes[$i]['visible'] ) { |
690 | $mailbox = $boxes[$i]['formatted']; |
691 | $mblevel = substr_count($boxes[$i]['unformatted'], $delimiter) + 1; |
692 | |
693 | /* Create the prefix for the folder name and link. */ |
694 | $prefix = str_repeat(' ',$mblevel); |
695 | if (isset($collapse_folders) && $collapse_folders && $boxes[$i]['parent']) { |
696 | $prefix = str_replace(' ',' ',substr($prefix,0,strlen($prefix)-2)). |
697 | create_collapse_link($i) . ' '; |
698 | } else { |
699 | $prefix = str_replace(' ',' ',$prefix); |
700 | } |
701 | $line = "<NOBR><TT>$prefix</TT>"; |
702 | |
703 | /* Add the folder name and link. */ |
1c52ba77 |
704 | if (! isset($color[15])) { |
05611cba |
705 | $color[15] = $color[6]; |
1c52ba77 |
706 | } |
90de1755 |
707 | |
95e93571 |
708 | if (in_array('noselect', $boxes[$i]['flags'])) { |
1c52ba77 |
709 | if( isSpecialMailbox( $boxes[$i]['unformatted']) ) { |
710 | $line .= "<FONT COLOR=\"$color[11]\">"; |
711 | } else { |
712 | $line .= "<FONT COLOR=\"$color[15]\">"; |
713 | } |
95e93571 |
714 | if (ereg("^( *)([^ ]*)", $mailbox, $regs)) { |
715 | $mailbox = str_replace(' ','',$mailbox); |
716 | $line .= str_replace(' ', ' ', $mailbox); |
2d367c68 |
717 | } |
95e93571 |
718 | $line .= '</FONT>'; |
719 | } else { |
720 | $line .= formatMailboxName($imapConnection, $boxes[$i]); |
721 | } |
2d367c68 |
722 | |
95e93571 |
723 | /* Put the final touches on our folder line. */ |
724 | $line .= "</NOBR><BR>\n"; |
2d367c68 |
725 | |
95e93571 |
726 | /* Output the line for this folder. */ |
727 | echo $line; |
2d367c68 |
728 | } |
95e93571 |
729 | } |
f23f6a3a |
730 | } else { /* expiremental code */ |
731 | $boxes = sqimap_mailbox_tree($imapConnection); |
732 | if (isset($advanced_tree) && $advanced_tree) { |
733 | echo '<FORM name=collapse action="left_main.php" METHOD=POST' . |
734 | 'ENCTYPE="multipart/form-data"'."\n"; |
735 | echo '<small><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>'; |
736 | echo '<DIV ID=mailboxes CLASS=mailboxes>'."\n\n"; |
737 | if (!isset($mbx)) $mbx=NULL; |
738 | ListAdvancedBoxes($boxes, $mbx); |
739 | echo '</div></small>'."\n"; |
740 | echo '</FORM>'."\n"; |
741 | } else { |
742 | ListBoxes($boxes); |
743 | } |
744 | } /* if ($oldway) else ... */ |
2d367c68 |
745 | |
95e93571 |
746 | do_hook('left_main_after'); |
76b684a5 |
747 | sqimap_logout($imapConnection); |
2d367c68 |
748 | |
95e93571 |
749 | echo "</BODY></HTML>\n"; |
2d367c68 |
750 | |
7fb54066 |
751 | ?> |