6 * Copyright (c) 1999-2002 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/array.php');
21 require_once(SM_PATH
. 'functions/imap.php');
22 require_once(SM_PATH
. 'functions/plugin.php');
23 require_once(SM_PATH
. 'functions/page_header.php');
24 require_once(SM_PATH
. 'functions/html.php');
26 /* These constants are used for folder stuff. */
27 define('SM_BOX_UNCOLLAPSED', 0);
28 define('SM_BOX_COLLAPSED', 1);
30 /* --------------------- FUNCTIONS ------------------------- */
32 function formatMailboxName($imapConnection, $box_array) {
34 global $folder_prefix, $trash_folder, $sent_folder,
35 $color, $move_to_sent, $move_to_trash,
36 $unseen_notify, $unseen_type, $collapse_folders,
37 $draft_folder, $save_as_draft,
38 $use_special_folder_color;
40 $real_box = $box_array['unformatted'];
41 $mailbox = str_replace(' ','',$box_array['formatted']);
42 $mailboxURL = urlencode($real_box);
44 /* Strip down the mailbox name. */
45 if (ereg("^( *)([^ ]*)$", $mailbox, $regs)) {
48 $status = create_unseen_string($real_box, $box_array, $imapConnection);
49 if ($status !== false) {
50 list($unseen_string, $unseen) = $status;
52 list($unseen_string, $unseen) = array(_("Not available"),'');
54 $special_color = ($use_special_folder_color && isSpecialMailbox($real_box));
56 /* Start off with a blank line. */
59 /* If there are unseen message, bold the line. */
60 if ($unseen > 0) { $line .= '<B>'; }
62 /* Create the link for this folder. */
63 if ($status !== false) {
64 $line .= '<a href="right_main.php?PG_SHOWALL=0&sort=0&startMessage=1&mailbox='.
65 $mailboxURL.'" TARGET="right" STYLE="text-decoration:none">';
68 $line .= "<font color=\"$color[11]\">";
70 if ( $mailbox == 'INBOX' ) {
73 $line .= str_replace(' ',' ',$mailbox);
75 if ($special_color == TRUE)
77 if ($status !== false) {
81 /* If there are unseen message, close bolding. */
82 if ($unseen > 0) { $line .= "</B>"; }
84 /* Print unseen information. */
85 if ($unseen_string != '') {
86 $line .= " <SMALL>$unseen_string</SMALL>";
89 if (($move_to_trash) && ($real_box == $trash_folder)) {
90 if (! isset($numMessages)) {
91 $numMessages = sqimap_get_num_messages($imapConnection, $real_box);
94 if ($numMessages > 0) {
95 $urlMailbox = urlencode($real_box);
96 $line .= "\n<small>\n" .
97 " (<A HREF=\"empty_trash.php\" style=\"text-decoration:none\">"._("purge")."</A>)" .
102 /* Return the final product. */
107 * Recursive function that computes the collapsed status and parent
108 * (or not parent) status of this box, and the visiblity and collapsed
109 * status and parent (or not parent) status for all children boxes.
111 function compute_folder_children(&$parbox, $boxcount) {
112 global $boxes, $data_dir, $username, $collapse_folders;
113 $nextbox = $parbox +
1;
115 /* Retreive the name for the parent box. */
116 $parbox_name = $boxes[$parbox]['unformatted'];
118 /* 'Initialize' this parent box to childless. */
119 $boxes[$parbox]['parent'] = FALSE;
121 /* Compute the collapse status for this box. */
122 if( isset($collapse_folders) && $collapse_folders ) {
123 $collapse = getPref($data_dir, $username, 'collapse_folder_' . $parbox_name);
124 $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED
: $collapse);
126 $collapse = SM_BOX_UNCOLLAPSED
;
128 $boxes[$parbox]['collapse'] = $collapse;
130 /* Otherwise, get the name of the next box. */
131 if (isset($boxes[$nextbox]['unformatted'])) {
132 $nextbox_name = $boxes[$nextbox]['unformatted'];
137 /* Compute any children boxes for this box. */
138 while (($nextbox < $boxcount) &&
139 (is_parent_box($boxes[$nextbox]['unformatted'], $parbox_name))) {
141 /* Note that this 'parent' box has at least one child. */
142 $boxes[$parbox]['parent'] = TRUE;
144 /* Compute the visiblity of this box. */
145 $boxes[$nextbox]['visible'] = ($boxes[$parbox]['visible'] &&
146 ($boxes[$parbox]['collapse'] != SM_BOX_COLLAPSED
));
148 /* Compute the visibility of any child boxes. */
149 compute_folder_children($nextbox, $boxcount);
152 /* Set the parent box to the current next box. */
157 * Create the link for a parent folder that will allow that
158 * parent folder to either be collapsed or expaned, as is
159 * currently appropriate.
161 function create_collapse_link($boxnum) {
162 global $boxes, $imapConnection, $unseen_notify, $color;
163 $mailbox = urlencode($boxes[$boxnum]['unformatted']);
165 /* Create the link for this collapse link. */
166 $link = '<a target="left" style="text-decoration:none" ' .
167 'href="left_main.php?';
168 if ($boxes[$boxnum]['collapse'] == SM_BOX_COLLAPSED
) {
169 $link .= "unfold=$mailbox\">+";
171 $link .= "fold=$mailbox\">-";
175 /* Return the finished product. */
180 * create_unseen_string:
182 * Create unseen and total message count for both this folder and
185 * @param string $boxName name of the current mailbox
186 * @param array $boxArray array for the current mailbox
187 * @param $imapConnection current imap connection in use
188 * @return array[0] unseen message string (for display)
189 * @return array[1] unseen message count
191 function create_unseen_string($boxName, $boxArray, $imapConnection) {
192 global $boxes, $unseen_type, $color, $unseen_cum;
194 /* Initialize the return value. */
195 $result = array(0,0);
197 /* Initialize the counts for this folder. */
199 $boxMessageCount = 0;
200 $totalUnseenCount = 0;
201 $totalMessageCount = 0;
203 /* Collect the counts for this box alone. */
204 $status = sqimap_status_messages($imapConnection, $boxName);
205 $boxUnseenCount = $status['UNSEEN'];
206 if ($boxUnseenCount === false) {
209 if ($unseen_type == 2) {
210 $boxMessageCount = $status['MESSAGES'];
213 /* Initialize the total counts. */
215 if ($boxArray['collapse'] == SM_BOX_COLLAPSED
&& $unseen_cum) {
216 /* Collect the counts for this boxes subfolders. */
217 $curBoxLength = strlen($boxName);
218 $boxCount = count($boxes);
220 for ($i = 0; $i < $boxCount; ++
$i) {
221 /* Initialize the counts for this subfolder. */
223 $subMessageCount = 0;
225 /* Collect the counts for this subfolder. */
226 if (($boxName != $boxes[$i]['unformatted'])
227 && (substr($boxes[$i]['unformatted'], 0, $curBoxLength) == $boxName)
228 && !in_array('noselect', $boxes[$i]['flags'])) {
229 $status = sqimap_status_messages($imapConnection, $boxes[$i]['unformatted']);
230 $subUnseenCount = $status['UNSEEN'];
231 if ($unseen_type == 2) {
232 $subMessageCount = $status['MESSAGES'];;
234 /* Add the counts for this subfolder to the total. */
235 $totalUnseenCount +
= $subUnseenCount;
236 $totalMessageCount +
= $subMessageCount;
240 /* Add the counts for all subfolders to that of the box. */
241 $boxUnseenCount +
= $totalUnseenCount;
242 $boxMessageCount +
= $totalMessageCount;
245 /* And create the magic unseen count string. */
246 /* Really a lot more then just the unseen count. */
247 if (($unseen_type == 1) && ($boxUnseenCount > 0)) {
248 $result[0] = "($boxUnseenCount)";
249 } else if ($unseen_type == 2) {
250 $result[0] = "($boxUnseenCount/$boxMessageCount)";
251 $result[0] = "<font color=\"$color[11]\">$result[0]</font>";
254 /* Set the unseen count to return to the outside world. */
255 $result[1] = $boxUnseenCount;
257 /* Return our happy result. */
262 * This simple function checks if a box is another box's parent.
264 function is_parent_box($curbox_name, $parbox_name) {
267 /* Extract the name of the parent of the current box. */
268 $curparts = explode($delimiter, $curbox_name);
269 $curname = array_pop($curparts);
270 $actual_parname = implode($delimiter, $curparts);
271 $actual_parname = substr($actual_parname,0,strlen($parbox_name));
273 /* Compare the actual with the given parent name. */
274 return ($parbox_name == $actual_parname);
277 function listBoxes ($boxes, $j=0 ) {
278 global $data_dir, $username, $startmessage, $color, $unseen_notify, $unseen_type,
279 $move_to_trash, $trash_folder, $collapse_folders;
284 $mailbox = $boxes->mailboxname_full
;
286 for ($k = 0; $k < $j; $k++
) {
287 $leader.= '   ';
289 $mailboxURL = urlencode($mailbox);
291 /* get unseen/total messages information */
292 if ($boxes->unseen
) {
293 $unseen = $boxes->unseen
;
294 $unseen_string = "($unseen)";
295 if ($unseen>0) $unseen_found = TRUE;
297 $numMessages = $boxes->total
;
298 $unseen_string = "<font color=\"$color[11]\">($unseen/$numMessages)</font>";
304 if (isset($boxes->mbxs
[0]) && $collapse_folders) {
305 $collapse = getPref($data_dir, $username, 'collapse_folder_' . $mailbox);
306 $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED
: $collapse);
308 $link = '<a target="left" style="text-decoration:none" ' .'href="left_main.php?';
310 $link .= "unfold=$mailboxURL\">$leader + ";
312 $link .= "fold=$mailboxURL\">$leader - ";
317 $pre.= $leader . '   ';
321 /* If there are unseen message, bold the line. */
322 if ($unseen > 0) { $pre .= '<B>'; }
324 if (($move_to_trash) && ($mailbox == $trash_folder)) {
325 if (! isset($numMessages)) {
326 $status = sqimap_status_messages($imapConnection, $mailbox);
327 $numMessages = $status['MESSAGES'];
330 if ($numMessages > 0) {
331 $urlMailbox = urlencode($mailbox);
332 $pre .= "\n<small>\n" .
333 " (<A HREF=\"empty_trash.php\" style=\"text-decoration:none\">"._("purge")."</A>)" .
337 if (!$boxes->is_noselect
) {
338 $pre .= "<a HREF=\"right_main.php?PG_SHOWALL=0&sort=0&startMessage=1&mailbox=$mailboxURL\" TARGET=\"right\">";
343 /* If there are unseen message, close bolding. */
344 if ($unseen > 0) { $end .= "</B>"; }
346 /* Print unseen information. */
347 if (isset($unseen_found) && $unseen_found) {
348 $end .= " <SMALL>$unseen_string</SMALL>";
353 if ($boxes->is_special
) {
354 $font = "<FONT COLOR=\"$color[11]\">";
355 $fontend = "</FONT>";
358 if (!$boxes->is_root
) {
359 echo "" . $pre .$font. $boxes->mailboxname_sub
.$fontend . $end. '<br>';
362 if (!$collapse ||
$boxes->is_root
) {
363 for ($i = 0; $i <count($boxes->mbxs
); $i++
) {
364 listBoxes($boxes->mbxs
[$i],$j);
371 function ListAdvancedBoxes ($boxes, $mbx, $j='ID.0000' ) {
372 global $data_dir, $username, $startmessage, $color, $unseen_notify, $unseen_type,
373 $move_to_trash, $trash_folder, $collapse_folders;
375 /* use_folder_images only works if the images exist in ../images */
376 $use_folder_images = true;
383 $mailbox = $boxes->mailboxname_full
;
384 $mailboxURL = urlencode($mailbox);
386 /* get unseen/total messages information */
387 if ($boxes->unseen
) {
388 $unseen = $boxes->unseen
;
389 $unseen_string = "($unseen)";
390 if ($unseen>0) $unseen_found = TRUE;
392 $numMessages = $boxes->total
;
393 $unseen_string = "<font color=\"$color[11]\">($unseen/$numMessages)</font>";
397 /* If there are unseen message, bold the line. */
398 if ($unseen > 0) { $pre .= '<B>'; }
400 /* color special boxes */
401 if ($boxes->is_special
) {
402 $pre .= "<FONT COLOR=\"$color[11]\">";
406 /* If there are unseen message, close bolding. */
407 if ($unseen > 0) { $end .= "</B>"; }
409 /* Print unseen information. */
410 if (isset($unseen_found) && $unseen_found) {
411 $end .= " $unseen_string";
414 if (($move_to_trash) && ($mailbox == $trash_folder)) {
415 if (! isset($numMessages)) {
416 $numMessages = $boxes->total
;
418 if ($numMessages > 0) {
419 $urlMailbox = urlencode($mailbox);
420 $pre .= "\n<small>\n" .
421 " (<a class=\"mbx_link\" HREF=\"empty_trash.php\">"._("purge")."</a>)" .
425 if (!$boxes->is_noselect
) { /* \Noselect boxes can't be selected */
426 $pre .= "<a class=\"mbx_link\" HREF=\"right_main.php?PG_SHOWALL=0&sort=0&startMessage=1&mailbox=$mailboxURL\" TARGET=\"right\">";
431 if (!$boxes->is_root
) {
432 if ($use_folder_images) {
433 if ($boxes->is_inbox
) {
434 $folder_img = '../images/inbox.gif';
435 } else if ($boxes->is_sent
) {
436 $folder_img = '../images/senti.gif';
437 } else if ($boxes->is_trash
) {
438 $folder_img = '../images/delitem.gif';
439 } else if ($boxes->is_draft
) {
440 $folder_img = '../images/draft.gif';
441 } else $folder_img = '../images/folder.gif';
442 $folder_img = ' <img src="'.$folder_img.'" height="15" valign="center"> ';
443 } else $folder_img = '';
444 if (!isset($boxes->mbxs
[0])) {
445 echo ' ' . html_tag( 'div',
446 $pre . $folder_img . $boxes->mailboxname_sub
. $end ,
447 'left', '', 'class="mbx_sub" id="' .$j. '"' )
450 /* get collapse information */
451 if ($collapse_folders) {
452 $link = '<a target="left" style="text-decoration:none" ' .'href="left_main.php?';
453 $form_entry = $j.'F';
454 if (isset($mbx) && isset($mbx[$form_entry])) {
455 $collapse = $mbx[$form_entry];
457 setPref($data_dir, $username, 'collapse_folder_'.$boxes->mailboxname_full
, SM_BOX_COLLAPSED
);
459 setPref($data_dir, $username, 'collapse_folder_'.$boxes->mailboxname_full
, SM_BOX_UNCOLLAPSED
);
462 $collapse = getPref($data_dir, $username, 'collapse_folder_' . $mailbox);
463 $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED
: $collapse);
466 $link = '<a href="javascript:void(0)">'." <img src=\"../images/plus.gif\" border=\"1\" id=$j onclick=\"hidechilds(this)\"></A>";
468 $link = '<a href="javascript:void(0)">'."<img src=\"../images/minus.gif\" border=\"1\" id=$j onclick=\"hidechilds(this)\"></a>";
470 $collapse_link = $link;
471 } else $collapse_link='';
472 echo ' ' . html_tag( 'div',
473 $collapse_link . $pre . $folder_img . ' '. $boxes->mailboxname_sub
. $end ,
474 'left', '', 'class="mbx_par" id="' .$j. 'P"' )
476 echo ' <INPUT TYPE="hidden" name=mbx['.$j. 'F] value="'.$collapse.'" id="mbx['.$j.'F]">'."\n";
480 $visible = ' STYLE="display:none;"';
482 $visible = ' STYLE="display:block;"';
485 if (isset($boxes->mbxs
[0]) && !$boxes->is_root
) /* mailbox contains childs */
486 echo html_tag( 'div', '', 'left', '', 'class="par_area" id='.$j.'.0000 '. $visible ) . "\n";
488 if ($j !='ID.0000') {
491 for ($i = 0; $i <count($boxes->mbxs
); $i++
) {
493 listAdvancedBoxes($boxes->mbxs
[$i],$mbx,$j);
495 if (isset($boxes->mbxs
[0]) && !$boxes->is_root
) echo '</div>'."\n\n";
502 /* -------------------- MAIN ------------------------ */
504 $key = $_COOKIE['key'];
505 $onetimepad = $_SESSION['onetimepad'];
506 $username = $_SESSION['username'];
507 $delimiter = $_SESSION['delimiter'];
509 if (isset($_GET['fold'])) {
510 $fold = $_GET['fold'];
512 if (isset($_GET['unfold'])) {
513 $unfold = $_GET['unfold'];
516 // open a connection on the imap port (143)
517 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 10); // the 10 is to hide the output
520 * Using stristr since older preferences may contain "None" and "none".
522 if (isset($left_refresh) && ($left_refresh != '') &&
523 !stristr($left_refresh, "none")){
524 $xtra = "\n<META HTTP-EQUIV=\"Expires\" CONTENT=\"Thu, 01 Dec 1994 16:00:00 GMT\">\n" .
525 "<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">\n".
526 "<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"$left_refresh;URL=left_main.php\">\n";
532 * $advanced_tree and $oldway are boolean vars which are default set to default
534 * Setting $oldway to false causes left_main.php to use the new experimental
535 * way of getting the mailbox-tree.
536 * Setting $advanced tree to true causes SM to display a experimental
537 * mailbox-tree with dhtml behaviour.
538 * It only works on browsers which supports css and javascript. The used
539 * javascript is experimental and doesn't support all browsers. It is tested on
540 * IE6 an Konquerer 3.0.0-2.
541 * In the function ListAdvancedBoxes there is another var $use_folder_images.
542 * setting this to true is only usefull if the images exists in ../images.
544 * Feel free to experiment with the code and report bugs and enhancements
545 * to marc@its-projects.nl
548 $advanced_tree = false; /* set this to true if you want to see a nicer mailboxtree */
549 $oldway = true; /* default SM behaviour */
551 if ($advanced_tree) {
553 <script language="Javascript" TYPE="text/javascript">
557 function hidechilds(el) {
559 form_id = "mbx[" + el.id +"F]";
561 ele = document.all[id];
563 if(ele.style.display == "none") {
564 ele.style.display = "block";
565 ele.style.visibility = "visible"
566 el.src="../images/minus.gif";
567 document.all[form_id].value=0;
569 ele.style.display = "none";
570 ele.style.visibility = "hidden"
571 el.src="../images/plus.gif";
572 document.all[form_id].value=1;
575 } else if (document.getElementById) {
576 ele = document.getElementById(id);
578 if(ele.style.display == "none") {
579 ele.style.display = "block";
580 ele.style.visibility = "visible"
581 el.src="../images/minus.gif";
582 document.getElementById(form_id).value=0;
584 ele.style.display = "none";
585 ele.style.visibility = "hidden"
586 el.src="../images/plus.gif";
587 document.getElementById(form_id).value=1;
594 if (!document.images) return;
595 var ar = new Array();
596 var arguments = preload.arguments;
597 for (var i = 0; i<arguments.length; i++) {
599 ar[i].src = arguments[i];
603 function buttonover(el,on) {
605 el.style.borderColor="blue";}
607 el.style.borderColor="orange";}
610 function buttonclick(el,on) {
612 el.style.border="groove"}
614 el.style.border="ridge";}
617 function hideframe(hide) {
620 $xtra .= " left_size = \"$left_size\";\n";
623 masterf = window.parent.document.all["fs1"];
624 leftf = window.parent.document.all["left"];
625 leftcontent = document.all["leftframe"];
626 leftbutton = document.all["showf"];
627 } else if (document.getElementById) {
628 masterf = window.parent.document.getElementById("fs1");
629 leftf = window.parent.document.getElementById("left");
630 leftcontent = document.getElementById("leftframe");
631 leftbutton = document.getElementById("showf");
636 new_col = calc_col("20");
637 masterf.cols = new_col;
638 document.body.scrollLeft=0;
639 document.body.style.overflow='hidden';
640 leftcontent.style.display = 'none';
641 leftbutton.style.display='block';
643 masterf.cols = calc_col(left_size);
644 document.body.style.overflow='';
645 leftbutton.style.display='none';
646 leftcontent.style.display='block';
651 function calc_col(c_w) {
654 if ($location_of_bar == 'right') {
655 $xtra .= ' right=true;';
657 $xtra .= ' right=false;';
669 function resizeframe(direction) {
671 masterf = window.parent.document.all["fs1"];
672 } else if (document.getElementById) {
673 window.parent.document.getElementById("fs1");
679 if ($location_of_bar == 'right') {
680 $xtra .= ' colPat=/^\*,(\d+)$/;';
682 $xtra .= ' colPat=/^(\d+),.*$/;';
687 old_col = masterf.cols;
688 colPat.exec(old_col);
691 new_col_width = parseInt(RegExp.$1) + 25;
694 if (parseInt(RegExp.$1) > 35) {
695 new_col_width = parseInt(RegExp.$1) - 25;
698 masterf.cols = calc_col(new_col_width);
707 /* style definitions */
711 <STYLE TYPE="text/css">
714 margin: 0px 0px 0px 0px;
715 padding: 5px 5px 5px 5px;
733 text-decoration: none;
734 background-color: $color[0];
739 background-color: $color[9];
761 border-left-width:0.1em;
762 border-left-color:blue;
763 border-bottom: solid;
764 border-bottom-width:0.1em;
765 border-bottom-color:blue;
778 background: $color[0];
792 displayHtmlHeader( 'SquirrelMail', $xtra );
794 /* If requested and not yet complete, attempt to autocreate folders. */
795 if ($auto_create_special && !isset($auto_create_done)) {
796 $autocreate = array($sent_folder, $trash_folder, $draft_folder);
797 foreach( $autocreate as $folder ) {
798 if (($folder != '') && ($folder != 'none')) {
799 if ( !sqimap_mailbox_exists($imapConnection, $folder)) {
800 sqimap_mailbox_create($imapConnection, $folder, '');
801 } else if (!sqimap_mailbox_is_subscribed($imapConnection, $folder)) {
802 sqimap_subscribe($imapConnection, $folder);
807 /* Let the world know that autocreation is complete! Hurrah! */
808 $auto_create_done = TRUE;
809 sqsession_register($auto_create_done, 'auto_create_done');
812 echo "\n<BODY BGCOLOR=\"$color[3]\" TEXT=\"$color[6]\" LINK=\"$color[6]\" VLINK=\"$color[6]\" ALINK=\"$color[6]\">\n";
814 do_hook('left_main_before');
815 if ($advanced_tree) {
816 /* nice future feature, needs layout !! volunteers? */
817 $right_pos = $left_size - 20;
818 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>';
819 echo '<div ID="showf" style="width=20;font-size:12;display:none;"><A HREF="javascript:hideframe(false)"><b>>></b></a></div>';
820 echo '<div ID="incrf" style="width=20;font-size:12"><A HREF="javascript:resizeframe(true)"><b>></b></a></div>';
821 echo '<div ID="decrf" style="width=20;font-size:12"><A HREF="javascript:resizeframe(false)"><b><</b></a></div></div>';
822 echo '<div ID="leftframe"><br><br>';
825 echo "\n\n" . html_tag( 'table', '', 'left', '', 'border="0" cellspacing="0" cellpadding="0" width="99%"' ) .
827 html_tag( 'td', '', 'left' ) .
828 '<center><font size="4"><b>'. _("Folders") . "</b><br></font>\n\n";
830 if ($date_format != 6) {
831 /* First, display the clock. */
832 if ($hour_format == 1) {
834 if ($date_format == 4) {
838 if ($date_format == 4) {
845 switch( $date_format ) {
847 $clk = date('m/d/y '.$hr, time());
850 $clk = date('d/m/y '.$hr, time());
854 $clk = date($hr, time());
857 $clk = substr( getDayName( date( 'w', time() ) ), 0, 3 ) . date( ', ' . $hr, time() );
859 $clk = str_replace(' ',' ',$clk);
861 echo '<center><small>' . str_replace(' ',' ',_("Last Refresh")) .
862 ": $clk</small></center>";
865 /* Next, display the refresh button. */
866 echo '<small>(<a href="../src/left_main.php" target="left">'.
867 _("refresh folder list") . '</a>)</small></center><br>';
869 /* Lastly, display the folder list. */
870 if ( $collapse_folders ) {
871 /* If directed, collapse or uncollapse a folder. */
873 setPref($data_dir, $username, 'collapse_folder_' . $fold, SM_BOX_COLLAPSED
);
874 } else if (isset($unfold)) {
875 setPref($data_dir, $username, 'collapse_folder_' . $unfold, SM_BOX_UNCOLLAPSED
);
879 if ($oldway) { /* normal behaviour SM */
881 $boxes = sqimap_mailbox_list($imapConnection);
882 /* Prepare do do out collapsedness and visibility computation. */
884 $boxcount = count($boxes);
886 /* Compute the collapsedness and visibility of each box. */
888 while ($curbox < $boxcount) {
889 $boxes[$curbox]['visible'] = TRUE;
890 compute_folder_children($curbox, $boxcount);
894 for ($i = 0; $i < count($boxes); $i++
) {
895 if ( $boxes[$i]['visible'] ) {
896 $mailbox = $boxes[$i]['formatted'];
897 $mblevel = substr_count($boxes[$i]['unformatted'], $delimiter) +
1;
899 /* Create the prefix for the folder name and link. */
900 $prefix = str_repeat(' ',$mblevel);
901 if (isset($collapse_folders) && $collapse_folders && $boxes[$i]['parent']) {
902 $prefix = str_replace(' ',' ',substr($prefix,0,strlen($prefix)-2)).
903 create_collapse_link($i) . ' ';
905 $prefix = str_replace(' ',' ',$prefix);
907 $line = "<NOBR><TT>$prefix</TT>";
909 /* Add the folder name and link. */
910 if (! isset($color[15])) {
911 $color[15] = $color[6];
914 if (in_array('noselect', $boxes[$i]['flags'])) {
915 if( isSpecialMailbox( $boxes[$i]['unformatted']) ) {
916 $line .= "<FONT COLOR=\"$color[11]\">";
918 $line .= "<FONT COLOR=\"$color[15]\">";
920 if (ereg("^( *)([^ ]*)", $mailbox, $regs)) {
921 $mailbox = str_replace(' ','',$mailbox);
922 $line .= str_replace(' ', ' ', $mailbox);
926 $line .= formatMailboxName($imapConnection, $boxes[$i]);
929 /* Put the final touches on our folder line. */
930 $line .= "</NOBR><BR>\n";
932 /* Output the line for this folder. */
936 } else { /* expiremental code */
937 $boxes = sqimap_mailbox_tree($imapConnection);
938 if (isset($advanced_tree) && $advanced_tree) {
939 echo '<FORM name=collapse action="left_main.php" METHOD=POST' .
940 'ENCTYPE="multipart/form-data"'."\n";
941 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>';
942 echo '<DIV ID=mailboxes CLASS=mailboxes>'."\n\n";
943 if (!isset($mbx)) $mbx=NULL;
944 ListAdvancedBoxes($boxes, $mbx);
945 echo '</div></small>'."\n";
950 } /* if ($oldway) else ... */
951 do_hook('left_main_after');
952 sqimap_logout($imapConnection);
954 echo '</td></tr></table>' . "\n".
955 "</div></body></html>\n";