Restore folder list centering to the old situation (before 3 weeks ago).
[squirrelmail.git] / src / left_main.php
1 <?php
2
3 /**
4 * left_main.php
5 *
6 * Copyright (c) 1999-2005 The SquirrelMail Project Team
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 * @version $Id$
13 * @package squirrelmail
14 */
15
16 /**
17 * Path for SquirrelMail required files.
18 * @ignore
19 */
20 define('SM_PATH','../');
21
22 /* SquirrelMail required files. */
23 require_once(SM_PATH . 'include/validate.php');
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');
28 require_once(SM_PATH . 'functions/date.php');
29
30 /* These constants are used for folder stuff. */
31 define('SM_BOX_UNCOLLAPSED', 0);
32 define('SM_BOX_COLLAPSED', 1);
33
34 /* --------------------- FUNCTIONS ------------------------- */
35
36
37 /**
38 * Recursive function to output a tree of folders.
39 * It is called on a list of boxes and iterates over that tree.
40 *
41 * @since 1.3.0
42 */
43 function ListBoxes ($boxes, $j=0 ) {
44 global $data_dir, $username, $color, $unseen_notify, $unseen_type,
45 $move_to_trash, $trash_folder, $collapse_folders, $imapConnection,
46 $use_icons, $icon_theme, $use_special_folder_color;
47
48 // stop condition
49 if (empty($boxes)) {
50 return;
51 }
52
53 $pre = '<span style="white-space: nowrap;">';
54 $end = '';
55 $collapse = false;
56 $unseen_found = false;
57 $unseen = 0;
58
59 $mailbox = $boxes->mailboxname_full;
60 $leader = str_repeat('&nbsp;&nbsp;',$j);
61 $mailboxURL = urlencode($mailbox);
62
63 /* get unseen/total messages information */
64 /* Only need to display info when option is set */
65 if (isset($unseen_notify) && ($unseen_notify > 1) &&
66 (($boxes->unseen !== false) || ($boxes->total !== false))) {
67
68 if ($boxes->unseen !== false)
69 $unseen = $boxes->unseen;
70
71 /*
72 Should only display unseen info if the folder is inbox
73 or you set the option for all folders
74 */
75
76 if ((strtolower($mailbox) == 'inbox') || ($unseen_notify == 3)) {
77 $unseen_string = $unseen;
78
79 /* If users requests, display message count too */
80 if (isset($unseen_type) && ($unseen_type == 2) && ($boxes->total !== false)) {
81 $unseen_string .= '/' . $boxes->total;
82 }
83
84 $unseen_string = "<font color=\"$color[11]\">($unseen_string)</font>";
85
86 /*
87 Finally allow the script to display the values by setting a boolean.
88 This can only occur if the unseen count is great than 0 (if you have
89 unseen count only), or you have the message count too.
90 */
91 if (($unseen > 0) || (isset($unseen_type) && ($unseen_type ==2))) {
92 $unseen_found = true;
93 }
94 }
95 }
96
97 if (isset($boxes->mbxs[0]) && $collapse_folders) {
98 $collapse = getPref($data_dir, $username, 'collapse_folder_' . $mailbox);
99 $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED : $collapse);
100
101 $link = '<a target="left" style="text-decoration:none" ' .'href="left_main.php?';
102 if ($collapse) {
103 if ($use_icons && $icon_theme != 'none') {
104 $link .= "unfold=$mailboxURL\">$leader<img src=\"" . SM_PATH . 'images/plus.png" border="0" height="7" width="7" />&nbsp;';
105 } else {
106 $link .= "unfold=$mailboxURL\">$leader+&nbsp;";
107 }
108 } else {
109 if ($use_icons && $icon_theme != 'none') {
110 $link .= "fold=$mailboxURL\">$leader<img src=\"" . SM_PATH . 'images/minus.png" border="0" height="7" width="7" />&nbsp;';
111 } else {
112 $link .= "fold=$mailboxURL\">$leader-&nbsp;";
113 }
114 }
115 $link .= '</a>';
116 $pre .= $link;
117 } else {
118 $pre.= $leader . '&nbsp;&nbsp;';
119 }
120
121 /* If there are unseen message, bold the line. */
122 if (($move_to_trash) && ($mailbox == $trash_folder)) {
123
124 if ( !is_numeric($boxes->total) ) {
125 $result = sqimap_status_messages($imapConnection, $mailbox);
126 $boxes->total = $result['MESSAGES'];
127 $boxes->unseen = $result['UNSEEN'];
128 }
129
130 $pre .= "<a href=\"right_main.php?PG_SHOWALL=0&amp;startMessage=1&amp;mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\">";
131 if ($unseen > 0) {
132 $pre .= '<b>';
133 $end .= '</b>';
134 }
135 $end .= '</a>';
136 if ($boxes->total > 0) {
137 /* Print unseen information. */
138 if ($unseen_found) {
139 $end .= "&nbsp;<small>$unseen_string</small>";
140 }
141 $end .= "\n<small>" .
142 '&nbsp;&nbsp;[<a href="empty_trash.php">'._("Purge").'</a>]'.
143 '</small>';
144 }
145 } else {
146 if (!$boxes->is_noselect) {
147 $pre .= "<a href=\"right_main.php?PG_SHOWALL=0&amp;startMessage=1&amp;mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\">";
148 if ($unseen > 0) {
149 $pre .= '<b>';
150 $end .= '</b>';
151 }
152 $end .= '</a>';
153 }
154 /* Print unseen information. */
155 if ($unseen_found) {
156 $end .= "&nbsp;<small>$unseen_string</small>";
157 }
158
159 }
160
161 $font = '';
162 $fontend = '';
163 if ($use_special_folder_color && $boxes->is_special) {
164 $font = "<font color=\"$color[11]\">";
165 $fontend = "</font>";
166 } elseif ( $boxes->is_noselect ) {
167 $font = "<font color=\"$color[15]\">";
168 $fontend = '</font>';
169 }
170
171 // let plugins fiddle with end of line
172 $end .= concat_hook_function('left_main_after_each_folder',
173 array(isset($numMessages) ? $numMessages : '',
174 $boxes->mailboxname_full, $imapConnection));
175
176 $end .= '</span>';
177
178 if (!$boxes->is_root) {
179 echo "" . $pre .$font.
180 str_replace(
181 array(' ','<','>'),
182 array('&nbsp;','&lt;','&gt;'),
183 $boxes->mailboxname_sub) .
184 $fontend . $end. '<br />' . "\n";
185 $j++;
186 }
187
188 if (!$collapse || $boxes->is_root) {
189 for ($i = 0; $i <count($boxes->mbxs); $i++) {
190 ListBoxes($boxes->mbxs[$i],$j);
191 }
192 }
193 }
194
195 function ListAdvancedBoxes ($boxes, $mbx, $j='ID.0000' ) {
196 global $data_dir, $username, $color, $unseen_notify, $unseen_type,
197 $move_to_trash, $trash_folder, $collapse_folders, $use_special_folder_color;
198
199 if (empty($boxes)) {
200 return;
201 }
202
203 /* use_folder_images only works if the images exist in ../images */
204 $use_folder_images = true;
205
206 $pre = '';
207 $end = '';
208 $collapse = false;
209 $unseen_found = false;
210 $unseen = 0;
211
212 $mailbox = $boxes->mailboxname_full;
213 $mailboxURL = urlencode($mailbox);
214
215 /* get unseen/total messages information */
216 /* Only need to display info when option is set */
217 if (isset($unseen_notify) && ($unseen_notify > 1) &&
218 (($boxes->unseen !== false) || ($boxes->total !== false))) {
219
220 if ($boxes->unseen !== false)
221 $unseen = $boxes->unseen;
222
223 /*
224 Should only display unseen info if the folder is inbox
225 or you set the option for all folders
226 */
227
228 if ((strtolower($mailbox) == 'inbox') || ($unseen_notify == 3)) {
229 $unseen_string = $unseen;
230
231 /* If users requests, display message count too */
232 if (isset($unseen_type) && ($unseen_type == 2) && ($boxes->total !== false)) {
233 $unseen_string .= '/' . $boxes->total;
234 }
235
236 $unseen_string = "<font color=\"$color[11]\">($unseen_string)</font>";
237
238 /*
239 Finally allow the script to display the values by setting a boolean.
240 This can only occur if the unseen count is great than 0 (if you have
241 unseen count only), or you have the message count too.
242 */
243 if (($unseen > 0) || (isset($unseen_type) && ($unseen_type ==2))) {
244 $unseen_found = true;
245 }
246 }
247 }
248
249 /* If there are unseen message, bold the line. */
250 if ($unseen > 0) { $pre .= '<b>'; }
251
252 /* color special boxes */
253 if ($use_special_folder_color && $boxes->is_special) {
254 $pre .= "<font color=\"$color[11]\">";
255 $end .= '</font>';
256 }
257
258 /* If there are unseen message, close bolding. */
259 if ($unseen > 0) { $end .= '</b>'; }
260
261 /* Print unseen information. */
262 if ($unseen_found) {
263 $end .= "&nbsp;$unseen_string";
264 }
265
266 if (($move_to_trash) && ($mailbox == $trash_folder)) {
267 $pre = "<a class=\"mbx_link\" href=\"right_main.php?PG_SHOWALL=0&amp;startMessage=1&amp;mailbox=$mailboxURL\" target=\"right\">" . $pre;
268 $end .= '</a>';
269 $end .= "\n<small>\n" .
270 '&nbsp;&nbsp;[<a class="mbx_link" href="empty_trash.php">'._("Purge").'</a>]'.
271 '</small>';
272 } else {
273 if (!$boxes->is_noselect) { /* \Noselect boxes can't be selected */
274 $pre = "<a class=\"mbx_link\" href=\"right_main.php?PG_SHOWALL=0&amp;startMessage=1&amp;mailbox=$mailboxURL\" target=\"right\">" . $pre;
275 $end .= '</a>';
276 }
277 }
278
279 // let plugins fiddle with end of line
280 global $imapConnection;
281 $end .= concat_hook_function('left_main_after_each_folder',
282 array(isset($numMessages) ? $numMessages : '',
283 $boxes->mailboxname_full, $imapConnection));
284
285 if (!$boxes->is_root) {
286 if ($use_folder_images) {
287 if ($boxes->is_inbox) {
288 $folder_img = '../images/inbox.png';
289 } else if ($boxes->is_sent) {
290 $folder_img = '../images/senti.png';
291 } else if ($boxes->is_trash) {
292 $folder_img = '../images/delitem.png';
293 } else if ($boxes->is_draft) {
294 $folder_img = '../images/draft.png';
295 } else if ($boxes->is_noinferiors) {
296 $folder_img = '../images/folder_noinf.png';
297 } else {
298 $folder_img = '../images/folder.png';
299 }
300 $folder_img = '&nbsp;<img src="'.$folder_img.'" height="15" />&nbsp;';
301 } else {
302 $folder_img = '';
303 }
304 if (!isset($boxes->mbxs[0])) {
305 echo ' ' . html_tag( 'div',
306 $pre . $folder_img .
307 str_replace( array(' ','<','>'),
308 array('&nbsp;','&lt;','&gt;'),
309 $boxes->mailboxname_sub) .
310 $end,
311 'left', '', 'class="mbx_sub" id="' .$j. '"' ) . "\n";
312 } else {
313 /* get collapse information */
314 if ($collapse_folders) {
315 $form_entry = $j.'F';
316 if (isset($mbx) && isset($mbx[$form_entry])) {
317 $collapse = $mbx[$form_entry];
318 setPref($data_dir, $username, 'collapse_folder_'.$boxes->mailboxname_full ,
319 $collapse ? SM_BOX_COLLAPSED : SM_BOX_UNCOLLAPSED);
320 } else {
321 $collapse = getPref($data_dir, $username, 'collapse_folder_' . $mailbox);
322 $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED : $collapse);
323 }
324 $img_src = ($collapse ? '../images/plus.png' : '../images/minus.png');
325 $collapse_link = '<a href="javascript:void(0)">' .
326 " <img src=\"$img_src\" border=\"1\" id=$j onclick=\"hidechilds(this)\" style=\"cursor:hand\" /></a>";
327 } else {
328 $collapse_link='';
329 }
330 echo ' ' . html_tag( 'div',
331 $collapse_link . $pre . $folder_img . '&nbsp;'. $boxes->mailboxname_sub . $end ,
332 'left', '', 'class="mbx_par" id="' .$j. 'P"' ) . "\n";
333 echo ' <input type="hidden" name="mbx['.$j. 'F]" value="'.$collapse.'" id="mbx['.$j.'F]" />'."\n";
334 }
335 }
336
337 $visible = ($collapse ? ' style="display:none"' : ' style="display:block"');
338 if (isset($boxes->mbxs[0]) && !$boxes->is_root) /* mailbox contains childs */
339 echo html_tag( 'div', '', 'left', '', 'class="par_area" id='.$j.'.0000 '. $visible ) . "\n";
340
341 if ($j !='ID.0000') {
342 $j = $j .'.0000';
343 }
344 for ($i = 0; $i <count($boxes->mbxs); $i++) {
345 $j++;
346 ListAdvancedBoxes($boxes->mbxs[$i],$mbx,$j);
347 }
348 if (isset($boxes->mbxs[0]) && !$boxes->is_root) {
349 echo '</div>'."\n\n";
350 }
351 }
352
353
354
355
356 /* -------------------- MAIN ------------------------ */
357
358 /* get globals */
359 sqgetGlobalVar('username', $username, SQ_SESSION);
360 sqgetGlobalVar('key', $key, SQ_COOKIE);
361 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION);
362 sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION);
363
364 sqgetGlobalVar('fold', $fold, SQ_GET);
365 sqgetGlobalVar('unfold', $unfold, SQ_GET);
366
367 /* end globals */
368
369 // open a connection on the imap port (143)
370 // why hide the output?
371 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, true);
372
373 /**
374 * Using stristr since very old preferences may contain "None" and "none".
375 */
376 if (!empty($left_refresh) &&
377 !stristr($left_refresh, 'none')){
378 $xtra = "\n<meta http-equiv=\"Expires\" content=\"Thu, 01 Dec 1994 16:00:00 GMT\" />\n" .
379 "<meta http-equiv=\"Pragma\" content=\"no-cache\" />\n".
380 "<meta http-equiv=\"REFRESH\" content=\"$left_refresh;URL=left_main.php\" />\n";
381 } else {
382 $xtra = '';
383 }
384
385 /**
386 * $advanced_tree and is a boolean var which is default set to default
387 * SM behaviour.
388 * Setting $advanced tree to true causes SM to display a experimental
389 * mailbox-tree with dhtml behaviour.
390 * It only works on browsers which supports css and javascript. The used
391 * javascript is experimental and doesn't support all browsers.
392 * It has been tested on IE6 an Konquerer 3.0.0-2.
393 * It is now tested and working on: (please test and update this list)
394 * Windows: IE 5.5 SP2, IE 6 SP1, Gecko based (Mozilla, Firebird) and Opera7
395 * XWindow: ?
396 * Mac: ?
397 * In the function ListAdvancedBoxes there is another var $use_folder_images.
398 * setting this to true is only usefull if the images exists in ../images.
399 *
400 * Feel free to experiment with the code and report bugs and enhancements
401 **/
402
403 /* set this to true if you want to see a nicer mailboxtree */
404 if (empty($advanced_tree)) {
405 $advanced_tree=false;
406 }
407
408 if ($advanced_tree) {
409 $xtra .= <<<HEREDOC
410 <script language="Javascript" type="text/javascript">
411 <!--
412 function preload() {
413 if (document.images) {
414 var treeImages = new Array;
415 var arguments = preload.arguments;
416 for (var i = 0; i<arguments.length; i++) {
417 treeImages[i] = new Image();
418 treeImages[i].src = arguments[i];
419 }
420 }
421 }
422 var vTreeImg;
423 var vTreeDiv;
424 var vTreeSrc;
425 function fTreeTimeout() {
426 if (vTreeDiv.readyState == "complete")
427 vTreeImg.src = vTreeSrc;
428 else
429 setTimeout("fTreeTimeout()", 100);
430 }
431 function hidechilds(img) {
432 id = img.id + ".0000";
433 form_id = "mbx[" + img.id +"F]";
434 if (document.all) { //IE, Opera7
435 div = document.all[id];
436 if (div) {
437 if (div.style.display == "none") {
438 vTreeSrc = "../images/minus.png";
439 style = "block";
440 value = 0;
441 }
442 else {
443 vTreeSrc = "../images/plus.png";
444 style = "none";
445 value = 1;
446 }
447 vTreeImg = img;
448 vTreeDiv = div;
449 if (typeof vTreeDiv.readyState != "undefined") //IE
450 setTimeout("fTreeTimeout()",100);
451 else //Non IE
452 vTreeImg.src = vTreeSrc;
453 div.style.display = style;
454 document.all[form_id].value = value;
455 }
456 }
457 else if (document.getElementById) { //Gecko
458 div = document.getElementById(id);
459 if (div) {
460 if (div.style.display == "none") {
461 src = "../images/minus.png";
462 style = "block";
463 value = 0;
464 }
465 else {
466 src = "../images/plus.png";
467 style = "none";
468 value = 1;
469 }
470 div.style.display = style;
471 img.src = src;
472 document.getElementById(form_id).value = value;
473 }
474 }
475 }
476 function buttonover(el,on) {
477 if (!on) {
478 el.style.background="$color[0]";}
479 else {
480 el.style.background="$color[9]";}
481 }
482 function buttonclick(el,on) {
483 if (!on) {
484 el.style.border="groove";}
485 else {
486 el.style.border="ridge";}
487 }
488 function hideframe(hide) {
489 left_size = "$left_size";
490 if (document.all) {
491 masterf = window.parent.document.all["fs1"];
492 leftf = window.parent.document.all["left"];
493 leftcontent = document.all["leftframe"];
494 leftbutton = document.all["showf"];
495 } else if (document.getElementById) {
496 masterf = window.parent.document.getElementById("fs1");
497 leftf = window.parent.document.getElementById("left");
498 leftcontent = document.getElementById("leftframe");
499 leftbutton = document.getElementById("showf");
500 } else {
501 return false;
502 }
503 if(hide) {
504 new_col = calc_col("20");
505 masterf.cols = new_col;
506 document.body.scrollLeft=0;
507 document.body.style.overflow="hidden";
508 leftcontent.style.display = "none";
509 leftbutton.style.display="block";
510 } else {
511 masterf.cols = calc_col(left_size);
512 document.body.style.overflow="";
513 leftbutton.style.display="none";
514 leftcontent.style.display="block";
515 }
516 }
517 function calc_col(c_w) {
518 HEREDOC;
519 if ($location_of_bar == 'right') {
520 $xtra .= ' right=true;';
521 } else {
522 $xtra .= ' right=false;';
523 }
524 $xtra .= <<<HEREDOC
525 if (right) {
526 new_col = '*,'+c_w;
527 } else {
528 new_col = c_w+',*';
529 }
530 return new_col;
531 }
532 function resizeframe(direction) {
533 if (document.all) {
534 masterf = window.parent.document.all["fs1"];
535 } else if (document.getElementById) {
536 window.parent.document.getElementById("fs1");
537 } else {
538 return false;
539 }
540 HEREDOC;
541 if ($location_of_bar == 'right') {
542 $xtra .= ' colPat=/^\*,(\d+)$/;';
543 } else {
544 $xtra .= ' colPat=/^(\d+),.*$/;';
545 }
546 $xtra .= <<<HEREDOC
547 old_col = masterf.cols;
548 colPat.exec(old_col);
549 if (direction) {
550 new_col_width = parseInt(RegExp.$1) + 25;
551 } else {
552 if (parseInt(RegExp.$1) > 35) {
553 new_col_width = parseInt(RegExp.$1) - 25;
554 }
555 }
556 masterf.cols = calc_col(new_col_width);
557 }
558 //-->
559 </script>
560
561 HEREDOC;
562
563 /* style definitions */
564
565 $xtra .= <<<HEREDOC
566 <style type="text/css">
567 <!--
568 body {
569 margin: 0px 0px 0px 0px;
570 padding: 5px 5px 5px 5px;
571 }
572 img {
573 vertical-align: middle;
574 }
575 .button {
576 border:outset;
577 border-color: $color[9];
578 background:$color[0];
579 color:$color[6];
580 width:99%;
581 heigth:99%;
582 }
583 .mbx_par {
584 font-size:1.0em;
585 margin-left:4px;
586 margin-right:0px;
587 white-space: nowrap;
588 }
589 a.mbx_link {
590 text-decoration: none;
591 background-color: $color[0];
592 display: inline;
593 }
594 a:hover.mbx_link {
595 background-color: $color[9];
596 }
597 a.mbx_link img {
598 border-style: none;
599 }
600 .mbx_sub {
601 padding-left:5px;
602 padding-right:0px;
603 margin-left:4px;
604 margin-right:0px;
605 font-size:0.9em;
606 white-space: nowrap;
607 }
608 .par_area {
609 margin-top:0px;
610 margin-left:4px;
611 margin-right:0px;
612 padding-left:10px;
613 padding-bottom:5px;
614 border-left: solid;
615 border-left-width:0.1em;
616 border-left-color:$color[9];
617 border-bottom: solid;
618 border-bottom-width:0.1em;
619 border-bottom-color:$color[9];
620 display: block;
621 }
622 .mailboxes {
623 padding-bottom:3px;
624 margin-right:4px;
625 padding-right:4px;
626 margin-left:4px;
627 padding-left:4px;
628 border: groove;
629 border-width:0.1em;
630 border-color:$color[9];
631 background: $color[0];
632 font-size: smaller;
633 }
634 -->
635 </style>
636
637 HEREDOC;
638 }
639
640 displayHtmlHeader( 'SquirrelMail', $xtra );
641 sqgetGlobalVar('auto_create_done',$auto_create_done,SQ_SESSION);
642 /* If requested and not yet complete, attempt to autocreate folders. */
643 if ($auto_create_special && !isset($auto_create_done)) {
644 $autocreate = array($sent_folder, $trash_folder, $draft_folder);
645 foreach( $autocreate as $folder ) {
646 if (($folder != '') && ($folder != 'none')) {
647 if ( !sqimap_mailbox_exists($imapConnection, $folder)) {
648 sqimap_mailbox_create($imapConnection, $folder, '');
649 } else {
650 // check for subscription is useless and expensive, just
651 // surpress the NO response. Unless we're on Mecury, which
652 // will just subscribe a folder again if it's already
653 // subscribed.
654 if ( strtolower($imap_server_type) != 'mercury32' ||
655 !sqimap_mailbox_is_subscribed($imapConnection, $folder) ) {
656 sqimap_subscribe($imapConnection, $folder, false);
657 }
658 }
659 }
660 }
661
662 /* Let the world know that autocreation is complete! Hurrah! */
663 $auto_create_done = TRUE;
664 sqsession_register($auto_create_done, 'auto_create_done');
665 }
666
667 if ($advanced_tree) {
668 echo "\n<body" .
669 ' onload="preload(\'../images/minus.png\',\'../images/plus.png\')"' .
670 " bgcolor=\"$color[3]\" text=\"$color[6]\" link=\"$color[6]\" vlink=\"$color[6]\" alink=\"$color[6]\">\n";
671 } else {
672 echo "\n<body bgcolor=\"$color[3]\" text=\"$color[6]\" link=\"$color[6]\" vlink=\"$color[6]\" alink=\"$color[6]\">\n";
673 }
674
675 do_hook('left_main_before');
676 if ($advanced_tree) {
677 /* nice future feature, needs layout !! volunteers? */
678 $right_pos = $left_size - 20;
679 /* 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>&lt;&lt;</b></a></div>';
680 echo '<div id="showf" style="width=20;font-size:12;display:none;"><a href="javascript:hideframe(false)"><b>&gt;&gt;</b></a></div>';
681 echo '<div id="incrf" style="width=20;font-size:12"><a href="javascript:resizeframe(true)"><b>&gt;</b></a></div>';
682 echo '<div id="decrf" style="width=20;font-size:12"><a href="javascript:resizeframe(false)"><b>&lt;</b></a></div></div>';
683 echo '<div id="leftframe"><br /><br />';*/
684 }
685
686 echo "\n\n" . html_tag( 'table', '', 'left', '', 'border="0" cellspacing="0" cellpadding="0" width="99%"' ) .
687 html_tag( 'tr' ) .
688 html_tag( 'td', '', 'left' ) .
689 html_tag( 'table', '', '', '', 'border="0" cellspacing="0" cellpadding="0"' ) .
690 html_tag( 'tr' ) .
691 html_tag( 'td', '', 'center' ) .
692 '<font size="4"><b>'. _("Folders") . "</b><br /></font>\n\n";
693
694 if ($date_format != 6) {
695 /* First, display the clock. */
696 if ($hour_format == 1) {
697 $hr = 'H:i';
698 if ($date_format == 4) {
699 $hr .= ':s';
700 }
701 } else {
702 if ($date_format == 4) {
703 $hr = 'g:i:s a';
704 } else {
705 $hr = 'g:i a';
706 }
707 }
708
709 switch( $date_format ) {
710 case 0:
711 $clk = date('Y-m-d '.$hr. ' T', time());
712 break;
713 case 1:
714 $clk = date('m/d/y '.$hr, time());
715 break;
716 case 2:
717 $clk = date('d/m/y '.$hr, time());
718 break;
719 case 4:
720 case 5:
721 $clk = date($hr, time());
722 break;
723 default:
724 $clk = getDayAbrv( date( 'w', time() ) ) . date( ', ' . $hr, time() );
725 }
726 $clk = str_replace(' ','&nbsp;',$clk);
727
728 echo '<small><span style="white-space: nowrap;">'
729 . str_replace(' ', '&nbsp;', _("Last Refresh"))
730 . ":</span><br /><span style=\"white-space: nowrap;\">$clk</span></small><br />\n";
731 }
732
733 /* Next, display the refresh button. */
734 echo '<div style="white-space: nowrap;"><small>[<a href="../src/left_main.php" target="left">'.
735 _("Check mail") . "</a>]</small></div></td></tr></table><br />\n\n";
736
737 /* Lastly, display the folder list. */
738
739 if ( $collapse_folders ) {
740 /* If directed, collapse or uncollapse a folder. */
741 if (isset($fold)) {
742 setPref($data_dir, $username, 'collapse_folder_' . $fold, SM_BOX_COLLAPSED);
743 } else if (isset($unfold)) {
744 setPref($data_dir, $username, 'collapse_folder_' . $unfold, SM_BOX_UNCOLLAPSED);
745 }
746 }
747
748 /* Get unseen/total display prefs */
749 $unseen_type = getPref( $data_dir , $username , 'unseen_type' );
750 $unseen_notify = getPref( $data_dir , $username , 'unseen_notify' );
751
752 if (empty($unseen_type)) {
753 if (!empty($default_unseen_type)) {
754 $unseen_type = $default_unseen_type;
755 } else {
756 $unseen_type = 1;
757 }
758 }
759
760 if (empty($unseen_notify)) {
761 if (!empty($default_unseen_notify)) {
762 $unseen_notify = $default_unseen_notify;
763 } else {
764 $unseen_notify = 0;
765 }
766 }
767
768 $boxes = sqimap_mailbox_tree($imapConnection);
769 if (isset($advanced_tree) && $advanced_tree) {
770 echo '<form name="collapse" action="left_main.php" method="post" ' .
771 'enctype="multipart/form-data">'."\n";
772 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 />';
773 echo '<div id="mailboxes" class="mailboxes">'."\n\n";
774 sqgetGlobalVar('mbx', $mbx, SQ_POST);
775 if (!isset($mbx)) $mbx=NULL;
776 ListAdvancedBoxes($boxes, $mbx);
777 echo '</div>';
778 echo '</form>'."\n";
779 } else {
780 ListBoxes($boxes);
781 }
782
783 do_hook('left_main_after');
784 sqimap_logout($imapConnection);
785
786 ?>
787 </td></tr></table>
788 </body></html>