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