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, $imapConnection;
289 /* Get unseen/total display prefs */
290 $unseen_type = getPref( $data_dir , $username , 'unseen_type' );
291 $unseen_notify = getPref( $data_dir , $username , 'unseen_notify' );
293 if (isset($boxes) && !empty($boxes)) {
294 $mailbox = $boxes->mailboxname_full
;
296 $leader .= str_repeat(' ',$j);
297 $mailboxURL = urlencode($mailbox);
299 /* get unseen/total messages information */
300 if ($boxes->unseen||
$boxes->total
) {
301 $unseen = $boxes->unseen
;
302 $unseen_string = "($unseen)";
303 if ($unseen>0||
$boxes->total
>0) {
304 $unseen_found = TRUE;
307 $unseen_before = '<font color="' . $color[11] . '">';
308 $unseen_after = '</font>';
310 if ((($unseen_notify == 2) && (strtolower($mailbox) == 'inbox')) ||
($unseen_notify == 3)) {
311 $unseen_string = '(' . $unseen;
313 if ($unseen_type > 1) {
314 $unseen_string .= '/' . $boxes->total
;
317 $unseen_string .= ')';
319 $unseen_string = $unseen_before . $unseen_string . $unseen_after;
325 if (isset($boxes->mbxs
[0]) && $collapse_folders) {
326 $collapse = getPref($data_dir, $username, 'collapse_folder_' . $mailbox);
327 $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED
: $collapse);
329 $link = '<a target="left" style="text-decoration:none" ' .'href="left_main.php?';
331 $link .= "unfold=$mailboxURL\">$leader+ </tt>";
333 $link .= "fold=$mailboxURL\">$leader- </tt>";
338 $pre.= $leader . ' </tt>';
341 /* If there are unseen message, bold the line. */
343 if (($move_to_trash) && ($mailbox == $trash_folder)) {
344 if (! isset($numMessages)) {
345 $status = sqimap_status_messages($imapConnection, $mailbox);
346 $numMessages = $status['MESSAGES'];
353 $pre .= "<a href=\"right_main.php?PG_SHOWALL=0&sort=0;startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\">";
360 if ($numMessages > 0) {
364 $pre .= "<a href=\"right_main.php?PG_SHOWALL=0&sort=0;startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\">";
368 $end .= "\n<small>\n" .
369 " (<a href=\"empty_trash.php\" style=\"text-decoration:none\">"._("purge")."</a>)" .
373 if (!$boxes->is_noselect
) {
377 $pre .= "<a href=\"right_main.php?PG_SHOWALL=0&sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\">";
385 /* Print unseen information. */
386 if (isset($unseen_found) && $unseen_found) {
387 $end .= " <small>$unseen_string</small>";
392 if ($boxes->is_special
) {
393 $font = "<font color=\"$color[11]\">";
394 $fontend = "</font>";
398 if (!$boxes->is_root
) {
399 echo "" . $pre .$font. $boxes->mailboxname_sub
.$fontend . $end. '<br />' . "\n";
403 if (!$collapse ||
$boxes->is_root
) {
404 for ($i = 0; $i <count($boxes->mbxs
); $i++
) {
405 listBoxes($boxes->mbxs
[$i],$j);
411 function ListAdvancedBoxes ($boxes, $mbx, $j='ID.0000' ) {
412 global $data_dir, $username, $startmessage, $color, $unseen_notify, $unseen_type,
413 $move_to_trash, $trash_folder, $collapse_folders;
415 /* use_folder_images only works if the images exist in ../images */
416 $use_folder_images = true;
423 $mailbox = $boxes->mailboxname_full
;
424 $mailboxURL = urlencode($mailbox);
426 /* get unseen/total messages information */
427 if ($boxes->unseen
) {
428 $unseen = $boxes->unseen
;
429 $unseen_string = "($unseen)";
430 if ($unseen>0) $unseen_found = TRUE;
432 $numMessages = $boxes->total
;
433 $unseen_string = "<font color=\"$color[11]\">($unseen/$numMessages)</font>";
437 /* If there are unseen message, bold the line. */
438 if ($unseen > 0) { $pre .= '<b>'; }
440 /* color special boxes */
441 if ($boxes->is_special
) {
442 $pre .= "<font color=\"$color[11]\">";
446 /* If there are unseen message, close bolding. */
447 if ($unseen > 0) { $end .= '</b>'; }
449 /* Print unseen information. */
450 if (isset($unseen_found) && $unseen_found) {
451 $end .= " $unseen_string";
454 if (($move_to_trash) && ($mailbox == $trash_folder)) {
455 if (! isset($numMessages)) {
456 $numMessages = $boxes->total
;
458 if ($numMessages > 0) {
459 $urlMailbox = urlencode($mailbox);
460 $pre .= "\n<small>\n" .
461 " (<a class=\"mbx_link\" href=\"empty_trash.php\">"._("purge")."</a>)" .
465 if (!$boxes->is_noselect
) { /* \Noselect boxes can't be selected */
466 $pre .= "<a class=\"mbx_link\" href=\"right_main.php?PG_SHOWALL=0&sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\">";
471 if (!$boxes->is_root
) {
472 if ($use_folder_images) {
473 if ($boxes->is_inbox
) {
474 $folder_img = '../images/inbox.gif';
475 } else if ($boxes->is_sent
) {
476 $folder_img = '../images/senti.gif';
477 } else if ($boxes->is_trash
) {
478 $folder_img = '../images/delitem.gif';
479 } else if ($boxes->is_draft
) {
480 $folder_img = '../images/draft.gif';
481 } else $folder_img = '../images/folder.gif';
482 $folder_img = ' <img src="'.$folder_img.'" height="15" valign="center" /> ';
483 } else $folder_img = '';
484 if (!isset($boxes->mbxs
[0])) {
485 echo ' ' . html_tag( 'div',
486 $pre . $folder_img . $boxes->mailboxname_sub
. $end ,
487 'left', '', 'class="mbx_sub" id="' .$j. '"' )
490 /* get collapse information */
491 if ($collapse_folders) {
492 $link = '<a target="left" style="text-decoration:none" ' .'href="left_main.php?';
493 $form_entry = $j.'F';
494 if (isset($mbx) && isset($mbx[$form_entry])) {
495 $collapse = $mbx[$form_entry];
497 setPref($data_dir, $username, 'collapse_folder_'.$boxes->mailboxname_full
, SM_BOX_COLLAPSED
);
499 setPref($data_dir, $username, 'collapse_folder_'.$boxes->mailboxname_full
, SM_BOX_UNCOLLAPSED
);
502 $collapse = getPref($data_dir, $username, 'collapse_folder_' . $mailbox);
503 $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED
: $collapse);
506 $link = '<a href="javascript:void(0)">'." <img src=\"../images/plus.gif\" border=\"1\" id=$j onclick=\"hidechilds(this)\" /></a>";
508 $link = '<a href="javascript:void(0)">'."<img src=\"../images/minus.gif\" border=\"1\" id=$j onclick=\"hidechilds(this)\" /></a>";
510 $collapse_link = $link;
511 } else $collapse_link='';
512 echo ' ' . html_tag( 'div',
513 $collapse_link . $pre . $folder_img . ' '. $boxes->mailboxname_sub
. $end ,
514 'left', '', 'class="mbx_par" id="' .$j. 'P"' )
516 echo ' <input type="hidden" name="mbx['.$j. 'F]" value="'.$collapse.'" id="mbx['.$j.'F]" />'."\n";
520 $visible = ' style="display:none;"';
522 $visible = ' style="display:block;"';
525 if (isset($boxes->mbxs
[0]) && !$boxes->is_root
) /* mailbox contains childs */
526 echo html_tag( 'div', '', 'left', '', 'class="par_area" id='.$j.'.0000 '. $visible ) . "\n";
528 if ($j !='ID.0000') {
531 for ($i = 0; $i <count($boxes->mbxs
); $i++
) {
533 listAdvancedBoxes($boxes->mbxs
[$i],$mbx,$j);
535 if (isset($boxes->mbxs
[0]) && !$boxes->is_root
) echo '</div>'."\n\n";
542 /* -------------------- MAIN ------------------------ */
545 sqgetGlobalVar('username', $username, SQ_SESSION
);
546 sqgetGlobalVar('key', $key, SQ_COOKIE
);
547 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION
);
548 sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION
);
550 sqgetGlobalVar('fold', $fold, SQ_GET
);
551 sqgetGlobalVar('unfold', $unfold, SQ_GET
);
555 // open a connection on the imap port (143)
556 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 10); // the 10 is to hide the output
559 * Using stristr since older preferences may contain "None" and "none".
561 if (isset($left_refresh) && ($left_refresh != '') &&
562 !stristr($left_refresh, 'none')){
563 $xtra = "\n<meta http-equiv=\"Expires\" content=\"Thu, 01 Dec 1994 16:00:00 GMT\" />\n" .
564 "<meta http-equiv=\"Pragma\" content=\"no-cache\" />\n".
565 "<meta http-equiv=\"REFRESH\" content=\"$left_refresh;URL=left_main.php\" />\n";
571 * $advanced_tree and $oldway are boolean vars which are default set to default
573 * Setting $oldway to false causes left_main.php to use the new experimental
574 * way of getting the mailbox-tree.
575 * Setting $advanced tree to true causes SM to display a experimental
576 * mailbox-tree with dhtml behaviour.
577 * It only works on browsers which supports css and javascript. The used
578 * javascript is experimental and doesn't support all browsers. It is tested on
579 * IE6 an Konquerer 3.0.0-2.
580 * In the function ListAdvancedBoxes there is another var $use_folder_images.
581 * setting this to true is only usefull if the images exists in ../images.
583 * Feel free to experiment with the code and report bugs and enhancements
584 * to marc@its-projects.nl
587 $advanced_tree = false; /* set this to true if you want to see a nicer mailboxtree */
588 $oldway = false; /* default SM behaviour */
590 if ($advanced_tree) {
592 <script language="Javascript" TYPE="text/javascript">
596 function hidechilds(el) {
598 form_id = "mbx[" + el.id +"F]";
600 ele = document.all[id];
602 if(ele.style.display == "none") {
603 ele.style.display = "block";
604 ele.style.visibility = "visible"
605 el.src="../images/minus.gif";
606 document.all[form_id].value=0;
608 ele.style.display = "none";
609 ele.style.visibility = "hidden"
610 el.src="../images/plus.gif";
611 document.all[form_id].value=1;
614 } else if (document.getElementById) {
615 ele = document.getElementById(id);
617 if(ele.style.display == "none") {
618 ele.style.display = "block";
619 ele.style.visibility = "visible"
620 el.src="../images/minus.gif";
621 document.getElementById(form_id).value=0;
623 ele.style.display = "none";
624 ele.style.visibility = "hidden"
625 el.src="../images/plus.gif";
626 document.getElementById(form_id).value=1;
633 if (!document.images) return;
634 var ar = new Array();
635 var arguments = preload.arguments;
636 for (var i = 0; i<arguments.length; i++) {
638 ar[i].src = arguments[i];
642 function buttonover(el,on) {
644 el.style.borderColor="blue";}
646 el.style.borderColor="orange";}
649 function buttonclick(el,on) {
651 el.style.border="groove"}
653 el.style.border="ridge";}
656 function hideframe(hide) {
659 $xtra .= " left_size = \"$left_size\";\n";
662 masterf = window.parent.document.all["fs1"];
663 leftf = window.parent.document.all["left"];
664 leftcontent = document.all["leftframe"];
665 leftbutton = document.all["showf"];
666 } else if (document.getElementById) {
667 masterf = window.parent.document.getElementById("fs1");
668 leftf = window.parent.document.getElementById("left");
669 leftcontent = document.getElementById("leftframe");
670 leftbutton = document.getElementById("showf");
675 new_col = calc_col("20");
676 masterf.cols = new_col;
677 document.body.scrollLeft=0;
678 document.body.style.overflow='hidden';
679 leftcontent.style.display = 'none';
680 leftbutton.style.display='block';
682 masterf.cols = calc_col(left_size);
683 document.body.style.overflow='';
684 leftbutton.style.display='none';
685 leftcontent.style.display='block';
690 function calc_col(c_w) {
693 if ($location_of_bar == 'right') {
694 $xtra .= ' right=true;';
696 $xtra .= ' right=false;';
708 function resizeframe(direction) {
710 masterf = window.parent.document.all["fs1"];
711 } else if (document.getElementById) {
712 window.parent.document.getElementById("fs1");
718 if ($location_of_bar == 'right') {
719 $xtra .= ' colPat=/^\*,(\d+)$/;';
721 $xtra .= ' colPat=/^(\d+),.*$/;';
726 old_col = masterf.cols;
727 colPat.exec(old_col);
730 new_col_width = parseInt(RegExp.$1) + 25;
733 if (parseInt(RegExp.$1) > 35) {
734 new_col_width = parseInt(RegExp.$1) - 25;
737 masterf.cols = calc_col(new_col_width);
746 /* style definitions */
750 <style type="text/css">
753 margin: 0px 0px 0px 0px;
754 padding: 5px 5px 5px 5px;
772 text-decoration: none;
773 background-color: $color[0];
778 background-color: $color[9];
800 border-left-width:0.1em;
801 border-left-color:blue;
802 border-bottom: solid;
803 border-bottom-width:0.1em;
804 border-bottom-color:blue;
817 background: $color[0];
831 displayHtmlHeader( 'SquirrelMail', $xtra );
833 /* If requested and not yet complete, attempt to autocreate folders. */
834 if ($auto_create_special && !isset($auto_create_done)) {
835 $autocreate = array($sent_folder, $trash_folder, $draft_folder);
836 foreach( $autocreate as $folder ) {
837 if (($folder != '') && ($folder != 'none')) {
838 if ( !sqimap_mailbox_exists($imapConnection, $folder)) {
839 sqimap_mailbox_create($imapConnection, $folder, '');
840 } else if (!sqimap_mailbox_is_subscribed($imapConnection, $folder)) {
841 sqimap_subscribe($imapConnection, $folder);
846 /* Let the world know that autocreation is complete! Hurrah! */
847 $auto_create_done = TRUE;
848 sqsession_register($auto_create_done, 'auto_create_done');
851 echo "\n<body bgcolor=\"$color[3]\" text=\"$color[6]\" link=\"$color[6]\" vlink=\"$color[6]\" alink=\"$color[6]\">\n";
853 do_hook('left_main_before');
854 if ($advanced_tree) {
855 /* nice future feature, needs layout !! volunteers? */
856 $right_pos = $left_size - 20;
857 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>';
858 echo '<div ID="showf" style="width=20;font-size:12;display:none;"><a href="javascript:hideframe(false)"><b>>></b></a></div>';
859 echo '<div ID="incrf" style="width=20;font-size:12"><a href="javascript:resizeframe(true)"><b>></b></a></div>';
860 echo '<div ID="decrf" style="width=20;font-size:12"><a href="javascript:resizeframe(false)"><b><</b></a></div></div>';
861 echo '<div ID="leftframe"><br /><br />';
864 echo "\n\n" . html_tag( 'table', '', 'left', '', 'border="0" cellspacing="0" cellpadding="0" width="99%"' ) .
866 html_tag( 'td', '', 'left' ) .
867 '<center><font size="4"><b>'. _("Folders") . "</b><br /></font>\n\n";
869 if ($date_format != 6) {
870 /* First, display the clock. */
871 if ($hour_format == 1) {
873 if ($date_format == 4) {
877 if ($date_format == 4) {
884 switch( $date_format ) {
886 $clk = date('m/d/y '.$hr, time());
889 $clk = date('d/m/y '.$hr, time());
893 $clk = date($hr, time());
896 $clk = substr( getDayName( date( 'w', time() ) ), 0, 3 ) . date( ', ' . $hr, time() );
898 $clk = str_replace(' ',' ',$clk);
900 echo '<center><small>' . str_replace(' ',' ',_("Last Refresh")) .
901 ": $clk</small></center>";
904 /* Next, display the refresh button. */
905 echo '<small>(<a href="../src/left_main.php" target="left">'.
906 _("refresh folder list") . '</a>)</small></center><br />';
908 /* Lastly, display the folder list. */
909 if ( $collapse_folders ) {
910 /* If directed, collapse or uncollapse a folder. */
912 setPref($data_dir, $username, 'collapse_folder_' . $fold, SM_BOX_COLLAPSED
);
913 } else if (isset($unfold)) {
914 setPref($data_dir, $username, 'collapse_folder_' . $unfold, SM_BOX_UNCOLLAPSED
);
918 if ($oldway) { /* normal behaviour SM */
920 $boxes = sqimap_mailbox_list($imapConnection);
921 /* Prepare do do out collapsedness and visibility computation. */
923 $boxcount = count($boxes);
925 /* Compute the collapsedness and visibility of each box. */
927 while ($curbox < $boxcount) {
928 $boxes[$curbox]['visible'] = TRUE;
929 compute_folder_children($curbox, $boxcount);
932 for ($i = 0; $i < count($boxes); $i++
) {
933 if ( $boxes[$i]['visible'] ) {
934 $mailbox = $boxes[$i]['formatted'];
935 $mblevel = substr_count($boxes[$i]['unformatted'], $delimiter) +
1;
937 /* Create the prefix for the folder name and link. */
938 $prefix = str_repeat(' ',$mblevel);
939 if (isset($collapse_folders) && $collapse_folders && $boxes[$i]['parent']) {
940 $prefix = str_replace(' ',' ',substr($prefix,0,strlen($prefix)-2)).
941 create_collapse_link($i) . ' ';
943 $prefix = str_replace(' ',' ',$prefix);
945 $line = "<nobr><tt>$prefix</tt>";
947 /* Add the folder name and link. */
948 if (! isset($color[15])) {
949 $color[15] = $color[6];
952 if (in_array('noselect', $boxes[$i]['flags'])) {
953 if( isSpecialMailbox( $boxes[$i]['unformatted']) ) {
954 $line .= "<font color=\"$color[11]\">";
956 $line .= "<font color=\"$color[15]\">";
958 if (ereg("^( *)([^ ]*)", $mailbox, $regs)) {
959 $mailbox = str_replace(' ','',$mailbox);
960 $line .= str_replace(' ', ' ', $mailbox);
964 $line .= formatMailboxName($imapConnection, $boxes[$i]);
967 /* Put the final touches on our folder line. */
968 $line .= "</nobr><br>\n";
970 /* Output the line for this folder. */
974 } else { /* expiremental code */
975 $boxes = sqimap_mailbox_tree($imapConnection);
976 if (isset($advanced_tree) && $advanced_tree) {
977 echo '<form name="collapse" action="left_main.php" method="post" ' .
978 'enctype="multipart/form-data"'."\n";
979 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 />';
980 echo '<div id="mailboxes" class="mailboxes">'."\n\n";
981 if (!isset($mbx)) $mbx=NULL;
982 ListAdvancedBoxes($boxes, $mbx);
983 echo '</div></small>'."\n";
988 } /* if ($oldway) else ... */
989 do_hook('left_main_after');
990 sqimap_logout($imapConnection);
992 echo '</td></tr></table>' . "\n".
993 "</div></body></html>\n";