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