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