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