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;
38 $real_box = $box_array['unformatted'];
39 $mailbox = str_replace(' ','',$box_array['formatted']);
40 $mailboxURL = urlencode($real_box);
42 /* Strip down the mailbox name. */
43 if (ereg("^( *)([^ ]*)$", $mailbox, $regs)) {
48 if (($unseen_notify == 2 && $real_box == 'INBOX') ||
49 $unseen_notify == 3) {
50 $status = create_unseen_string($real_box, $box_array, $imapConnection, $unseen_type );
51 if ($status !== false) {
52 list($unseen_string, $unseen) = $status;
54 list($unseen_string, $unseen) = array(_("Not available"),'');
57 list($unseen_string, $unseen) = array('','');
59 $special_color = ($use_special_folder_color && isSpecialMailbox($real_box));
61 /* Start off with a blank line. */
64 /* If there are unseen message, bold the line. */
65 if ($unseen > 0) { $line .= '<B>'; }
67 /* Create the link for this folder. */
68 if ($status !== false) {
69 $line .= '<a href="right_main.php?PG_SHOWALL=0&sort=0&startMessage=1&mailbox='.
70 $mailboxURL.'" TARGET="right" STYLE="text-decoration:none">';
73 $line .= "<font color=\"$color[11]\">";
75 if ( $mailbox == 'INBOX' ) {
78 $line .= str_replace(' ',' ',$mailbox);
80 if ($special_color == TRUE)
82 if ($status !== false) {
86 /* If there are unseen message, close bolding. */
87 if ($unseen > 0) { $line .= "</B>"; }
89 /* Print unseen information. */
90 if ($unseen_string != '') {
91 $line .= " <SMALL>$unseen_string</SMALL>";
94 /* If it's the trash folder, show a purge link when needed */
95 if (($move_to_trash) && ($real_box == $trash_folder)) {
96 if (! isset($numMessages)) {
97 $numMessages = sqimap_get_num_messages($imapConnection, $real_box);
100 if (($numMessages > 0) or ($box_array['parent'] == 1)) {
101 $urlMailbox = urlencode($real_box);
102 $line .= "\n<small>\n" .
103 " (<A HREF=\"empty_trash.php\" style=\"text-decoration:none\">"._("purge")."</A>)" .
108 /* Return the final product. */
113 * Recursive function that computes the collapsed status and parent
114 * (or not parent) status of this box, and the visiblity and collapsed
115 * status and parent (or not parent) status for all children boxes.
117 function compute_folder_children(&$parbox, $boxcount) {
118 global $boxes, $data_dir, $username, $collapse_folders;
119 $nextbox = $parbox +
1;
121 /* Retreive the name for the parent box. */
122 $parbox_name = $boxes[$parbox]['unformatted'];
124 /* 'Initialize' this parent box to childless. */
125 $boxes[$parbox]['parent'] = FALSE;
127 /* Compute the collapse status for this box. */
128 if( isset($collapse_folders) && $collapse_folders ) {
129 $collapse = getPref($data_dir, $username, 'collapse_folder_' . $parbox_name);
130 $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED
: $collapse);
132 $collapse = SM_BOX_UNCOLLAPSED
;
134 $boxes[$parbox]['collapse'] = $collapse;
136 /* Otherwise, get the name of the next box. */
137 if (isset($boxes[$nextbox]['unformatted'])) {
138 $nextbox_name = $boxes[$nextbox]['unformatted'];
143 /* Compute any children boxes for this box. */
144 while (($nextbox < $boxcount) &&
145 (is_parent_box($boxes[$nextbox]['unformatted'], $parbox_name))) {
147 /* Note that this 'parent' box has at least one child. */
148 $boxes[$parbox]['parent'] = TRUE;
150 /* Compute the visiblity of this box. */
151 $boxes[$nextbox]['visible'] = ($boxes[$parbox]['visible'] &&
152 ($boxes[$parbox]['collapse'] != SM_BOX_COLLAPSED
));
154 /* Compute the visibility of any child boxes. */
155 compute_folder_children($nextbox, $boxcount);
158 /* Set the parent box to the current next box. */
163 * Create the link for a parent folder that will allow that
164 * parent folder to either be collapsed or expaned, as is
165 * currently appropriate.
167 function create_collapse_link($boxnum) {
168 global $boxes, $imapConnection, $unseen_notify, $color;
169 $mailbox = urlencode($boxes[$boxnum]['unformatted']);
171 /* Create the link for this collapse link. */
172 $link = '<a target="left" style="text-decoration:none" ' .
173 'href="left_main.php?';
174 if ($boxes[$boxnum]['collapse'] == SM_BOX_COLLAPSED
) {
175 $link .= "unfold=$mailbox\">+";
177 $link .= "fold=$mailbox\">-";
181 /* Return the finished product. */
186 * create_unseen_string:
188 * Create unseen and total message count for both this folder and
191 * @param string $boxName name of the current mailbox
192 * @param array $boxArray array for the current mailbox
193 * @param $imapConnection current imap connection in use
194 * @return array[0] unseen message string (for display)
195 * @return array[1] unseen message count
197 function create_unseen_string($boxName, $boxArray, $imapConnection, $unseen_type) {
198 global $boxes, $unseen_type, $color, $unseen_cum;
200 /* Initialize the return value. */
201 $result = array(0,0);
203 /* Initialize the counts for this folder. */
205 $boxMessageCount = 0;
206 $totalUnseenCount = 0;
207 $totalMessageCount = 0;
209 /* Collect the counts for this box alone. */
210 $status = sqimap_status_messages($imapConnection, $boxName);
211 $boxUnseenCount = $status['UNSEEN'];
212 if ($boxUnseenCount === false) {
215 if ($unseen_type == 2) {
216 $boxMessageCount = $status['MESSAGES'];
219 /* Initialize the total counts. */
221 if ($boxArray['collapse'] == SM_BOX_COLLAPSED
&& $unseen_cum) {
222 /* Collect the counts for this boxes subfolders. */
223 $curBoxLength = strlen($boxName);
224 $boxCount = count($boxes);
226 for ($i = 0; $i < $boxCount; ++
$i) {
227 /* Initialize the counts for this subfolder. */
229 $subMessageCount = 0;
231 /* Collect the counts for this subfolder. */
232 if (($boxName != $boxes[$i]['unformatted'])
233 && (substr($boxes[$i]['unformatted'], 0, $curBoxLength) == $boxName)
234 && !in_array('noselect', $boxes[$i]['flags'])) {
235 $status = sqimap_status_messages($imapConnection, $boxes[$i]['unformatted']);
236 $subUnseenCount = $status['UNSEEN'];
237 if ($unseen_type == 2) {
238 $subMessageCount = $status['MESSAGES'];;
240 /* Add the counts for this subfolder to the total. */
241 $totalUnseenCount +
= $subUnseenCount;
242 $totalMessageCount +
= $subMessageCount;
246 /* Add the counts for all subfolders to that of the box. */
247 $boxUnseenCount +
= $totalUnseenCount;
248 $boxMessageCount +
= $totalMessageCount;
251 /* And create the magic unseen count string. */
252 /* Really a lot more then just the unseen count. */
253 if (($unseen_type == 1) && ($boxUnseenCount > 0)) {
254 $result[0] = "($boxUnseenCount)";
255 } else if ($unseen_type == 2) {
256 $result[0] = "($boxUnseenCount/$boxMessageCount)";
257 $result[0] = "<font color=\"$color[11]\">$result[0]</font>";
260 /* Set the unseen count to return to the outside world. */
261 $result[1] = $boxUnseenCount;
263 /* Return our happy result. */
268 * This simple function checks if a box is another box's parent.
270 function is_parent_box($curbox_name, $parbox_name) {
273 /* Extract the name of the parent of the current box. */
274 $curparts = explode($delimiter, $curbox_name);
275 $curname = array_pop($curparts);
276 $actual_parname = implode($delimiter, $curparts);
277 $actual_parname = substr($actual_parname,0,strlen($parbox_name));
279 /* Compare the actual with the given parent name. */
280 return ($parbox_name == $actual_parname);
283 function listBoxes ($boxes, $j=0 ) {
284 global $data_dir, $username, $startmessage, $color, $unseen_notify, $unseen_type,
285 $move_to_trash, $trash_folder, $collapse_folders;
290 $mailbox = $boxes->mailboxname_full
;
292 for ($k = 0; $k < $j; $k++
) {
293 $leader.= '   ';
295 $mailboxURL = urlencode($mailbox);
297 /* get unseen/total messages information */
298 if ($boxes->unseen
) {
299 $unseen = $boxes->unseen
;
300 $unseen_string = "($unseen)";
301 if ($unseen>0) $unseen_found = TRUE;
303 $numMessages = $boxes->total
;
304 $unseen_string = "<font color=\"$color[11]\">($unseen/$numMessages)</font>";
310 if (isset($boxes->mbxs
[0]) && $collapse_folders) {
311 $collapse = getPref($data_dir, $username, 'collapse_folder_' . $mailbox);
312 $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED
: $collapse);
314 $link = '<a target="left" style="text-decoration:none" ' .'href="left_main.php?';
316 $link .= "unfold=$mailboxURL\">$leader + ";
318 $link .= "fold=$mailboxURL\">$leader - ";
323 $pre.= $leader . '   ';
327 /* If there are unseen message, bold the line. */
328 if ($unseen > 0) { $pre .= '<B>'; }
330 if (($move_to_trash) && ($mailbox == $trash_folder)) {
331 if (! isset($numMessages)) {
332 $status = sqimap_status_messages($imapConnection, $mailbox);
333 $numMessages = $status['MESSAGES'];
336 if ($numMessages > 0) {
337 $urlMailbox = urlencode($mailbox);
338 $pre .= "\n<small>\n" .
339 " (<a href=\"empty_trash.php\" style=\"text-decoration:none\">"._("purge")."</a>)" .
343 if (!$boxes->is_noselect
) {
344 $pre .= "<a href=\"right_main.php?PG_SHOWALL=0&sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\">";
349 /* If there are unseen message, close bolding. */
350 if ($unseen > 0) { $end .= "</b>"; }
352 /* Print unseen information. */
353 if (isset($unseen_found) && $unseen_found) {
354 $end .= " <small>$unseen_string</small>";
359 if ($boxes->is_special
) {
360 $font = "<font color=\"$color[11]\">";
361 $fontend = "</font>";
364 if (!$boxes->is_root
) {
365 echo "" . $pre .$font. $boxes->mailboxname_sub
.$fontend . $end. '<br />';
368 if (!$collapse ||
$boxes->is_root
) {
369 for ($i = 0; $i <count($boxes->mbxs
); $i++
) {
370 listBoxes($boxes->mbxs
[$i],$j);
377 function ListAdvancedBoxes ($boxes, $mbx, $j='ID.0000' ) {
378 global $data_dir, $username, $startmessage, $color, $unseen_notify, $unseen_type,
379 $move_to_trash, $trash_folder, $collapse_folders;
381 /* use_folder_images only works if the images exist in ../images */
382 $use_folder_images = true;
389 $mailbox = $boxes->mailboxname_full
;
390 $mailboxURL = urlencode($mailbox);
392 /* get unseen/total messages information */
393 if ($boxes->unseen
) {
394 $unseen = $boxes->unseen
;
395 $unseen_string = "($unseen)";
396 if ($unseen>0) $unseen_found = TRUE;
398 $numMessages = $boxes->total
;
399 $unseen_string = "<font color=\"$color[11]\">($unseen/$numMessages)</font>";
403 /* If there are unseen message, bold the line. */
404 if ($unseen > 0) { $pre .= '<b>'; }
406 /* color special boxes */
407 if ($boxes->is_special
) {
408 $pre .= "<font color=\"$color[11]\">";
412 /* If there are unseen message, close bolding. */
413 if ($unseen > 0) { $end .= '</b>'; }
415 /* Print unseen information. */
416 if (isset($unseen_found) && $unseen_found) {
417 $end .= " $unseen_string";
420 if (($move_to_trash) && ($mailbox == $trash_folder)) {
421 if (! isset($numMessages)) {
422 $numMessages = $boxes->total
;
424 if ($numMessages > 0) {
425 $urlMailbox = urlencode($mailbox);
426 $pre .= "\n<small>\n" .
427 " (<a class=\"mbx_link\" href=\"empty_trash.php\">"._("purge")."</a>)" .
431 if (!$boxes->is_noselect
) { /* \Noselect boxes can't be selected */
432 $pre .= "<a class=\"mbx_link\" href=\"right_main.php?PG_SHOWALL=0&sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\">";
437 if (!$boxes->is_root
) {
438 if ($use_folder_images) {
439 if ($boxes->is_inbox
) {
440 $folder_img = '../images/inbox.gif';
441 } else if ($boxes->is_sent
) {
442 $folder_img = '../images/senti.gif';
443 } else if ($boxes->is_trash
) {
444 $folder_img = '../images/delitem.gif';
445 } else if ($boxes->is_draft
) {
446 $folder_img = '../images/draft.gif';
447 } else $folder_img = '../images/folder.gif';
448 $folder_img = ' <img src="'.$folder_img.'" height="15" valign="center" /> ';
449 } else $folder_img = '';
450 if (!isset($boxes->mbxs
[0])) {
451 echo ' ' . html_tag( 'div',
452 $pre . $folder_img . $boxes->mailboxname_sub
. $end ,
453 'left', '', 'class="mbx_sub" id="' .$j. '"' )
456 /* get collapse information */
457 if ($collapse_folders) {
458 $link = '<a target="left" style="text-decoration:none" ' .'href="left_main.php?';
459 $form_entry = $j.'F';
460 if (isset($mbx) && isset($mbx[$form_entry])) {
461 $collapse = $mbx[$form_entry];
463 setPref($data_dir, $username, 'collapse_folder_'.$boxes->mailboxname_full
, SM_BOX_COLLAPSED
);
465 setPref($data_dir, $username, 'collapse_folder_'.$boxes->mailboxname_full
, SM_BOX_UNCOLLAPSED
);
468 $collapse = getPref($data_dir, $username, 'collapse_folder_' . $mailbox);
469 $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED
: $collapse);
472 $link = '<a href="javascript:void(0)">'." <img src=\"../images/plus.gif\" border=\"1\" id=$j onclick=\"hidechilds(this)\" /></a>";
474 $link = '<a href="javascript:void(0)">'."<img src=\"../images/minus.gif\" border=\"1\" id=$j onclick=\"hidechilds(this)\" /></a>";
476 $collapse_link = $link;
477 } else $collapse_link='';
478 echo ' ' . html_tag( 'div',
479 $collapse_link . $pre . $folder_img . ' '. $boxes->mailboxname_sub
. $end ,
480 'left', '', 'class="mbx_par" id="' .$j. 'P"' )
482 echo ' <input type="hidden" name="mbx['.$j. 'F]" value="'.$collapse.'" id="mbx['.$j.'F]" />'."\n";
486 $visible = ' style="display:none;"';
488 $visible = ' style="display:block;"';
491 if (isset($boxes->mbxs
[0]) && !$boxes->is_root
) /* mailbox contains childs */
492 echo html_tag( 'div', '', 'left', '', 'class="par_area" id='.$j.'.0000 '. $visible ) . "\n";
494 if ($j !='ID.0000') {
497 for ($i = 0; $i <count($boxes->mbxs
); $i++
) {
499 listAdvancedBoxes($boxes->mbxs
[$i],$mbx,$j);
501 if (isset($boxes->mbxs
[0]) && !$boxes->is_root
) echo '</div>'."\n\n";
508 /* -------------------- MAIN ------------------------ */
510 $key = $_COOKIE['key'];
511 $onetimepad = $_SESSION['onetimepad'];
512 $username = $_SESSION['username'];
513 $delimiter = $_SESSION['delimiter'];
515 if (isset($_GET['fold'])) {
516 $fold = $_GET['fold'];
518 if (isset($_GET['unfold'])) {
519 $unfold = $_GET['unfold'];
522 // open a connection on the imap port (143)
523 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 10); // the 10 is to hide the output
526 * Using stristr since older preferences may contain "None" and "none".
528 if (isset($left_refresh) && ($left_refresh != '') &&
529 !stristr($left_refresh, 'none')){
530 $xtra = "\n<meta http-equiv=\"Expires\" content=\"Thu, 01 Dec 1994 16:00:00 GMT\" />\n" .
531 "<meta http-equiv=\"Pragma\" content=\"no-cache\" />\n".
532 "<meta http-equiv=\"REFRESH\" content=\"$left_refresh;URL=left_main.php\" />\n";
538 * $advanced_tree and $oldway are boolean vars which are default set to default
540 * Setting $oldway to false causes left_main.php to use the new experimental
541 * way of getting the mailbox-tree.
542 * Setting $advanced tree to true causes SM to display a experimental
543 * mailbox-tree with dhtml behaviour.
544 * It only works on browsers which supports css and javascript. The used
545 * javascript is experimental and doesn't support all browsers. It is tested on
546 * IE6 an Konquerer 3.0.0-2.
547 * In the function ListAdvancedBoxes there is another var $use_folder_images.
548 * setting this to true is only usefull if the images exists in ../images.
550 * Feel free to experiment with the code and report bugs and enhancements
551 * to marc@its-projects.nl
554 $advanced_tree = false; /* set this to true if you want to see a nicer mailboxtree */
555 $oldway = true; /* default SM behaviour */
557 if ($advanced_tree) {
559 <script language="Javascript" TYPE="text/javascript">
563 function hidechilds(el) {
565 form_id = "mbx[" + el.id +"F]";
567 ele = document.all[id];
569 if(ele.style.display == "none") {
570 ele.style.display = "block";
571 ele.style.visibility = "visible"
572 el.src="../images/minus.gif";
573 document.all[form_id].value=0;
575 ele.style.display = "none";
576 ele.style.visibility = "hidden"
577 el.src="../images/plus.gif";
578 document.all[form_id].value=1;
581 } else if (document.getElementById) {
582 ele = document.getElementById(id);
584 if(ele.style.display == "none") {
585 ele.style.display = "block";
586 ele.style.visibility = "visible"
587 el.src="../images/minus.gif";
588 document.getElementById(form_id).value=0;
590 ele.style.display = "none";
591 ele.style.visibility = "hidden"
592 el.src="../images/plus.gif";
593 document.getElementById(form_id).value=1;
600 if (!document.images) return;
601 var ar = new Array();
602 var arguments = preload.arguments;
603 for (var i = 0; i<arguments.length; i++) {
605 ar[i].src = arguments[i];
609 function buttonover(el,on) {
611 el.style.borderColor="blue";}
613 el.style.borderColor="orange";}
616 function buttonclick(el,on) {
618 el.style.border="groove"}
620 el.style.border="ridge";}
623 function hideframe(hide) {
626 $xtra .= " left_size = \"$left_size\";\n";
629 masterf = window.parent.document.all["fs1"];
630 leftf = window.parent.document.all["left"];
631 leftcontent = document.all["leftframe"];
632 leftbutton = document.all["showf"];
633 } else if (document.getElementById) {
634 masterf = window.parent.document.getElementById("fs1");
635 leftf = window.parent.document.getElementById("left");
636 leftcontent = document.getElementById("leftframe");
637 leftbutton = document.getElementById("showf");
642 new_col = calc_col("20");
643 masterf.cols = new_col;
644 document.body.scrollLeft=0;
645 document.body.style.overflow='hidden';
646 leftcontent.style.display = 'none';
647 leftbutton.style.display='block';
649 masterf.cols = calc_col(left_size);
650 document.body.style.overflow='';
651 leftbutton.style.display='none';
652 leftcontent.style.display='block';
657 function calc_col(c_w) {
660 if ($location_of_bar == 'right') {
661 $xtra .= ' right=true;';
663 $xtra .= ' right=false;';
675 function resizeframe(direction) {
677 masterf = window.parent.document.all["fs1"];
678 } else if (document.getElementById) {
679 window.parent.document.getElementById("fs1");
685 if ($location_of_bar == 'right') {
686 $xtra .= ' colPat=/^\*,(\d+)$/;';
688 $xtra .= ' colPat=/^(\d+),.*$/;';
693 old_col = masterf.cols;
694 colPat.exec(old_col);
697 new_col_width = parseInt(RegExp.$1) + 25;
700 if (parseInt(RegExp.$1) > 35) {
701 new_col_width = parseInt(RegExp.$1) - 25;
704 masterf.cols = calc_col(new_col_width);
713 /* style definitions */
717 <style type="text/css">
720 margin: 0px 0px 0px 0px;
721 padding: 5px 5px 5px 5px;
739 text-decoration: none;
740 background-color: $color[0];
745 background-color: $color[9];
767 border-left-width:0.1em;
768 border-left-color:blue;
769 border-bottom: solid;
770 border-bottom-width:0.1em;
771 border-bottom-color:blue;
784 background: $color[0];
798 displayHtmlHeader( 'SquirrelMail', $xtra );
800 /* If requested and not yet complete, attempt to autocreate folders. */
801 if ($auto_create_special && !isset($auto_create_done)) {
802 $autocreate = array($sent_folder, $trash_folder, $draft_folder);
803 foreach( $autocreate as $folder ) {
804 if (($folder != '') && ($folder != 'none')) {
805 if ( !sqimap_mailbox_exists($imapConnection, $folder)) {
806 sqimap_mailbox_create($imapConnection, $folder, '');
807 } else if (!sqimap_mailbox_is_subscribed($imapConnection, $folder)) {
808 sqimap_subscribe($imapConnection, $folder);
813 /* Let the world know that autocreation is complete! Hurrah! */
814 $auto_create_done = TRUE;
815 sqsession_register($auto_create_done, 'auto_create_done');
818 echo "\n<body bgcolor=\"$color[3]\" text=\"$color[6]\" link=\"$color[6]\" vlink=\"$color[6]\" alink=\"$color[6]\">\n";
820 do_hook('left_main_before');
821 if ($advanced_tree) {
822 /* nice future feature, needs layout !! volunteers? */
823 $right_pos = $left_size - 20;
824 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>';
825 echo '<div ID="showf" style="width=20;font-size:12;display:none;"><a href="javascript:hideframe(false)"><b>>></b></a></div>';
826 echo '<div ID="incrf" style="width=20;font-size:12"><a href="javascript:resizeframe(true)"><b>></b></a></div>';
827 echo '<div ID="decrf" style="width=20;font-size:12"><a href="javascript:resizeframe(false)"><b><</b></a></div></div>';
828 echo '<div ID="leftframe"><br /><br />';
831 echo "\n\n" . html_tag( 'table', '', 'left', '', 'border="0" cellspacing="0" cellpadding="0" width="99%"' ) .
833 html_tag( 'td', '', 'left' ) .
834 '<center><font size="4"><b>'. _("Folders") . "</b><br /></font>\n\n";
836 if ($date_format != 6) {
837 /* First, display the clock. */
838 if ($hour_format == 1) {
840 if ($date_format == 4) {
844 if ($date_format == 4) {
851 switch( $date_format ) {
853 $clk = date('m/d/y '.$hr, time());
856 $clk = date('d/m/y '.$hr, time());
860 $clk = date($hr, time());
863 $clk = substr( getDayName( date( 'w', time() ) ), 0, 3 ) . date( ', ' . $hr, time() );
865 $clk = str_replace(' ',' ',$clk);
867 echo '<center><small>' . str_replace(' ',' ',_("Last Refresh")) .
868 ": $clk</small></center>";
871 /* Next, display the refresh button. */
872 echo '<small>(<a href="../src/left_main.php" target="left">'.
873 _("refresh folder list") . '</a>)</small></center><br />';
875 /* Lastly, display the folder list. */
876 if ( $collapse_folders ) {
877 /* If directed, collapse or uncollapse a folder. */
879 setPref($data_dir, $username, 'collapse_folder_' . $fold, SM_BOX_COLLAPSED
);
880 } else if (isset($unfold)) {
881 setPref($data_dir, $username, 'collapse_folder_' . $unfold, SM_BOX_UNCOLLAPSED
);
885 if ($oldway) { /* normal behaviour SM */
887 $boxes = sqimap_mailbox_list($imapConnection);
888 /* Prepare do do out collapsedness and visibility computation. */
890 $boxcount = count($boxes);
892 /* Compute the collapsedness and visibility of each box. */
894 while ($curbox < $boxcount) {
895 $boxes[$curbox]['visible'] = TRUE;
896 compute_folder_children($curbox, $boxcount);
900 for ($i = 0; $i < count($boxes); $i++
) {
901 if ( $boxes[$i]['visible'] ) {
902 $mailbox = $boxes[$i]['formatted'];
903 $mblevel = substr_count($boxes[$i]['unformatted'], $delimiter) +
1;
905 /* Create the prefix for the folder name and link. */
906 $prefix = str_repeat(' ',$mblevel);
907 if (isset($collapse_folders) && $collapse_folders && $boxes[$i]['parent']) {
908 $prefix = str_replace(' ',' ',substr($prefix,0,strlen($prefix)-2)).
909 create_collapse_link($i) . ' ';
911 $prefix = str_replace(' ',' ',$prefix);
913 $line = "<nobr><tt>$prefix</tt>";
915 /* Add the folder name and link. */
916 if (! isset($color[15])) {
917 $color[15] = $color[6];
920 if (in_array('noselect', $boxes[$i]['flags'])) {
921 if( isSpecialMailbox( $boxes[$i]['unformatted']) ) {
922 $line .= "<font color=\"$color[11]\">";
924 $line .= "<font color=\"$color[15]\">";
926 if (ereg("^( *)([^ ]*)", $mailbox, $regs)) {
927 $mailbox = str_replace(' ','',$mailbox);
928 $line .= str_replace(' ', ' ', $mailbox);
932 $line .= formatMailboxName($imapConnection, $boxes[$i]);
935 /* Put the final touches on our folder line. */
936 $line .= "</nobr><br>\n";
938 /* Output the line for this folder. */
942 } else { /* expiremental code */
943 $boxes = sqimap_mailbox_tree($imapConnection);
944 if (isset($advanced_tree) && $advanced_tree) {
945 echo '<form name="collapse" action="left_main.php" method="post" ' .
946 'enctype="multipart/form-data"'."\n";
947 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 />';
948 echo '<div id="mailboxes" class="mailboxes">'."\n\n";
949 if (!isset($mbx)) $mbx=NULL;
950 ListAdvancedBoxes($boxes, $mbx);
951 echo '</div></small>'."\n";
956 } /* if ($oldway) else ... */
957 do_hook('left_main_after');
958 sqimap_logout($imapConnection);
960 echo '</td></tr></table>' . "\n".
961 "</div></body></html>\n";