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)) {
47 $status = array('','');
48 if (($unseen_notify == 2 && $real_box == 'INBOX') ||
49 $unseen_notify == 3) {
50 $tmp_status = create_unseen_string($real_box, $box_array, $imapConnection, $unseen_type );
51 if ($status !== false) {
52 $status = $tmp_status;
55 list($unseen_string, $unseen) = $status;
56 $special_color = ($use_special_folder_color && isSpecialMailbox($real_box));
58 /* Start off with a blank line. */
61 /* If there are unseen message, bold the line. */
62 if ($unseen > 0) { $line .= '<B>'; }
64 /* Create the link for this folder. */
65 if ($status !== false) {
66 $line .= '<a href="right_main.php?PG_SHOWALL=0&sort=0&startMessage=1&mailbox='.
67 $mailboxURL.'" TARGET="right" STYLE="text-decoration:none">';
70 $line .= "<font color=\"$color[11]\">";
72 if ( $mailbox == 'INBOX' ) {
75 $line .= str_replace(' ',' ',$mailbox);
77 if ($special_color == TRUE)
79 if ($status !== false) {
83 /* If there are unseen message, close bolding. */
84 if ($unseen > 0) { $line .= "</B>"; }
86 /* Print unseen information. */
87 if ($unseen_string != '') {
88 $line .= " <SMALL>$unseen_string</SMALL>";
91 /* If it's the trash folder, show a purge link when needed */
92 if (($move_to_trash) && ($real_box == $trash_folder)) {
93 if (! isset($numMessages)) {
94 $numMessages = sqimap_get_num_messages($imapConnection, $real_box);
97 if (($numMessages > 0) or ($box_array['parent'] == 1)) {
98 $urlMailbox = urlencode($real_box);
99 $line .= "\n<small>\n" .
100 " (<A HREF=\"empty_trash.php\" style=\"text-decoration:none\">"._("purge")."</A>)" .
105 /* Return the final product. */
110 * Recursive function that computes the collapsed status and parent
111 * (or not parent) status of this box, and the visiblity and collapsed
112 * status and parent (or not parent) status for all children boxes.
114 function compute_folder_children(&$parbox, $boxcount) {
115 global $boxes, $data_dir, $username, $collapse_folders;
116 $nextbox = $parbox +
1;
118 /* Retreive the name for the parent box. */
119 $parbox_name = $boxes[$parbox]['unformatted'];
121 /* 'Initialize' this parent box to childless. */
122 $boxes[$parbox]['parent'] = FALSE;
124 /* Compute the collapse status for this box. */
125 if( isset($collapse_folders) && $collapse_folders ) {
126 $collapse = getPref($data_dir, $username, 'collapse_folder_' . $parbox_name);
127 $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED
: $collapse);
129 $collapse = SM_BOX_UNCOLLAPSED
;
131 $boxes[$parbox]['collapse'] = $collapse;
133 /* Otherwise, get the name of the next box. */
134 if (isset($boxes[$nextbox]['unformatted'])) {
135 $nextbox_name = $boxes[$nextbox]['unformatted'];
140 /* Compute any children boxes for this box. */
141 while (($nextbox < $boxcount) &&
142 (is_parent_box($boxes[$nextbox]['unformatted'], $parbox_name))) {
144 /* Note that this 'parent' box has at least one child. */
145 $boxes[$parbox]['parent'] = TRUE;
147 /* Compute the visiblity of this box. */
148 $boxes[$nextbox]['visible'] = ($boxes[$parbox]['visible'] &&
149 ($boxes[$parbox]['collapse'] != SM_BOX_COLLAPSED
));
151 /* Compute the visibility of any child boxes. */
152 compute_folder_children($nextbox, $boxcount);
155 /* Set the parent box to the current next box. */
160 * Create the link for a parent folder that will allow that
161 * parent folder to either be collapsed or expaned, as is
162 * currently appropriate.
164 function create_collapse_link($boxnum) {
165 global $boxes, $imapConnection, $unseen_notify, $color;
166 $mailbox = urlencode($boxes[$boxnum]['unformatted']);
168 /* Create the link for this collapse link. */
169 $link = '<a target="left" style="text-decoration:none" ' .
170 'href="left_main.php?';
171 if ($boxes[$boxnum]['collapse'] == SM_BOX_COLLAPSED
) {
172 $link .= "unfold=$mailbox\">+";
174 $link .= "fold=$mailbox\">-";
178 /* Return the finished product. */
183 * create_unseen_string:
185 * Create unseen and total message count for both this folder and
188 * @param string $boxName name of the current mailbox
189 * @param array $boxArray array for the current mailbox
190 * @param $imapConnection current imap connection in use
191 * @return array[0] unseen message string (for display)
192 * @return array[1] unseen message count
194 function create_unseen_string($boxName, $boxArray, $imapConnection, $unseen_type) {
195 global $boxes, $unseen_type, $color, $unseen_cum;
197 /* Initialize the return value. */
198 $result = array(0,0);
200 /* Initialize the counts for this folder. */
202 $boxMessageCount = 0;
203 $totalUnseenCount = 0;
204 $totalMessageCount = 0;
206 /* Collect the counts for this box alone. */
207 $status = sqimap_status_messages($imapConnection, $boxName);
208 $boxUnseenCount = $status['UNSEEN'];
209 if ($boxUnseenCount === false) {
212 if ($unseen_type == 2) {
213 $boxMessageCount = $status['MESSAGES'];
216 /* Initialize the total counts. */
218 if ($boxArray['collapse'] == SM_BOX_COLLAPSED
&& $unseen_cum) {
219 /* Collect the counts for this boxes subfolders. */
220 $curBoxLength = strlen($boxName);
221 $boxCount = count($boxes);
223 for ($i = 0; $i < $boxCount; ++
$i) {
224 /* Initialize the counts for this subfolder. */
226 $subMessageCount = 0;
228 /* Collect the counts for this subfolder. */
229 if (($boxName != $boxes[$i]['unformatted'])
230 && (substr($boxes[$i]['unformatted'], 0, $curBoxLength) == $boxName)
231 && !in_array('noselect', $boxes[$i]['flags'])) {
232 $status = sqimap_status_messages($imapConnection, $boxes[$i]['unformatted']);
233 $subUnseenCount = $status['UNSEEN'];
234 if ($unseen_type == 2) {
235 $subMessageCount = $status['MESSAGES'];;
237 /* Add the counts for this subfolder to the total. */
238 $totalUnseenCount +
= $subUnseenCount;
239 $totalMessageCount +
= $subMessageCount;
243 /* Add the counts for all subfolders to that of the box. */
244 $boxUnseenCount +
= $totalUnseenCount;
245 $boxMessageCount +
= $totalMessageCount;
248 /* And create the magic unseen count string. */
249 /* Really a lot more then just the unseen count. */
250 if (($unseen_type == 1) && ($boxUnseenCount > 0)) {
251 $result[0] = "($boxUnseenCount)";
252 } else if ($unseen_type == 2) {
253 $result[0] = "($boxUnseenCount/$boxMessageCount)";
254 $result[0] = "<font color=\"$color[11]\">$result[0]</font>";
257 /* Set the unseen count to return to the outside world. */
258 $result[1] = $boxUnseenCount;
260 /* Return our happy result. */
265 * This simple function checks if a box is another box's parent.
267 function is_parent_box($curbox_name, $parbox_name) {
270 /* Extract the name of the parent of the current box. */
271 $curparts = explode($delimiter, $curbox_name);
272 $curname = array_pop($curparts);
273 $actual_parname = implode($delimiter, $curparts);
274 $actual_parname = substr($actual_parname,0,strlen($parbox_name));
276 /* Compare the actual with the given parent name. */
277 return ($parbox_name == $actual_parname);
280 function listBoxes ($boxes, $j=0 ) {
281 global $data_dir, $username, $startmessage, $color, $unseen_notify, $unseen_type,
282 $move_to_trash, $trash_folder, $collapse_folders;
287 $mailbox = $boxes->mailboxname_full
;
289 for ($k = 0; $k < $j; $k++
) {
290 $leader.= ' ';
292 $mailboxURL = urlencode($mailbox);
294 /* get unseen/total messages information */
295 if ($boxes->unseen
) {
296 $unseen = $boxes->unseen
;
297 $unseen_string = "($unseen)";
298 if ($unseen>0) $unseen_found = TRUE;
300 $numMessages = $boxes->total
;
301 $unseen_string = "<font color=\"$color[11]\">($unseen/$numMessages)</font>";
307 if (isset($boxes->mbxs
[0]) && $collapse_folders) {
308 $collapse = getPref($data_dir, $username, 'collapse_folder_' . $mailbox);
309 $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED
: $collapse);
311 $link = '<a target="left" style="text-decoration:none" ' .'href="left_main.php?';
313 $link .= "unfold=$mailboxURL\">$leader + ";
315 $link .= "fold=$mailboxURL\">$leader - ";
320 $pre.= $leader . ' ';
324 /* If there are unseen message, bold the line. */
325 if ($unseen > 0) { $pre .= '<B>'; }
327 if (($move_to_trash) && ($mailbox == $trash_folder)) {
328 if (! isset($numMessages)) {
329 $status = sqimap_status_messages($imapConnection, $mailbox);
330 $numMessages = $status['MESSAGES'];
333 if ($numMessages > 0) {
334 $urlMailbox = urlencode($mailbox);
335 $pre .= "\n<small>\n" .
336 " (<a href=\"empty_trash.php\" style=\"text-decoration:none\">"._("purge")."</a>)" .
340 if (!$boxes->is_noselect
) {
341 $pre .= "<a href=\"right_main.php?PG_SHOWALL=0&sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\">";
346 /* If there are unseen message, close bolding. */
347 if ($unseen > 0) { $end .= "</b>"; }
349 /* Print unseen information. */
350 if (isset($unseen_found) && $unseen_found) {
351 $end .= " <small>$unseen_string</small>";
356 if ($boxes->is_special
) {
357 $font = "<font color=\"$color[11]\">";
358 $fontend = "</font>";
361 if (!$boxes->is_root
) {
362 echo "" . $pre .$font. $boxes->mailboxname_sub
.$fontend . $end. '<br />';
365 if (!$collapse ||
$boxes->is_root
) {
366 for ($i = 0; $i <count($boxes->mbxs
); $i++
) {
367 listBoxes($boxes->mbxs
[$i],$j);
374 function ListAdvancedBoxes ($boxes, $mbx, $j='ID.0000' ) {
375 global $data_dir, $username, $startmessage, $color, $unseen_notify, $unseen_type,
376 $move_to_trash, $trash_folder, $collapse_folders;
378 /* use_folder_images only works if the images exist in ../images */
379 $use_folder_images = true;
386 $mailbox = $boxes->mailboxname_full
;
387 $mailboxURL = urlencode($mailbox);
389 /* get unseen/total messages information */
390 if ($boxes->unseen
) {
391 $unseen = $boxes->unseen
;
392 $unseen_string = "($unseen)";
393 if ($unseen>0) $unseen_found = TRUE;
395 $numMessages = $boxes->total
;
396 $unseen_string = "<font color=\"$color[11]\">($unseen/$numMessages)</font>";
400 /* If there are unseen message, bold the line. */
401 if ($unseen > 0) { $pre .= '<b>'; }
403 /* color special boxes */
404 if ($boxes->is_special
) {
405 $pre .= "<font color=\"$color[11]\">";
409 /* If there are unseen message, close bolding. */
410 if ($unseen > 0) { $end .= '</b>'; }
412 /* Print unseen information. */
413 if (isset($unseen_found) && $unseen_found) {
414 $end .= " $unseen_string";
417 if (($move_to_trash) && ($mailbox == $trash_folder)) {
418 if (! isset($numMessages)) {
419 $numMessages = $boxes->total
;
421 if ($numMessages > 0) {
422 $urlMailbox = urlencode($mailbox);
423 $pre .= "\n<small>\n" .
424 " (<a class=\"mbx_link\" href=\"empty_trash.php\">"._("purge")."</a>)" .
428 if (!$boxes->is_noselect
) { /* \Noselect boxes can't be selected */
429 $pre .= "<a class=\"mbx_link\" href=\"right_main.php?PG_SHOWALL=0&sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\">";
434 if (!$boxes->is_root
) {
435 if ($use_folder_images) {
436 if ($boxes->is_inbox
) {
437 $folder_img = '../images/inbox.gif';
438 } else if ($boxes->is_sent
) {
439 $folder_img = '../images/senti.gif';
440 } else if ($boxes->is_trash
) {
441 $folder_img = '../images/delitem.gif';
442 } else if ($boxes->is_draft
) {
443 $folder_img = '../images/draft.gif';
444 } else $folder_img = '../images/folder.gif';
445 $folder_img = ' <img src="'.$folder_img.'" height="15" valign="center" /> ';
446 } else $folder_img = '';
447 if (!isset($boxes->mbxs
[0])) {
448 echo ' ' . html_tag( 'div',
449 $pre . $folder_img . $boxes->mailboxname_sub
. $end ,
450 'left', '', 'class="mbx_sub" id="' .$j. '"' )
453 /* get collapse information */
454 if ($collapse_folders) {
455 $link = '<a target="left" style="text-decoration:none" ' .'href="left_main.php?';
456 $form_entry = $j.'F';
457 if (isset($mbx) && isset($mbx[$form_entry])) {
458 $collapse = $mbx[$form_entry];
460 setPref($data_dir, $username, 'collapse_folder_'.$boxes->mailboxname_full
, SM_BOX_COLLAPSED
);
462 setPref($data_dir, $username, 'collapse_folder_'.$boxes->mailboxname_full
, SM_BOX_UNCOLLAPSED
);
465 $collapse = getPref($data_dir, $username, 'collapse_folder_' . $mailbox);
466 $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED
: $collapse);
469 $link = '<a href="javascript:void(0)">'." <img src=\"../images/plus.gif\" border=\"1\" id=$j onclick=\"hidechilds(this)\" /></a>";
471 $link = '<a href="javascript:void(0)">'."<img src=\"../images/minus.gif\" border=\"1\" id=$j onclick=\"hidechilds(this)\" /></a>";
473 $collapse_link = $link;
474 } else $collapse_link='';
475 echo ' ' . html_tag( 'div',
476 $collapse_link . $pre . $folder_img . ' '. $boxes->mailboxname_sub
. $end ,
477 'left', '', 'class="mbx_par" id="' .$j. 'P"' )
479 echo ' <input type="hidden" name="mbx['.$j. 'F]" value="'.$collapse.'" id="mbx['.$j.'F]" />'."\n";
483 $visible = ' style="display:none;"';
485 $visible = ' style="display:block;"';
488 if (isset($boxes->mbxs
[0]) && !$boxes->is_root
) /* mailbox contains childs */
489 echo html_tag( 'div', '', 'left', '', 'class="par_area" id='.$j.'.0000 '. $visible ) . "\n";
491 if ($j !='ID.0000') {
494 for ($i = 0; $i <count($boxes->mbxs
); $i++
) {
496 listAdvancedBoxes($boxes->mbxs
[$i],$mbx,$j);
498 if (isset($boxes->mbxs
[0]) && !$boxes->is_root
) echo '</div>'."\n\n";
505 /* -------------------- MAIN ------------------------ */
508 sqgetGlobalVar('username', $username, SQ_SESSION
);
509 sqgetGlobalVar('key', $key, SQ_COOKIE
);
510 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION
);
511 sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION
);
513 sqgetGlobalVar('fold', $fold, SQ_GET
);
514 sqgetGlobalVar('unfold', $unfold, SQ_GET
);
518 // open a connection on the imap port (143)
519 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 10); // the 10 is to hide the output
522 * Using stristr since older preferences may contain "None" and "none".
524 if (isset($left_refresh) && ($left_refresh != '') &&
525 !stristr($left_refresh, 'none')){
526 $xtra = "\n<meta http-equiv=\"Expires\" content=\"Thu, 01 Dec 1994 16:00:00 GMT\" />\n" .
527 "<meta http-equiv=\"Pragma\" content=\"no-cache\" />\n".
528 "<meta http-equiv=\"REFRESH\" content=\"$left_refresh;URL=left_main.php\" />\n";
534 * $advanced_tree and $oldway are boolean vars which are default set to default
536 * Setting $oldway to false causes left_main.php to use the new experimental
537 * way of getting the mailbox-tree.
538 * Setting $advanced tree to true causes SM to display a experimental
539 * mailbox-tree with dhtml behaviour.
540 * It only works on browsers which supports css and javascript. The used
541 * javascript is experimental and doesn't support all browsers. It is tested on
542 * IE6 an Konquerer 3.0.0-2.
543 * In the function ListAdvancedBoxes there is another var $use_folder_images.
544 * setting this to true is only usefull if the images exists in ../images.
546 * Feel free to experiment with the code and report bugs and enhancements
547 * to marc@its-projects.nl
550 $advanced_tree = false; /* set this to true if you want to see a nicer mailboxtree */
551 $oldway = true; /* default SM behaviour */
553 if ($advanced_tree) {
555 <script language="Javascript" TYPE="text/javascript">
559 function hidechilds(el) {
561 form_id = "mbx[" + el.id +"F]";
563 ele = document.all[id];
565 if(ele.style.display == "none") {
566 ele.style.display = "block";
567 ele.style.visibility = "visible"
568 el.src="../images/minus.gif";
569 document.all[form_id].value=0;
571 ele.style.display = "none";
572 ele.style.visibility = "hidden"
573 el.src="../images/plus.gif";
574 document.all[form_id].value=1;
577 } else if (document.getElementById) {
578 ele = document.getElementById(id);
580 if(ele.style.display == "none") {
581 ele.style.display = "block";
582 ele.style.visibility = "visible"
583 el.src="../images/minus.gif";
584 document.getElementById(form_id).value=0;
586 ele.style.display = "none";
587 ele.style.visibility = "hidden"
588 el.src="../images/plus.gif";
589 document.getElementById(form_id).value=1;
596 if (!document.images) return;
597 var ar = new Array();
598 var arguments = preload.arguments;
599 for (var i = 0; i<arguments.length; i++) {
601 ar[i].src = arguments[i];
605 function buttonover(el,on) {
607 el.style.borderColor="blue";}
609 el.style.borderColor="orange";}
612 function buttonclick(el,on) {
614 el.style.border="groove"}
616 el.style.border="ridge";}
619 function hideframe(hide) {
622 $xtra .= " left_size = \"$left_size\";\n";
625 masterf = window.parent.document.all["fs1"];
626 leftf = window.parent.document.all["left"];
627 leftcontent = document.all["leftframe"];
628 leftbutton = document.all["showf"];
629 } else if (document.getElementById) {
630 masterf = window.parent.document.getElementById("fs1");
631 leftf = window.parent.document.getElementById("left");
632 leftcontent = document.getElementById("leftframe");
633 leftbutton = document.getElementById("showf");
638 new_col = calc_col("20");
639 masterf.cols = new_col;
640 document.body.scrollLeft=0;
641 document.body.style.overflow='hidden';
642 leftcontent.style.display = 'none';
643 leftbutton.style.display='block';
645 masterf.cols = calc_col(left_size);
646 document.body.style.overflow='';
647 leftbutton.style.display='none';
648 leftcontent.style.display='block';
653 function calc_col(c_w) {
656 if ($location_of_bar == 'right') {
657 $xtra .= ' right=true;';
659 $xtra .= ' right=false;';
671 function resizeframe(direction) {
673 masterf = window.parent.document.all["fs1"];
674 } else if (document.getElementById) {
675 window.parent.document.getElementById("fs1");
681 if ($location_of_bar == 'right') {
682 $xtra .= ' colPat=/^\*,(\d+)$/;';
684 $xtra .= ' colPat=/^(\d+),.*$/;';
689 old_col = masterf.cols;
690 colPat.exec(old_col);
693 new_col_width = parseInt(RegExp.$1) + 25;
696 if (parseInt(RegExp.$1) > 35) {
697 new_col_width = parseInt(RegExp.$1) - 25;
700 masterf.cols = calc_col(new_col_width);
709 /* style definitions */
713 <style type="text/css">
716 margin: 0px 0px 0px 0px;
717 padding: 5px 5px 5px 5px;
735 text-decoration: none;
736 background-color: $color[0];
741 background-color: $color[9];
763 border-left-width:0.1em;
764 border-left-color:blue;
765 border-bottom: solid;
766 border-bottom-width:0.1em;
767 border-bottom-color:blue;
780 background: $color[0];
794 displayHtmlHeader( 'SquirrelMail', $xtra );
796 /* If requested and not yet complete, attempt to autocreate folders. */
797 if ($auto_create_special && !isset($auto_create_done)) {
798 $autocreate = array($sent_folder, $trash_folder, $draft_folder);
799 foreach( $autocreate as $folder ) {
800 if (($folder != '') && ($folder != 'none')) {
801 if ( !sqimap_mailbox_exists($imapConnection, $folder)) {
802 sqimap_mailbox_create($imapConnection, $folder, '');
803 } else if (!sqimap_mailbox_is_subscribed($imapConnection, $folder)) {
804 sqimap_subscribe($imapConnection, $folder);
809 /* Let the world know that autocreation is complete! Hurrah! */
810 $auto_create_done = TRUE;
811 sqsession_register($auto_create_done, 'auto_create_done');
814 echo "\n<body bgcolor=\"$color[3]\" text=\"$color[6]\" link=\"$color[6]\" vlink=\"$color[6]\" alink=\"$color[6]\">\n";
816 do_hook('left_main_before');
817 if ($advanced_tree) {
818 /* nice future feature, needs layout !! volunteers? */
819 $right_pos = $left_size - 20;
820 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>';
821 echo '<div ID="showf" style="width=20;font-size:12;display:none;"><a href="javascript:hideframe(false)"><b>>></b></a></div>';
822 echo '<div ID="incrf" style="width=20;font-size:12"><a href="javascript:resizeframe(true)"><b>></b></a></div>';
823 echo '<div ID="decrf" style="width=20;font-size:12"><a href="javascript:resizeframe(false)"><b><</b></a></div></div>';
824 echo '<div ID="leftframe"><br /><br />';
827 echo "\n\n" . html_tag( 'table', '', 'left', '', 'border="0" cellspacing="0" cellpadding="0" width="99%"' ) .
829 html_tag( 'td', '', 'left' ) .
830 '<center><font size="4"><b>'. _("Folders") . "</b><br /></font>\n\n";
832 if ($date_format != 6) {
833 /* First, display the clock. */
834 if ($hour_format == 1) {
836 if ($date_format == 4) {
840 if ($date_format == 4) {
847 switch( $date_format ) {
849 $clk = date('m/d/y '.$hr, time());
852 $clk = date('d/m/y '.$hr, time());
856 $clk = date($hr, time());
859 $clk = substr( getDayName( date( 'w', time() ) ), 0, 3 ) . date( ', ' . $hr, time() );
861 $clk = str_replace(' ',' ',$clk);
863 echo '<center><small>' . str_replace(' ',' ',_("Last Refresh")) .
864 ": $clk</small></center>";
867 /* Next, display the refresh button. */
868 echo '<small>(<a href="../src/left_main.php" target="left">'.
869 _("refresh folder list") . '</a>)</small></center><br />';
871 /* Lastly, display the folder list. */
872 if ( $collapse_folders ) {
873 /* If directed, collapse or uncollapse a folder. */
875 setPref($data_dir, $username, 'collapse_folder_' . $fold, SM_BOX_COLLAPSED
);
876 } else if (isset($unfold)) {
877 setPref($data_dir, $username, 'collapse_folder_' . $unfold, SM_BOX_UNCOLLAPSED
);
881 if ($oldway) { /* normal behaviour SM */
883 $boxes = sqimap_mailbox_list($imapConnection);
884 /* Prepare do do out collapsedness and visibility computation. */
886 $boxcount = count($boxes);
888 /* Compute the collapsedness and visibility of each box. */
890 while ($curbox < $boxcount) {
891 $boxes[$curbox]['visible'] = TRUE;
892 compute_folder_children($curbox, $boxcount);
896 for ($i = 0; $i < count($boxes); $i++
) {
897 if ( $boxes[$i]['visible'] ) {
898 $mailbox = $boxes[$i]['formatted'];
899 $mblevel = substr_count($boxes[$i]['unformatted'], $delimiter) +
1;
901 /* Create the prefix for the folder name and link. */
902 $prefix = str_repeat(' ',$mblevel);
903 if (isset($collapse_folders) && $collapse_folders && $boxes[$i]['parent']) {
904 $prefix = str_replace(' ',' ',substr($prefix,0,strlen($prefix)-2)).
905 create_collapse_link($i) . ' ';
907 $prefix = str_replace(' ',' ',$prefix);
909 $line = "<nobr><tt>$prefix</tt>";
911 /* Add the folder name and link. */
912 if (! isset($color[15])) {
913 $color[15] = $color[6];
916 if (in_array('noselect', $boxes[$i]['flags'])) {
917 if( isSpecialMailbox( $boxes[$i]['unformatted']) ) {
918 $line .= "<font color=\"$color[11]\">";
920 $line .= "<font color=\"$color[15]\">";
922 if (ereg("^( *)([^ ]*)", $mailbox, $regs)) {
923 $mailbox = str_replace(' ','',$mailbox);
924 $line .= str_replace(' ', ' ', $mailbox);
928 $line .= formatMailboxName($imapConnection, $boxes[$i]);
931 /* Put the final touches on our folder line. */
932 $line .= "</nobr><br>\n";
934 /* Output the line for this folder. */
938 } else { /* expiremental code */
939 $boxes = sqimap_mailbox_tree($imapConnection);
940 if (isset($advanced_tree) && $advanced_tree) {
941 echo '<form name="collapse" action="left_main.php" method="post" ' .
942 'enctype="multipart/form-data"'."\n";
943 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 />';
944 echo '<div id="mailboxes" class="mailboxes">'."\n\n";
945 if (!isset($mbx)) $mbx=NULL;
946 ListAdvancedBoxes($boxes, $mbx);
947 echo '</div></small>'."\n";
952 } /* if ($oldway) else ... */
953 do_hook('left_main_after');
954 sqimap_logout($imapConnection);
956 echo '</td></tr></table>' . "\n".
957 "</div></body></html>\n";