6 * Copyright (c) 1999-2003 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
9 * This is the code for the left bar. The left bar shows the folders
10 * available, and has cookie information.
15 /* Path for SquirrelMail required files. */
16 define('SM_PATH','../');
18 /* SquirrelMail required files. */
19 require_once(SM_PATH
. 'include/validate.php');
20 require_once(SM_PATH
. 'functions/imap.php');
21 require_once(SM_PATH
. 'functions/plugin.php');
22 require_once(SM_PATH
. 'functions/page_header.php');
23 require_once(SM_PATH
. 'functions/html.php');
25 /* These constants are used for folder stuff. */
26 define('SM_BOX_UNCOLLAPSED', 0);
27 define('SM_BOX_COLLAPSED', 1);
29 /* --------------------- FUNCTIONS ------------------------- */
31 function formatMailboxName($imapConnection, $box_array) {
33 global $folder_prefix, $trash_folder, $sent_folder,
34 $color, $move_to_sent, $move_to_trash,
35 $unseen_notify, $unseen_type, $collapse_folders,
36 $draft_folder, $save_as_draft,
37 $use_special_folder_color;
39 $real_box = $box_array['unformatted'];
40 $mailbox = str_replace(' ','',$box_array['formatted']);
41 $mailboxURL = urlencode($real_box);
43 /* Strip down the mailbox name. */
44 if (ereg("^( *)([^ ]*)$", $mailbox, $regs)) {
49 if (($unseen_notify == 2 && $real_box == 'INBOX') ||
50 $unseen_notify == 3) {
51 $status = create_unseen_string($real_box, $box_array, $imapConnection, $unseen_type );
52 if ($status !== false) {
53 list($unseen_string, $unseen) = $status;
55 list($unseen_string, $unseen) = array(_("Not available"),'');
58 list($unseen_string, $unseen) = array('','');
60 $special_color = ($use_special_folder_color && isSpecialMailbox($real_box));
62 /* Start off with a blank line. */
65 /* If there are unseen message, bold the line. */
66 if ($unseen > 0) { $line .= '<B>'; }
68 /* Create the link for this folder. */
69 if ($status !== false) {
70 $line .= '<a href="right_main.php?PG_SHOWALL=0&sort=0&startMessage=1&mailbox='.
71 $mailboxURL.'" TARGET="right" STYLE="text-decoration:none">';
74 $line .= "<font color=\"$color[11]\">";
76 if ( $mailbox == 'INBOX' ) {
79 $line .= str_replace(' ',' ',$mailbox);
81 if ($special_color == TRUE)
83 if ($status !== false) {
87 /* If there are unseen message, close bolding. */
88 if ($unseen > 0) { $line .= "</B>"; }
90 /* Print unseen information. */
91 if ($unseen_string != '') {
92 $line .= " <SMALL>$unseen_string</SMALL>";
95 /* If it's the trash folder, show a purge link when needed */
96 if (($move_to_trash) && ($real_box == $trash_folder)) {
97 if (! isset($numMessages)) {
98 $numMessages = sqimap_get_num_messages($imapConnection, $real_box);
101 if (($numMessages > 0) or (sqimap_mailbox_has_children($trash_folder))) {
102 $urlMailbox = urlencode($real_box);
103 $line .= "\n<small>\n" .
104 " (<A HREF=\"empty_trash.php\" style=\"text-decoration:none\">"._("purge")."</A>)" .
109 /* Return the final product. */
114 * Recursive function that computes the collapsed status and parent
115 * (or not parent) status of this box, and the visiblity and collapsed
116 * status and parent (or not parent) status for all children boxes.
118 function compute_folder_children(&$parbox, $boxcount) {
119 global $boxes, $data_dir, $username, $collapse_folders;
120 $nextbox = $parbox +
1;
122 /* Retreive the name for the parent box. */
123 $parbox_name = $boxes[$parbox]['unformatted'];
125 /* 'Initialize' this parent box to childless. */
126 $boxes[$parbox]['parent'] = FALSE;
128 /* Compute the collapse status for this box. */
129 if( isset($collapse_folders) && $collapse_folders ) {
130 $collapse = getPref($data_dir, $username, 'collapse_folder_' . $parbox_name);
131 $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED
: $collapse);
133 $collapse = SM_BOX_UNCOLLAPSED
;
135 $boxes[$parbox]['collapse'] = $collapse;
137 /* Otherwise, get the name of the next box. */
138 if (isset($boxes[$nextbox]['unformatted'])) {
139 $nextbox_name = $boxes[$nextbox]['unformatted'];
144 /* Compute any children boxes for this box. */
145 while (($nextbox < $boxcount) &&
146 (is_parent_box($boxes[$nextbox]['unformatted'], $parbox_name))) {
148 /* Note that this 'parent' box has at least one child. */
149 $boxes[$parbox]['parent'] = TRUE;
151 /* Compute the visiblity of this box. */
152 $boxes[$nextbox]['visible'] = ($boxes[$parbox]['visible'] &&
153 ($boxes[$parbox]['collapse'] != SM_BOX_COLLAPSED
));
155 /* Compute the visibility of any child boxes. */
156 compute_folder_children($nextbox, $boxcount);
159 /* Set the parent box to the current next box. */
164 * Create the link for a parent folder that will allow that
165 * parent folder to either be collapsed or expaned, as is
166 * currently appropriate.
168 function create_collapse_link($boxnum) {
169 global $boxes, $imapConnection, $unseen_notify, $color;
170 $mailbox = urlencode($boxes[$boxnum]['unformatted']);
172 /* Create the link for this collapse link. */
173 $link = '<a target="left" style="text-decoration:none" ' .
174 'href="left_main.php?';
175 if ($boxes[$boxnum]['collapse'] == SM_BOX_COLLAPSED
) {
176 $link .= "unfold=$mailbox\">+";
178 $link .= "fold=$mailbox\">-";
182 /* Return the finished product. */
187 * create_unseen_string:
189 * Create unseen and total message count for both this folder and
192 * @param string $boxName name of the current mailbox
193 * @param array $boxArray array for the current mailbox
194 * @param $imapConnection current imap connection in use
195 * @return array[0] unseen message string (for display)
196 * @return array[1] unseen message count
198 function create_unseen_string($boxName, $boxArray, $imapConnection, $unseen_type) {
199 global $boxes, $unseen_type, $color, $unseen_cum;
201 /* Initialize the return value. */
202 $result = array(0,0);
204 /* Initialize the counts for this folder. */
206 $boxMessageCount = 0;
207 $totalUnseenCount = 0;
208 $totalMessageCount = 0;
210 /* Collect the counts for this box alone. */
211 $status = sqimap_status_messages($imapConnection, $boxName);
212 $boxUnseenCount = $status['UNSEEN'];
213 if ($boxUnseenCount === false) {
216 if ($unseen_type == 2) {
217 $boxMessageCount = $status['MESSAGES'];
220 /* Initialize the total counts. */
222 if ($boxArray['collapse'] == SM_BOX_COLLAPSED
&& $unseen_cum) {
223 /* Collect the counts for this boxes subfolders. */
224 $curBoxLength = strlen($boxName);
225 $boxCount = count($boxes);
227 for ($i = 0; $i < $boxCount; ++
$i) {
228 /* Initialize the counts for this subfolder. */
230 $subMessageCount = 0;
232 /* Collect the counts for this subfolder. */
233 if (($boxName != $boxes[$i]['unformatted'])
234 && (substr($boxes[$i]['unformatted'], 0, $curBoxLength) == $boxName)
235 && !in_array('noselect', $boxes[$i]['flags'])) {
236 $status = sqimap_status_messages($imapConnection, $boxes[$i]['unformatted']);
237 $subUnseenCount = $status['UNSEEN'];
238 if ($unseen_type == 2) {
239 $subMessageCount = $status['MESSAGES'];;
241 /* Add the counts for this subfolder to the total. */
242 $totalUnseenCount +
= $subUnseenCount;
243 $totalMessageCount +
= $subMessageCount;
247 /* Add the counts for all subfolders to that of the box. */
248 $boxUnseenCount +
= $totalUnseenCount;
249 $boxMessageCount +
= $totalMessageCount;
252 /* And create the magic unseen count string. */
253 /* Really a lot more then just the unseen count. */
254 if (($unseen_type == 1) && ($boxUnseenCount > 0)) {
255 $result[0] = "($boxUnseenCount)";
256 } else if ($unseen_type == 2) {
257 $result[0] = "($boxUnseenCount/$boxMessageCount)";
258 $result[0] = "<font color=\"$color[11]\">$result[0]</font>";
261 /* Set the unseen count to return to the outside world. */
262 $result[1] = $boxUnseenCount;
264 /* Return our happy result. */
269 * This simple function checks if a box is another box's parent.
271 function is_parent_box($curbox_name, $parbox_name) {
274 /* Extract the name of the parent of the current box. */
275 $curparts = explode($delimiter, $curbox_name);
276 $curname = array_pop($curparts);
277 $actual_parname = implode($delimiter, $curparts);
278 $actual_parname = substr($actual_parname,0,strlen($parbox_name));
280 /* Compare the actual with the given parent name. */
281 return ($parbox_name == $actual_parname);
284 function listBoxes ($boxes, $j=0 ) {
285 global $data_dir, $username, $startmessage, $color, $unseen_notify, $unseen_type,
286 $move_to_trash, $trash_folder, $collapse_folders;
291 $mailbox = $boxes->mailboxname_full
;
293 for ($k = 0; $k < $j; $k++
) {
294 $leader.= '   ';
296 $mailboxURL = urlencode($mailbox);
298 /* get unseen/total messages information */
299 if ($boxes->unseen
) {
300 $unseen = $boxes->unseen
;
301 $unseen_string = "($unseen)";
302 if ($unseen>0) $unseen_found = TRUE;
304 $numMessages = $boxes->total
;
305 $unseen_string = "<font color=\"$color[11]\">($unseen/$numMessages)</font>";
311 if (isset($boxes->mbxs
[0]) && $collapse_folders) {
312 $collapse = getPref($data_dir, $username, 'collapse_folder_' . $mailbox);
313 $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED
: $collapse);
315 $link = '<a target="left" style="text-decoration:none" ' .'href="left_main.php?';
317 $link .= "unfold=$mailboxURL\">$leader + ";
319 $link .= "fold=$mailboxURL\">$leader - ";
324 $pre.= $leader . '   ';
328 /* If there are unseen message, bold the line. */
329 if ($unseen > 0) { $pre .= '<B>'; }
331 if (($move_to_trash) && ($mailbox == $trash_folder)) {
332 if (! isset($numMessages)) {
333 $status = sqimap_status_messages($imapConnection, $mailbox);
334 $numMessages = $status['MESSAGES'];
337 if ($numMessages > 0) {
338 $urlMailbox = urlencode($mailbox);
339 $pre .= "\n<small>\n" .
340 " (<a href=\"empty_trash.php\" style=\"text-decoration:none\">"._("purge")."</a>)" .
344 if (!$boxes->is_noselect
) {
345 $pre .= "<a href=\"right_main.php?PG_SHOWALL=0&sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\">";
350 /* If there are unseen message, close bolding. */
351 if ($unseen > 0) { $end .= "</b>"; }
353 /* Print unseen information. */
354 if (isset($unseen_found) && $unseen_found) {
355 $end .= " <small>$unseen_string</small>";
360 if ($boxes->is_special
) {
361 $font = "<font color=\"$color[11]\">";
362 $fontend = "</font>";
365 if (!$boxes->is_root
) {
366 echo "" . $pre .$font. $boxes->mailboxname_sub
.$fontend . $end. '<br />';
369 if (!$collapse ||
$boxes->is_root
) {
370 for ($i = 0; $i <count($boxes->mbxs
); $i++
) {
371 listBoxes($boxes->mbxs
[$i],$j);
378 function ListAdvancedBoxes ($boxes, $mbx, $j='ID.0000' ) {
379 global $data_dir, $username, $startmessage, $color, $unseen_notify, $unseen_type,
380 $move_to_trash, $trash_folder, $collapse_folders;
382 /* use_folder_images only works if the images exist in ../images */
383 $use_folder_images = true;
390 $mailbox = $boxes->mailboxname_full
;
391 $mailboxURL = urlencode($mailbox);
393 /* get unseen/total messages information */
394 if ($boxes->unseen
) {
395 $unseen = $boxes->unseen
;
396 $unseen_string = "($unseen)";
397 if ($unseen>0) $unseen_found = TRUE;
399 $numMessages = $boxes->total
;
400 $unseen_string = "<font color=\"$color[11]\">($unseen/$numMessages)</font>";
404 /* If there are unseen message, bold the line. */
405 if ($unseen > 0) { $pre .= '<b>'; }
407 /* color special boxes */
408 if ($boxes->is_special
) {
409 $pre .= "<font color=\"$color[11]\">";
413 /* If there are unseen message, close bolding. */
414 if ($unseen > 0) { $end .= '</b>'; }
416 /* Print unseen information. */
417 if (isset($unseen_found) && $unseen_found) {
418 $end .= " $unseen_string";
421 if (($move_to_trash) && ($mailbox == $trash_folder)) {
422 if (! isset($numMessages)) {
423 $numMessages = $boxes->total
;
425 if ($numMessages > 0) {
426 $urlMailbox = urlencode($mailbox);
427 $pre .= "\n<small>\n" .
428 " (<a class=\"mbx_link\" href=\"empty_trash.php\">"._("purge")."</a>)" .
432 if (!$boxes->is_noselect
) { /* \Noselect boxes can't be selected */
433 $pre .= "<a class=\"mbx_link\" href=\"right_main.php?PG_SHOWALL=0&sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\">";
438 if (!$boxes->is_root
) {
439 if ($use_folder_images) {
440 if ($boxes->is_inbox
) {
441 $folder_img = '../images/inbox.gif';
442 } else if ($boxes->is_sent
) {
443 $folder_img = '../images/senti.gif';
444 } else if ($boxes->is_trash
) {
445 $folder_img = '../images/delitem.gif';
446 } else if ($boxes->is_draft
) {
447 $folder_img = '../images/draft.gif';
448 } else $folder_img = '../images/folder.gif';
449 $folder_img = ' <img src="'.$folder_img.'" height="15" valign="center" /> ';
450 } else $folder_img = '';
451 if (!isset($boxes->mbxs
[0])) {
452 echo ' ' . html_tag( 'div',
453 $pre . $folder_img . $boxes->mailboxname_sub
. $end ,
454 'left', '', 'class="mbx_sub" id="' .$j. '"' )
457 /* get collapse information */
458 if ($collapse_folders) {
459 $link = '<a target="left" style="text-decoration:none" ' .'href="left_main.php?';
460 $form_entry = $j.'F';
461 if (isset($mbx) && isset($mbx[$form_entry])) {
462 $collapse = $mbx[$form_entry];
464 setPref($data_dir, $username, 'collapse_folder_'.$boxes->mailboxname_full
, SM_BOX_COLLAPSED
);
466 setPref($data_dir, $username, 'collapse_folder_'.$boxes->mailboxname_full
, SM_BOX_UNCOLLAPSED
);
469 $collapse = getPref($data_dir, $username, 'collapse_folder_' . $mailbox);
470 $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED
: $collapse);
473 $link = '<a href="javascript:void(0)">'." <img src=\"../images/plus.gif\" border=\"1\" id=$j onclick=\"hidechilds(this)\" /></a>";
475 $link = '<a href="javascript:void(0)">'."<img src=\"../images/minus.gif\" border=\"1\" id=$j onclick=\"hidechilds(this)\" /></a>";
477 $collapse_link = $link;
478 } else $collapse_link='';
479 echo ' ' . html_tag( 'div',
480 $collapse_link . $pre . $folder_img . ' '. $boxes->mailboxname_sub
. $end ,
481 'left', '', 'class="mbx_par" id="' .$j. 'P"' )
483 echo ' <input type="hidden" name="mbx['.$j. 'F]" value="'.$collapse.'" id="mbx['.$j.'F]" />'."\n";
487 $visible = ' style="display:none;"';
489 $visible = ' style="display:block;"';
492 if (isset($boxes->mbxs
[0]) && !$boxes->is_root
) /* mailbox contains childs */
493 echo html_tag( 'div', '', 'left', '', 'class="par_area" id='.$j.'.0000 '. $visible ) . "\n";
495 if ($j !='ID.0000') {
498 for ($i = 0; $i <count($boxes->mbxs
); $i++
) {
500 listAdvancedBoxes($boxes->mbxs
[$i],$mbx,$j);
502 if (isset($boxes->mbxs
[0]) && !$boxes->is_root
) echo '</div>'."\n\n";
509 /* -------------------- MAIN ------------------------ */
511 $key = $_COOKIE['key'];
512 $onetimepad = $_SESSION['onetimepad'];
513 $username = $_SESSION['username'];
514 $delimiter = $_SESSION['delimiter'];
516 if (isset($_GET['fold'])) {
517 $fold = $_GET['fold'];
519 if (isset($_GET['unfold'])) {
520 $unfold = $_GET['unfold'];
523 // open a connection on the imap port (143)
524 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 10); // the 10 is to hide the output
527 * Using stristr since older preferences may contain "None" and "none".
529 if (isset($left_refresh) && ($left_refresh != '') &&
530 !stristr($left_refresh, 'none')){
531 $xtra = "\n<meta http-equiv=\"Expires\" content=\"Thu, 01 Dec 1994 16:00:00 GMT\" />\n" .
532 "<meta http-equiv=\"Pragma\" content=\"no-cache\" />\n".
533 "<meta http-equiv=\"REFRESH\" content=\"$left_refresh;URL=left_main.php\" />\n";
539 * $advanced_tree and $oldway are boolean vars which are default set to default
541 * Setting $oldway to false causes left_main.php to use the new experimental
542 * way of getting the mailbox-tree.
543 * Setting $advanced tree to true causes SM to display a experimental
544 * mailbox-tree with dhtml behaviour.
545 * It only works on browsers which supports css and javascript. The used
546 * javascript is experimental and doesn't support all browsers. It is tested on
547 * IE6 an Konquerer 3.0.0-2.
548 * In the function ListAdvancedBoxes there is another var $use_folder_images.
549 * setting this to true is only usefull if the images exists in ../images.
551 * Feel free to experiment with the code and report bugs and enhancements
552 * to marc@its-projects.nl
555 $advanced_tree = false; /* set this to true if you want to see a nicer mailboxtree */
556 $oldway = true; /* default SM behaviour */
558 if ($advanced_tree) {
560 <script language="Javascript" TYPE="text/javascript">
564 function hidechilds(el) {
566 form_id = "mbx[" + el.id +"F]";
568 ele = document.all[id];
570 if(ele.style.display == "none") {
571 ele.style.display = "block";
572 ele.style.visibility = "visible"
573 el.src="../images/minus.gif";
574 document.all[form_id].value=0;
576 ele.style.display = "none";
577 ele.style.visibility = "hidden"
578 el.src="../images/plus.gif";
579 document.all[form_id].value=1;
582 } else if (document.getElementById) {
583 ele = document.getElementById(id);
585 if(ele.style.display == "none") {
586 ele.style.display = "block";
587 ele.style.visibility = "visible"
588 el.src="../images/minus.gif";
589 document.getElementById(form_id).value=0;
591 ele.style.display = "none";
592 ele.style.visibility = "hidden"
593 el.src="../images/plus.gif";
594 document.getElementById(form_id).value=1;
601 if (!document.images) return;
602 var ar = new Array();
603 var arguments = preload.arguments;
604 for (var i = 0; i<arguments.length; i++) {
606 ar[i].src = arguments[i];
610 function buttonover(el,on) {
612 el.style.borderColor="blue";}
614 el.style.borderColor="orange";}
617 function buttonclick(el,on) {
619 el.style.border="groove"}
621 el.style.border="ridge";}
624 function hideframe(hide) {
627 $xtra .= " left_size = \"$left_size\";\n";
630 masterf = window.parent.document.all["fs1"];
631 leftf = window.parent.document.all["left"];
632 leftcontent = document.all["leftframe"];
633 leftbutton = document.all["showf"];
634 } else if (document.getElementById) {
635 masterf = window.parent.document.getElementById("fs1");
636 leftf = window.parent.document.getElementById("left");
637 leftcontent = document.getElementById("leftframe");
638 leftbutton = document.getElementById("showf");
643 new_col = calc_col("20");
644 masterf.cols = new_col;
645 document.body.scrollLeft=0;
646 document.body.style.overflow='hidden';
647 leftcontent.style.display = 'none';
648 leftbutton.style.display='block';
650 masterf.cols = calc_col(left_size);
651 document.body.style.overflow='';
652 leftbutton.style.display='none';
653 leftcontent.style.display='block';
658 function calc_col(c_w) {
661 if ($location_of_bar == 'right') {
662 $xtra .= ' right=true;';
664 $xtra .= ' right=false;';
676 function resizeframe(direction) {
678 masterf = window.parent.document.all["fs1"];
679 } else if (document.getElementById) {
680 window.parent.document.getElementById("fs1");
686 if ($location_of_bar == 'right') {
687 $xtra .= ' colPat=/^\*,(\d+)$/;';
689 $xtra .= ' colPat=/^(\d+),.*$/;';
694 old_col = masterf.cols;
695 colPat.exec(old_col);
698 new_col_width = parseInt(RegExp.$1) + 25;
701 if (parseInt(RegExp.$1) > 35) {
702 new_col_width = parseInt(RegExp.$1) - 25;
705 masterf.cols = calc_col(new_col_width);
714 /* style definitions */
718 <style type="text/css">
721 margin: 0px 0px 0px 0px;
722 padding: 5px 5px 5px 5px;
740 text-decoration: none;
741 background-color: $color[0];
746 background-color: $color[9];
768 border-left-width:0.1em;
769 border-left-color:blue;
770 border-bottom: solid;
771 border-bottom-width:0.1em;
772 border-bottom-color:blue;
785 background: $color[0];
799 displayHtmlHeader( 'SquirrelMail', $xtra );
801 /* If requested and not yet complete, attempt to autocreate folders. */
802 if ($auto_create_special && !isset($auto_create_done)) {
803 $autocreate = array($sent_folder, $trash_folder, $draft_folder);
804 foreach( $autocreate as $folder ) {
805 if (($folder != '') && ($folder != 'none')) {
806 if ( !sqimap_mailbox_exists($imapConnection, $folder)) {
807 sqimap_mailbox_create($imapConnection, $folder, '');
808 } else if (!sqimap_mailbox_is_subscribed($imapConnection, $folder)) {
809 sqimap_subscribe($imapConnection, $folder);
814 /* Let the world know that autocreation is complete! Hurrah! */
815 $auto_create_done = TRUE;
816 sqsession_register($auto_create_done, 'auto_create_done');
819 echo "\n<body bgcolor=\"$color[3]\" text=\"$color[6]\" link=\"$color[6]\" vlink=\"$color[6]\" alink=\"$color[6]\">\n";
821 do_hook('left_main_before');
822 if ($advanced_tree) {
823 /* nice future feature, needs layout !! volunteers? */
824 $right_pos = $left_size - 20;
825 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><<</b></a></div>';
826 echo '<div ID="showf" style="width=20;font-size:12;display:none;"><a href="javascript:hideframe(false)"><b>>></b></a></div>';
827 echo '<div ID="incrf" style="width=20;font-size:12"><a href="javascript:resizeframe(true)"><b>></b></a></div>';
828 echo '<div ID="decrf" style="width=20;font-size:12"><a href="javascript:resizeframe(false)"><b><</b></a></div></div>';
829 echo '<div ID="leftframe"><br /><br />';
832 echo "\n\n" . html_tag( 'table', '', 'left', '', 'border="0" cellspacing="0" cellpadding="0" width="99%"' ) .
834 html_tag( 'td', '', 'left' ) .
835 '<center><font size="4"><b>'. _("Folders") . "</b><br /></font>\n\n";
837 if ($date_format != 6) {
838 /* First, display the clock. */
839 if ($hour_format == 1) {
841 if ($date_format == 4) {
845 if ($date_format == 4) {
852 switch( $date_format ) {
854 $clk = date('m/d/y '.$hr, time());
857 $clk = date('d/m/y '.$hr, time());
861 $clk = date($hr, time());
864 $clk = substr( getDayName( date( 'w', time() ) ), 0, 3 ) . date( ', ' . $hr, time() );
866 $clk = str_replace(' ',' ',$clk);
868 echo '<center><small>' . str_replace(' ',' ',_("Last Refresh")) .
869 ": $clk</small></center>";
872 /* Next, display the refresh button. */
873 echo '<small>(<a href="../src/left_main.php" target="left">'.
874 _("refresh folder list") . '</a>)</small></center><br />';
876 /* Lastly, display the folder list. */
877 if ( $collapse_folders ) {
878 /* If directed, collapse or uncollapse a folder. */
880 setPref($data_dir, $username, 'collapse_folder_' . $fold, SM_BOX_COLLAPSED
);
881 } else if (isset($unfold)) {
882 setPref($data_dir, $username, 'collapse_folder_' . $unfold, SM_BOX_UNCOLLAPSED
);
886 if ($oldway) { /* normal behaviour SM */
888 $boxes = sqimap_mailbox_list($imapConnection);
889 /* Prepare do do out collapsedness and visibility computation. */
891 $boxcount = count($boxes);
893 /* Compute the collapsedness and visibility of each box. */
895 while ($curbox < $boxcount) {
896 $boxes[$curbox]['visible'] = TRUE;
897 compute_folder_children($curbox, $boxcount);
901 for ($i = 0; $i < count($boxes); $i++
) {
902 if ( $boxes[$i]['visible'] ) {
903 $mailbox = $boxes[$i]['formatted'];
904 $mblevel = substr_count($boxes[$i]['unformatted'], $delimiter) +
1;
906 /* Create the prefix for the folder name and link. */
907 $prefix = str_repeat(' ',$mblevel);
908 if (isset($collapse_folders) && $collapse_folders && $boxes[$i]['parent']) {
909 $prefix = str_replace(' ',' ',substr($prefix,0,strlen($prefix)-2)).
910 create_collapse_link($i) . ' ';
912 $prefix = str_replace(' ',' ',$prefix);
914 $line = "<nobr><tt>$prefix</tt>";
916 /* Add the folder name and link. */
917 if (! isset($color[15])) {
918 $color[15] = $color[6];
921 if (in_array('noselect', $boxes[$i]['flags'])) {
922 if( isSpecialMailbox( $boxes[$i]['unformatted']) ) {
923 $line .= "<font color=\"$color[11]\">";
925 $line .= "<font color=\"$color[15]\">";
927 if (ereg("^( *)([^ ]*)", $mailbox, $regs)) {
928 $mailbox = str_replace(' ','',$mailbox);
929 $line .= str_replace(' ', ' ', $mailbox);
933 $line .= formatMailboxName($imapConnection, $boxes[$i]);
936 /* Put the final touches on our folder line. */
937 $line .= "</nobr><br>\n";
939 /* Output the line for this folder. */
943 } else { /* expiremental code */
944 $boxes = sqimap_mailbox_tree($imapConnection);
945 if (isset($advanced_tree) && $advanced_tree) {
946 echo '<form name="collapse" action="left_main.php" method="post" ' .
947 'enctype="multipart/form-data"'."\n";
948 echo '<small><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 />';
949 echo '<div id="mailboxes" class="mailboxes">'."\n\n";
950 if (!isset($mbx)) $mbx=NULL;
951 ListAdvancedBoxes($boxes, $mbx);
952 echo '</div></small>'."\n";
957 } /* if ($oldway) else ... */
958 do_hook('left_main_after');
959 sqimap_logout($imapConnection);
961 echo '</td></tr></table>' . "\n".
962 "</div></body></html>\n";