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 require_once('../src/validate.php');
16 require_once('../functions/array.php');
17 require_once('../functions/imap.php');
18 require_once('../functions/plugin.php');
19 require_once('../functions/page_header.php');
20 require_once('../functions/html.php');
22 /* These constants are used for folder stuff. */
23 define('SM_BOX_UNCOLLAPSED', 0);
24 define('SM_BOX_COLLAPSED', 1);
26 /* --------------------- FUNCTIONS ------------------------- */
28 function formatMailboxName($imapConnection, $box_array) {
30 global $folder_prefix, $trash_folder, $sent_folder,
31 $color, $move_to_sent, $move_to_trash,
32 $unseen_notify, $unseen_type, $collapse_folders,
33 $draft_folder, $save_as_draft,
34 $use_special_folder_color;
36 $real_box = $box_array['unformatted'];
37 $mailbox = str_replace(' ','',$box_array['formatted']);
38 $mailboxURL = urlencode($real_box);
40 /* Strip down the mailbox name. */
41 if (ereg("^( *)([^ ]*)$", $mailbox, $regs)) {
45 list($unseen_string, $unseen) = create_unseen_string($real_box, $box_array, $imapConnection);
46 $special_color = ($use_special_folder_color && isSpecialMailbox($real_box));
48 /* Start off with a blank line. */
51 /* If there are unseen message, bold the line. */
52 if ($unseen > 0) { $line .= '<B>'; }
54 /* Create the link for this folder. */
55 $line .= '<a href="right_main.php?PG_SHOWALL=0&sort=0&startMessage=1&mailbox='.
56 $mailboxURL.'" TARGET="right" STYLE="text-decoration:none">';
59 $line .= "<font color=\"$color[11]\">";
61 if ( $mailbox == 'INBOX' ) {
64 $line .= str_replace(' ',' ',$mailbox);
66 if ($special_color == TRUE)
70 /* If there are unseen message, close bolding. */
71 if ($unseen > 0) { $line .= "</B>"; }
73 /* Print unseen information. */
74 if ($unseen_string != '') {
75 $line .= " <SMALL>$unseen_string</SMALL>";
78 if (($move_to_trash) && ($real_box == $trash_folder)) {
79 if (! isset($numMessages)) {
80 $numMessages = sqimap_get_num_messages($imapConnection, $real_box);
83 if ($numMessages > 0) {
84 $urlMailbox = urlencode($real_box);
85 $line .= "\n<small>\n" .
86 " (<A HREF=\"empty_trash.php\" style=\"text-decoration:none\">"._("purge")."</A>)" .
91 /* Return the final product. */
96 * Recursive function that computes the collapsed status and parent
97 * (or not parent) status of this box, and the visiblity and collapsed
98 * status and parent (or not parent) status for all children boxes.
100 function compute_folder_children(&$parbox, $boxcount) {
101 global $boxes, $data_dir, $username, $collapse_folders;
102 $nextbox = $parbox +
1;
104 /* Retreive the name for the parent box. */
105 $parbox_name = $boxes[$parbox]['unformatted'];
107 /* 'Initialize' this parent box to childless. */
108 $boxes[$parbox]['parent'] = FALSE;
110 /* Compute the collapse status for this box. */
111 if( isset($collapse_folders) && $collapse_folders ) {
112 $collapse = getPref($data_dir, $username, 'collapse_folder_' . $parbox_name);
113 $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED
: $collapse);
115 $collapse = SM_BOX_UNCOLLAPSED
;
117 $boxes[$parbox]['collapse'] = $collapse;
119 /* Otherwise, get the name of the next box. */
120 if (isset($boxes[$nextbox]['unformatted'])) {
121 $nextbox_name = $boxes[$nextbox]['unformatted'];
126 /* Compute any children boxes for this box. */
127 while (($nextbox < $boxcount) &&
128 (is_parent_box($boxes[$nextbox]['unformatted'], $parbox_name))) {
130 /* Note that this 'parent' box has at least one child. */
131 $boxes[$parbox]['parent'] = TRUE;
133 /* Compute the visiblity of this box. */
134 $boxes[$nextbox]['visible'] = ($boxes[$parbox]['visible'] &&
135 ($boxes[$parbox]['collapse'] != SM_BOX_COLLAPSED
));
137 /* Compute the visibility of any child boxes. */
138 compute_folder_children($nextbox, $boxcount);
141 /* Set the parent box to the current next box. */
146 * Create the link for a parent folder that will allow that
147 * parent folder to either be collapsed or expaned, as is
148 * currently appropriate.
150 function create_collapse_link($boxnum) {
151 global $boxes, $imapConnection, $unseen_notify, $color;
152 $mailbox = urlencode($boxes[$boxnum]['unformatted']);
154 /* Create the link for this collapse link. */
155 $link = '<a target="left" style="text-decoration:none" ' .
156 'href="left_main.php?';
157 if ($boxes[$boxnum]['collapse'] == SM_BOX_COLLAPSED
) {
158 $link .= "unfold=$mailbox\">+";
160 $link .= "fold=$mailbox\">-";
164 /* Return the finished product. */
169 * create_unseen_string:
171 * Create unseen and total message count for both this folder and
174 * @param string $boxName name of the current mailbox
175 * @param array $boxArray array for the current mailbox
176 * @param $imapConnection current imap connection in use
177 * @return array[0] unseen message string (for display)
178 * @return array[1] unseen message count
180 function create_unseen_string($boxName, $boxArray, $imapConnection) {
181 global $boxes, $unseen_type, $color;
183 /* Initialize the return value. */
186 /* Initialize the counts for this folder. */
188 $boxMessageCount = 0;
189 $totalUnseenCount = 0;
190 $totalMessageCount = 0;
192 /* Collect the counts for this box alone. */
193 $boxUnseenCount = sqimap_unseen_messages($imapConnection, $boxName);
194 if ($unseen_type == 2) {
195 $boxMessageCount = sqimap_get_num_messages($imapConnection, $boxName);
198 /* Initialize the total counts. */
200 if ($boxArray['collapse'] == SM_BOX_COLLAPSED
) {
201 /* Collect the counts for this boxes subfolders. */
202 $curBoxLength = strlen($boxName);
203 $boxCount = count($boxes);
205 for ($i = 0; $i < $boxCount; ++
$i) {
206 /* Initialize the counts for this subfolder. */
208 $subMessageCount = 0;
210 /* Collect the counts for this subfolder. */
211 if (($boxName != $boxes[$i]['unformatted'])
212 && (substr($boxes[$i]['unformatted'], 0, $curBoxLength) == $boxName)
213 && !in_array('noselect', $boxes[$i]['flags'])) {
214 $subUnseenCount = sqimap_unseen_messages($imapConnection, $boxes[$i]['unformatted']);
215 if ($unseen_type == 2) {
216 $subMessageCount = sqimap_get_num_messages($imapConnection, $boxes[$i]['unformatted']);
219 /* Add the counts for this subfolder to the total. */
220 $totalUnseenCount +
= $subUnseenCount;
221 $totalMessageCount +
= $subMessageCount;
225 /* Add the counts for all subfolders to that of the box. */
226 $boxUnseenCount +
= $totalUnseenCount;
227 $boxMessageCount +
= $totalMessageCount;
230 /* And create the magic unseen count string. */
231 /* Really a lot more then just the unseen count. */
232 if (($unseen_type == 1) && ($boxUnseenCount > 0)) {
233 $result[0] = "($boxUnseenCount)";
234 } else if ($unseen_type == 2) {
235 $result[0] = "($boxUnseenCount/$boxMessageCount)";
236 $result[0] = "<font color=\"$color[11]\">$result[0]</font>";
239 /* Set the unseen count to return to the outside world. */
240 $result[1] = $boxUnseenCount;
242 /* Return our happy result. */
247 * This simple function checks if a box is another box's parent.
249 function is_parent_box($curbox_name, $parbox_name) {
252 /* Extract the name of the parent of the current box. */
253 $curparts = explode($delimiter, $curbox_name);
254 $curname = array_pop($curparts);
255 $actual_parname = implode($delimiter, $curparts);
256 $actual_parname = substr($actual_parname,0,strlen($parbox_name));
258 /* Compare the actual with the given parent name. */
259 return ($parbox_name == $actual_parname);
262 function listBoxes ($boxes, $j=0 ) {
263 global $data_dir, $username, $startmessage, $color, $unseen_notify, $unseen_type,
264 $move_to_trash, $trash_folder, $collapse_folders;
269 $mailbox = $boxes->mailboxname_full
;
271 for ($k = 0; $k < $j; $k++
) {
272 $leader.= '   ';
274 $mailboxURL = urlencode($mailbox);
276 /* get unseen/total messages information */
277 if ($boxes->unseen
) {
278 $unseen = $boxes->unseen
;
279 $unseen_string = "($unseen)";
280 if ($unseen>0) $unseen_found = TRUE;
282 $numMessages = $boxes->total
;
283 $unseen_string = "<font color=\"$color[11]\">($unseen/$numMessages)</font>";
289 if (isset($boxes->mbxs
[0]) && $collapse_folders) {
290 $collapse = getPref($data_dir, $username, 'collapse_folder_' . $mailbox);
291 $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED
: $collapse);
293 $link = '<a target="left" style="text-decoration:none" ' .'href="left_main.php?';
295 $link .= "unfold=$mailboxURL\">$leader + ";
297 $link .= "fold=$mailboxURL\">$leader - ";
302 $pre.= $leader . '   ';
306 /* If there are unseen message, bold the line. */
307 if ($unseen > 0) { $pre .= '<B>'; }
309 if (($move_to_trash) && ($mailbox == $trash_folder)) {
310 if (! isset($numMessages)) {
311 $numMessages = sqimap_get_num_messages($imapConnection, $mailbox);
314 if ($numMessages > 0) {
315 $urlMailbox = urlencode($mailbox);
316 $pre .= "\n<small>\n" .
317 " (<A HREF=\"empty_trash.php\" style=\"text-decoration:none\">"._("purge")."</A>)" .
321 if (!$boxes->is_noselect
) {
322 $pre .= "<a HREF=\"right_main.php?PG_SHOWALL=0&sort=0&startMessage=1&mailbox=$mailboxURL\" TARGET=\"right\">";
327 /* If there are unseen message, close bolding. */
328 if ($unseen > 0) { $end .= "</B>"; }
330 /* Print unseen information. */
331 if (isset($unseen_found) && $unseen_found) {
332 $end .= " <SMALL>$unseen_string</SMALL>";
337 if ($boxes->is_special
) {
338 $font = "<FONT COLOR=\"$color[11]\">";
339 $fontend = "</FONT>";
342 if (!$boxes->is_root
) {
343 echo "" . $pre .$font. $boxes->mailboxname_sub
.$fontend . $end. '<br>';
346 if (!$collapse ||
$boxes->is_root
) {
347 for ($i = 0; $i <count($boxes->mbxs
); $i++
) {
348 listBoxes($boxes->mbxs
[$i],$j);
355 function ListAdvancedBoxes ($boxes, $mbx, $j='ID.0000' ) {
356 global $data_dir, $username, $startmessage, $color, $unseen_notify, $unseen_type,
357 $move_to_trash, $trash_folder, $collapse_folders;
359 /* use_folder_images only works if the images exist in ../images */
360 $use_folder_images = true;
367 $mailbox = $boxes->mailboxname_full
;
368 $mailboxURL = urlencode($mailbox);
370 /* get unseen/total messages information */
371 if ($boxes->unseen
) {
372 $unseen = $boxes->unseen
;
373 $unseen_string = "($unseen)";
374 if ($unseen>0) $unseen_found = TRUE;
376 $numMessages = $boxes->total
;
377 $unseen_string = "<font color=\"$color[11]\">($unseen/$numMessages)</font>";
381 /* If there are unseen message, bold the line. */
382 if ($unseen > 0) { $pre .= '<B>'; }
384 /* color special boxes */
385 if ($boxes->is_special
) {
386 $pre .= "<FONT COLOR=\"$color[11]\">";
390 /* If there are unseen message, close bolding. */
391 if ($unseen > 0) { $end .= "</B>"; }
393 /* Print unseen information. */
394 if (isset($unseen_found) && $unseen_found) {
395 $end .= " $unseen_string";
398 if (($move_to_trash) && ($mailbox == $trash_folder)) {
399 if (! isset($numMessages)) {
400 $numMessages = $boxes->total
;
402 if ($numMessages > 0) {
403 $urlMailbox = urlencode($mailbox);
404 $pre .= "\n<small>\n" .
405 " (<a class=\"mbx_link\" HREF=\"empty_trash.php\">"._("purge")."</a>)" .
409 if (!$boxes->is_noselect
) { /* \Noselect boxes can't be selected */
410 $pre .= "<a class=\"mbx_link\" HREF=\"right_main.php?PG_SHOWALL=0&sort=0&startMessage=1&mailbox=$mailboxURL\" TARGET=\"right\">";
415 if (!$boxes->is_root
) {
416 if ($use_folder_images) {
417 if ($boxes->is_inbox
) {
418 $folder_img = '../images/inbox.gif';
419 } else if ($boxes->is_sent
) {
420 $folder_img = '../images/senti.gif';
421 } else if ($boxes->is_trash
) {
422 $folder_img = '../images/delitem.gif';
423 } else if ($boxes->is_draft
) {
424 $folder_img = '../images/draft.gif';
425 } else $folder_img = '../images/folder.gif';
426 $folder_img = ' <img src="'.$folder_img.'" height="15" valign="center"> ';
427 } else $folder_img = '';
428 if (!isset($boxes->mbxs
[0])) {
429 echo ' ' . html_tag( 'div',
430 $pre . $folder_img . $boxes->mailboxname_sub
. $end ,
431 'left', '', 'class="mbx_sub" id="' .$j. '"' )
434 /* get collapse information */
435 if ($collapse_folders) {
436 $link = '<a target="left" style="text-decoration:none" ' .'href="left_main.php?';
437 $form_entry = $j.'F';
438 if (isset($mbx) && isset($mbx[$form_entry])) {
439 $collapse = $mbx[$form_entry];
441 setPref($data_dir, $username, 'collapse_folder_'.$boxes->mailboxname_full
, SM_BOX_COLLAPSED
);
443 setPref($data_dir, $username, 'collapse_folder_'.$boxes->mailboxname_full
, SM_BOX_UNCOLLAPSED
);
446 $collapse = getPref($data_dir, $username, 'collapse_folder_' . $mailbox);
447 $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED
: $collapse);
450 $link = '<a href="javascript:void(0)">'." <img src=\"../images/plus.gif\" border=\"1\" id=$j onclick=\"hidechilds(this)\"></A>";
452 $link = '<a href="javascript:void(0)">'."<img src=\"../images/minus.gif\" border=\"1\" id=$j onclick=\"hidechilds(this)\"></a>";
454 $collapse_link = $link;
455 } else $collapse_link='';
456 echo ' ' . html_tag( 'div',
457 $collapse_link . $pre . $folder_img . ' '. $boxes->mailboxname_sub
. $end ,
458 'left', '', 'class="mbx_par" id="' .$j. 'P"' )
460 echo ' <INPUT TYPE="hidden" name=mbx['.$j. 'F] value="'.$collapse.'" id="mbx['.$j.'F]">'."\n";
464 $visible = ' STYLE="display:none;"';
466 $visible = ' STYLE="display:block;"';
469 if (isset($boxes->mbxs
[0]) && !$boxes->is_root
) /* mailbox contains childs */
470 echo html_tag( 'div', '', 'left', '', 'class="par_area" id='.$j.'.0000 '. $visible ) . "\n";
472 if ($j !='ID.0000') {
475 for ($i = 0; $i <count($boxes->mbxs
); $i++
) {
477 listAdvancedBoxes($boxes->mbxs
[$i],$mbx,$j);
479 if (isset($boxes->mbxs
[0]) && !$boxes->is_root
) echo '</div>'."\n\n";
486 /* -------------------- MAIN ------------------------ */
488 global $delimiter, $default_folder_prefix, $left_size;
490 // open a connection on the imap port (143)
491 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 10); // the 10 is to hide the output
494 * Using stristr since older preferences may contain "None" and "none".
496 if (isset($left_refresh) && ($left_refresh != '') &&
497 !stristr($left_refresh, "none")){
498 $xtra = "\n<META HTTP-EQUIV=\"Expires\" CONTENT=\"Thu, 01 Dec 1994 16:00:00 GMT\">\n" .
499 "<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">\n".
500 "<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"$left_refresh;URL=left_main.php\">\n";
506 * $advanced_tree and $oldway are boolean vars which are default set to default
508 * Setting $oldway to false causes left_main.php to use the new experimental
509 * way of getting the mailbox-tree.
510 * Setting $advanced tree to true causes SM to display a experimental
511 * mailbox-tree with dhtml behaviour.
512 * It only works on browsers which supports css and javascript. The used
513 * javascript is experimental and doesn't support all browsers. It is tested on
514 * IE6 an Konquerer 3.0.0-2.
515 * In the function ListAdvancedBoxes there is another var $use_folder_images.
516 * setting this to true is only usefull if the images exists in ../images.
518 * Feel free to experiment with the code and report bugs and enhancements
519 * to marc@its-projects.nl
522 $advanced_tree = false; /* set this to true if you want to see a nicer mailboxtree */
523 $oldway = true; /* default SM behaviour */
525 if ($advanced_tree) {
527 <script language="Javascript" TYPE="text/javascript">
531 function hidechilds(el) {
533 form_id = "mbx[" + el.id +"F]";
535 ele = document.all[id];
537 if(ele.style.display == "none") {
538 ele.style.display = "block";
539 ele.style.visibility = "visible"
540 el.src="../images/minus.gif";
541 document.all[form_id].value=0;
543 ele.style.display = "none";
544 ele.style.visibility = "hidden"
545 el.src="../images/plus.gif";
546 document.all[form_id].value=1;
549 } else if (document.getElementById) {
550 ele = document.getElementById(id);
552 if(ele.style.display == "none") {
553 ele.style.display = "block";
554 ele.style.visibility = "visible"
555 el.src="../images/minus.gif";
556 document.getElementById(form_id).value=0;
558 ele.style.display = "none";
559 ele.style.visibility = "hidden"
560 el.src="../images/plus.gif";
561 document.getElementById(form_id).value=1;
568 if (!document.images) return;
569 var ar = new Array();
570 var arguments = preload.arguments;
571 for (var i = 0; i<arguments.length; i++) {
573 ar[i].src = arguments[i];
577 function buttonover(el,on) {
579 el.style.borderColor="blue";}
581 el.style.borderColor="orange";}
584 function buttonclick(el,on) {
586 el.style.border="groove"}
588 el.style.border="ridge";}
591 function hideframe(hide) {
594 $xtra .= " left_size = \"$left_size\";\n";
597 masterf = window.parent.document.all["fs1"];
598 leftf = window.parent.document.all["left"];
599 leftcontent = document.all["leftframe"];
600 leftbutton = document.all["showf"];
601 } else if (document.getElementById) {
602 masterf = window.parent.document.getElementById("fs1");
603 leftf = window.parent.document.getElementById("left");
604 leftcontent = document.getElementById("leftframe");
605 leftbutton = document.getElementById("showf");
610 new_col = calc_col("20");
611 masterf.cols = new_col;
612 document.body.scrollLeft=0;
613 document.body.style.overflow='hidden';
614 leftcontent.style.display = 'none';
615 leftbutton.style.display='block';
617 masterf.cols = calc_col(left_size);
618 document.body.style.overflow='';
619 leftbutton.style.display='none';
620 leftcontent.style.display='block';
625 function calc_col(c_w) {
628 if ($location_of_bar == 'right') {
629 $xtra .= ' right=true;';
631 $xtra .= ' right=false;';
643 function resizeframe(direction) {
645 masterf = window.parent.document.all["fs1"];
646 } else if (document.getElementById) {
647 window.parent.document.getElementById("fs1");
653 if ($location_of_bar == 'right') {
654 $xtra .= ' colPat=/^\*,(\d+)$/;';
656 $xtra .= ' colPat=/^(\d+),.*$/;';
661 old_col = masterf.cols;
662 colPat.exec(old_col);
665 new_col_width = parseInt(RegExp.$1) + 25;
668 if (parseInt(RegExp.$1) > 35) {
669 new_col_width = parseInt(RegExp.$1) - 25;
672 masterf.cols = calc_col(new_col_width);
681 /* style definitions */
685 <STYLE TYPE="text/css">
688 margin: 0px 0px 0px 0px;
689 padding: 5px 5px 5px 5px;
707 text-decoration: none;
708 background-color: $color[0];
713 background-color: $color[9];
735 border-left-width:0.1em;
736 border-left-color:blue;
737 border-bottom: solid;
738 border-bottom-width:0.1em;
739 border-bottom-color:blue;
752 background: $color[0];
766 displayHtmlHeader( 'SquirrelMail', $xtra );
768 /* If requested and not yet complete, attempt to autocreate folders. */
769 if ($auto_create_special && !isset($auto_create_done)) {
770 $autocreate = array($sent_folder, $trash_folder, $draft_folder);
771 foreach( $autocreate as $folder ) {
772 if (($folder != '') && ($folder != 'none')) {
773 if ( !sqimap_mailbox_exists($imapConnection, $folder)) {
774 sqimap_mailbox_create($imapConnection, $folder, '');
775 } else if (!sqimap_mailbox_is_subscribed($imapConnection, $folder)) {
776 sqimap_subscribe($imapConnection, $folder);
781 /* Let the world know that autocreation is complete! Hurrah! */
782 $auto_create_done = TRUE;
783 session_register('auto_create_done');
786 echo "\n<BODY BGCOLOR=\"$color[3]\" TEXT=\"$color[6]\" LINK=\"$color[6]\" VLINK=\"$color[6]\" ALINK=\"$color[6]\">\n";
788 do_hook('left_main_before');
789 if ($advanced_tree) {
790 /* nice future feature, needs layout !! volunteers? */
791 $right_pos = $left_size - 20;
792 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>';
793 echo '<div ID="showf" style="width=20;font-size:12;display:none;"><A HREF="javascript:hideframe(false)"><b>>></b></a></div>';
794 echo '<div ID="incrf" style="width=20;font-size:12"><A HREF="javascript:resizeframe(true)"><b>></b></a></div>';
795 echo '<div ID="decrf" style="width=20;font-size:12"><A HREF="javascript:resizeframe(false)"><b><</b></a></div></div>';
796 echo '<div ID="leftframe"><br><br>';
799 echo "\n\n" . html_tag( 'table', '', '', '', 'border="0" cellspacing="0" cellpadding="0" width="100%"' ) .
801 html_tag( 'td', '', 'left' ) .
802 '<center><font size="4"><b>'. _("Folders") . "</b><br></font>\n\n";
804 if ($date_format != 6) {
805 /* First, display the clock. */
806 if ($hour_format == 1) {
808 if ($date_format == 4) {
812 if ($date_format == 4) {
819 switch( $date_format ) {
821 $clk = date('m/d/y '.$hr, time());
824 $clk = date('d/m/y '.$hr, time());
828 $clk = date($hr, time());
831 $clk = substr( getDayName( date( 'w', time() ) ), 0, 3 ) . date( ', ' . $hr, time() );
833 $clk = str_replace(' ',' ',$clk);
835 echo '<center><small>' . str_replace(' ',' ',_("Last Refresh")) .
836 ": $clk</small></center>";
839 /* Next, display the refresh button. */
840 echo '<small>(<a href="../src/left_main.php" target="left">'.
841 _("refresh folder list") . '</a>)</small></center><br>';
843 /* Lastly, display the folder list. */
844 if ( $collapse_folders ) {
845 /* If directed, collapse or uncollapse a folder. */
847 setPref($data_dir, $username, 'collapse_folder_' . $fold, SM_BOX_COLLAPSED
);
848 } else if (isset($unfold)) {
849 setPref($data_dir, $username, 'collapse_folder_' . $unfold, SM_BOX_UNCOLLAPSED
);
853 if ($oldway) { /* normal behaviour SM */
855 $boxes = sqimap_mailbox_list($imapConnection);
856 /* Prepare do do out collapsedness and visibility computation. */
858 $boxcount = count($boxes);
860 /* Compute the collapsedness and visibility of each box. */
862 while ($curbox < $boxcount) {
863 $boxes[$curbox]['visible'] = TRUE;
864 compute_folder_children($curbox, $boxcount);
868 for ($i = 0; $i < count($boxes); $i++
) {
869 if ( $boxes[$i]['visible'] ) {
870 $mailbox = $boxes[$i]['formatted'];
871 $mblevel = substr_count($boxes[$i]['unformatted'], $delimiter) +
1;
873 /* Create the prefix for the folder name and link. */
874 $prefix = str_repeat(' ',$mblevel);
875 if (isset($collapse_folders) && $collapse_folders && $boxes[$i]['parent']) {
876 $prefix = str_replace(' ',' ',substr($prefix,0,strlen($prefix)-2)).
877 create_collapse_link($i) . ' ';
879 $prefix = str_replace(' ',' ',$prefix);
881 $line = "<NOBR><TT>$prefix</TT>";
883 /* Add the folder name and link. */
884 if (! isset($color[15])) {
885 $color[15] = $color[6];
888 if (in_array('noselect', $boxes[$i]['flags'])) {
889 if( isSpecialMailbox( $boxes[$i]['unformatted']) ) {
890 $line .= "<FONT COLOR=\"$color[11]\">";
892 $line .= "<FONT COLOR=\"$color[15]\">";
894 if (ereg("^( *)([^ ]*)", $mailbox, $regs)) {
895 $mailbox = str_replace(' ','',$mailbox);
896 $line .= str_replace(' ', ' ', $mailbox);
900 $line .= formatMailboxName($imapConnection, $boxes[$i]);
903 /* Put the final touches on our folder line. */
904 $line .= "</NOBR><BR>\n";
906 /* Output the line for this folder. */
910 } else { /* expiremental code */
911 $boxes = sqimap_mailbox_tree($imapConnection);
912 if (isset($advanced_tree) && $advanced_tree) {
913 echo '<FORM name=collapse action="left_main.php" METHOD=POST' .
914 'ENCTYPE="multipart/form-data"'."\n";
915 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>';
916 echo '<DIV ID=mailboxes CLASS=mailboxes>'."\n\n";
917 if (!isset($mbx)) $mbx=NULL;
918 ListAdvancedBoxes($boxes, $mbx);
919 echo '</div></small>'."\n";
924 } /* if ($oldway) else ... */
925 do_hook('left_main_after');
926 sqimap_logout($imapConnection);
928 echo '</td></tr></table>' . "\n".
929 "</div></body></html>\n";