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 for ($k = 0; $k < $j; $k++
) {
297 $leader.= ' ';
299 $mailboxURL = urlencode($mailbox);
301 /* get unseen/total messages information */
302 if ($boxes->unseen
) {
303 $unseen = $boxes->unseen
;
304 $unseen_string = "($unseen)";
306 $unseen_found = TRUE;
309 $unseen_before = '<font color="' . $color[11] . '">';
310 $unseen_after = '</font>';
312 if ((($unseen_notify == 2) && (strtolower($mailbox) == 'inbox')) ||
($unseen_notify == 3)) {
313 $unseen_string = '(' . $unseen;
315 if ($unseen_type > 1) {
316 $unseen_string .= '/' . $boxes->total
;
319 $unseen_string .= ')';
321 $unseen_string = $unseen_before . $unseen_string . $unseen_after;
328 if (isset($boxes->mbxs
[0]) && $collapse_folders) {
329 $collapse = getPref($data_dir, $username, 'collapse_folder_' . $mailbox);
330 $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED
: $collapse);
332 $link = '<a target="left" style="text-decoration:none" ' .'href="left_main.php?';
334 $link .= "unfold=$mailboxURL\">$leader + ";
336 $link .= "fold=$mailboxURL\">$leader - ";
341 $pre.= $leader . ' ';
344 /* If there are unseen message, bold the line. */
346 if (($move_to_trash) && ($mailbox == $trash_folder)) {
347 if (! isset($numMessages)) {
348 $status = sqimap_status_messages($imapConnection, $mailbox);
349 $numMessages = $status['MESSAGES'];
356 $pre .= "<a href=\"right_main.php?PG_SHOWALL=0&sort=0;startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\">";
363 if ($numMessages > 0) {
367 $pre .= "<a href=\"right_main.php?PG_SHOWALL=0&sort=0;startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\">";
371 $end .= "\n<small>\n" .
372 " (<a href=\"empty_trash.php\" style=\"text-decoration:none\">"._("purge")."</a>)" .
376 if (!$boxes->is_noselect
) {
380 $pre .= "<a href=\"right_main.php?PG_SHOWALL=0&sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\">";
388 /* Print unseen information. */
389 if (isset($unseen_found) && $unseen_found) {
390 $end .= " <small>$unseen_string</small>";
395 if ($boxes->is_special
) {
396 $font = "<font color=\"$color[11]\">";
397 $fontend = "</font>";
401 if (!$boxes->is_root
) {
402 echo "" . $pre .$font. $boxes->mailboxname_sub
.$fontend . $end. '<br />' . "\n";
406 if (!$collapse ||
$boxes->is_root
) {
407 for ($i = 0; $i <count($boxes->mbxs
); $i++
) {
408 listBoxes($boxes->mbxs
[$i],$j);
414 function ListAdvancedBoxes ($boxes, $mbx, $j='ID.0000' ) {
415 global $data_dir, $username, $startmessage, $color, $unseen_notify, $unseen_type,
416 $move_to_trash, $trash_folder, $collapse_folders;
418 /* use_folder_images only works if the images exist in ../images */
419 $use_folder_images = true;
426 $mailbox = $boxes->mailboxname_full
;
427 $mailboxURL = urlencode($mailbox);
429 /* get unseen/total messages information */
430 if ($boxes->unseen
) {
431 $unseen = $boxes->unseen
;
432 $unseen_string = "($unseen)";
433 if ($unseen>0) $unseen_found = TRUE;
435 $numMessages = $boxes->total
;
436 $unseen_string = "<font color=\"$color[11]\">($unseen/$numMessages)</font>";
440 /* If there are unseen message, bold the line. */
441 if ($unseen > 0) { $pre .= '<b>'; }
443 /* color special boxes */
444 if ($boxes->is_special
) {
445 $pre .= "<font color=\"$color[11]\">";
449 /* If there are unseen message, close bolding. */
450 if ($unseen > 0) { $end .= '</b>'; }
452 /* Print unseen information. */
453 if (isset($unseen_found) && $unseen_found) {
454 $end .= " $unseen_string";
457 if (($move_to_trash) && ($mailbox == $trash_folder)) {
458 if (! isset($numMessages)) {
459 $numMessages = $boxes->total
;
461 if ($numMessages > 0) {
462 $urlMailbox = urlencode($mailbox);
463 $pre .= "\n<small>\n" .
464 " (<a class=\"mbx_link\" href=\"empty_trash.php\">"._("purge")."</a>)" .
468 if (!$boxes->is_noselect
) { /* \Noselect boxes can't be selected */
469 $pre .= "<a class=\"mbx_link\" href=\"right_main.php?PG_SHOWALL=0&sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\">";
474 if (!$boxes->is_root
) {
475 if ($use_folder_images) {
476 if ($boxes->is_inbox
) {
477 $folder_img = '../images/inbox.gif';
478 } else if ($boxes->is_sent
) {
479 $folder_img = '../images/senti.gif';
480 } else if ($boxes->is_trash
) {
481 $folder_img = '../images/delitem.gif';
482 } else if ($boxes->is_draft
) {
483 $folder_img = '../images/draft.gif';
484 } else $folder_img = '../images/folder.gif';
485 $folder_img = ' <img src="'.$folder_img.'" height="15" valign="center" /> ';
486 } else $folder_img = '';
487 if (!isset($boxes->mbxs
[0])) {
488 echo ' ' . html_tag( 'div',
489 $pre . $folder_img . $boxes->mailboxname_sub
. $end ,
490 'left', '', 'class="mbx_sub" id="' .$j. '"' )
493 /* get collapse information */
494 if ($collapse_folders) {
495 $link = '<a target="left" style="text-decoration:none" ' .'href="left_main.php?';
496 $form_entry = $j.'F';
497 if (isset($mbx) && isset($mbx[$form_entry])) {
498 $collapse = $mbx[$form_entry];
500 setPref($data_dir, $username, 'collapse_folder_'.$boxes->mailboxname_full
, SM_BOX_COLLAPSED
);
502 setPref($data_dir, $username, 'collapse_folder_'.$boxes->mailboxname_full
, SM_BOX_UNCOLLAPSED
);
505 $collapse = getPref($data_dir, $username, 'collapse_folder_' . $mailbox);
506 $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED
: $collapse);
509 $link = '<a href="javascript:void(0)">'." <img src=\"../images/plus.gif\" border=\"1\" id=$j onclick=\"hidechilds(this)\" /></a>";
511 $link = '<a href="javascript:void(0)">'."<img src=\"../images/minus.gif\" border=\"1\" id=$j onclick=\"hidechilds(this)\" /></a>";
513 $collapse_link = $link;
514 } else $collapse_link='';
515 echo ' ' . html_tag( 'div',
516 $collapse_link . $pre . $folder_img . ' '. $boxes->mailboxname_sub
. $end ,
517 'left', '', 'class="mbx_par" id="' .$j. 'P"' )
519 echo ' <input type="hidden" name="mbx['.$j. 'F]" value="'.$collapse.'" id="mbx['.$j.'F]" />'."\n";
523 $visible = ' style="display:none;"';
525 $visible = ' style="display:block;"';
528 if (isset($boxes->mbxs
[0]) && !$boxes->is_root
) /* mailbox contains childs */
529 echo html_tag( 'div', '', 'left', '', 'class="par_area" id='.$j.'.0000 '. $visible ) . "\n";
531 if ($j !='ID.0000') {
534 for ($i = 0; $i <count($boxes->mbxs
); $i++
) {
536 listAdvancedBoxes($boxes->mbxs
[$i],$mbx,$j);
538 if (isset($boxes->mbxs
[0]) && !$boxes->is_root
) echo '</div>'."\n\n";
545 /* -------------------- MAIN ------------------------ */
548 sqgetGlobalVar('username', $username, SQ_SESSION
);
549 sqgetGlobalVar('key', $key, SQ_COOKIE
);
550 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION
);
551 sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION
);
553 sqgetGlobalVar('fold', $fold, SQ_GET
);
554 sqgetGlobalVar('unfold', $unfold, SQ_GET
);
558 // open a connection on the imap port (143)
559 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 10); // the 10 is to hide the output
562 * Using stristr since older preferences may contain "None" and "none".
564 if (isset($left_refresh) && ($left_refresh != '') &&
565 !stristr($left_refresh, 'none')){
566 $xtra = "\n<meta http-equiv=\"Expires\" content=\"Thu, 01 Dec 1994 16:00:00 GMT\" />\n" .
567 "<meta http-equiv=\"Pragma\" content=\"no-cache\" />\n".
568 "<meta http-equiv=\"REFRESH\" content=\"$left_refresh;URL=left_main.php\" />\n";
574 * $advanced_tree and $oldway are boolean vars which are default set to default
576 * Setting $oldway to false causes left_main.php to use the new experimental
577 * way of getting the mailbox-tree.
578 * Setting $advanced tree to true causes SM to display a experimental
579 * mailbox-tree with dhtml behaviour.
580 * It only works on browsers which supports css and javascript. The used
581 * javascript is experimental and doesn't support all browsers. It is tested on
582 * IE6 an Konquerer 3.0.0-2.
583 * In the function ListAdvancedBoxes there is another var $use_folder_images.
584 * setting this to true is only usefull if the images exists in ../images.
586 * Feel free to experiment with the code and report bugs and enhancements
587 * to marc@its-projects.nl
590 $advanced_tree = false; /* set this to true if you want to see a nicer mailboxtree */
591 $oldway = false; /* default SM behaviour */
593 if ($advanced_tree) {
595 <script language="Javascript" TYPE="text/javascript">
599 function hidechilds(el) {
601 form_id = "mbx[" + el.id +"F]";
603 ele = document.all[id];
605 if(ele.style.display == "none") {
606 ele.style.display = "block";
607 ele.style.visibility = "visible"
608 el.src="../images/minus.gif";
609 document.all[form_id].value=0;
611 ele.style.display = "none";
612 ele.style.visibility = "hidden"
613 el.src="../images/plus.gif";
614 document.all[form_id].value=1;
617 } else if (document.getElementById) {
618 ele = document.getElementById(id);
620 if(ele.style.display == "none") {
621 ele.style.display = "block";
622 ele.style.visibility = "visible"
623 el.src="../images/minus.gif";
624 document.getElementById(form_id).value=0;
626 ele.style.display = "none";
627 ele.style.visibility = "hidden"
628 el.src="../images/plus.gif";
629 document.getElementById(form_id).value=1;
636 if (!document.images) return;
637 var ar = new Array();
638 var arguments = preload.arguments;
639 for (var i = 0; i<arguments.length; i++) {
641 ar[i].src = arguments[i];
645 function buttonover(el,on) {
647 el.style.borderColor="blue";}
649 el.style.borderColor="orange";}
652 function buttonclick(el,on) {
654 el.style.border="groove"}
656 el.style.border="ridge";}
659 function hideframe(hide) {
662 $xtra .= " left_size = \"$left_size\";\n";
665 masterf = window.parent.document.all["fs1"];
666 leftf = window.parent.document.all["left"];
667 leftcontent = document.all["leftframe"];
668 leftbutton = document.all["showf"];
669 } else if (document.getElementById) {
670 masterf = window.parent.document.getElementById("fs1");
671 leftf = window.parent.document.getElementById("left");
672 leftcontent = document.getElementById("leftframe");
673 leftbutton = document.getElementById("showf");
678 new_col = calc_col("20");
679 masterf.cols = new_col;
680 document.body.scrollLeft=0;
681 document.body.style.overflow='hidden';
682 leftcontent.style.display = 'none';
683 leftbutton.style.display='block';
685 masterf.cols = calc_col(left_size);
686 document.body.style.overflow='';
687 leftbutton.style.display='none';
688 leftcontent.style.display='block';
693 function calc_col(c_w) {
696 if ($location_of_bar == 'right') {
697 $xtra .= ' right=true;';
699 $xtra .= ' right=false;';
711 function resizeframe(direction) {
713 masterf = window.parent.document.all["fs1"];
714 } else if (document.getElementById) {
715 window.parent.document.getElementById("fs1");
721 if ($location_of_bar == 'right') {
722 $xtra .= ' colPat=/^\*,(\d+)$/;';
724 $xtra .= ' colPat=/^(\d+),.*$/;';
729 old_col = masterf.cols;
730 colPat.exec(old_col);
733 new_col_width = parseInt(RegExp.$1) + 25;
736 if (parseInt(RegExp.$1) > 35) {
737 new_col_width = parseInt(RegExp.$1) - 25;
740 masterf.cols = calc_col(new_col_width);
749 /* style definitions */
753 <style type="text/css">
756 margin: 0px 0px 0px 0px;
757 padding: 5px 5px 5px 5px;
775 text-decoration: none;
776 background-color: $color[0];
781 background-color: $color[9];
803 border-left-width:0.1em;
804 border-left-color:blue;
805 border-bottom: solid;
806 border-bottom-width:0.1em;
807 border-bottom-color:blue;
820 background: $color[0];
834 displayHtmlHeader( 'SquirrelMail', $xtra );
836 /* If requested and not yet complete, attempt to autocreate folders. */
837 if ($auto_create_special && !isset($auto_create_done)) {
838 $autocreate = array($sent_folder, $trash_folder, $draft_folder);
839 foreach( $autocreate as $folder ) {
840 if (($folder != '') && ($folder != 'none')) {
841 if ( !sqimap_mailbox_exists($imapConnection, $folder)) {
842 sqimap_mailbox_create($imapConnection, $folder, '');
843 } else if (!sqimap_mailbox_is_subscribed($imapConnection, $folder)) {
844 sqimap_subscribe($imapConnection, $folder);
849 /* Let the world know that autocreation is complete! Hurrah! */
850 $auto_create_done = TRUE;
851 sqsession_register($auto_create_done, 'auto_create_done');
854 echo "\n<body bgcolor=\"$color[3]\" text=\"$color[6]\" link=\"$color[6]\" vlink=\"$color[6]\" alink=\"$color[6]\">\n";
856 do_hook('left_main_before');
857 if ($advanced_tree) {
858 /* nice future feature, needs layout !! volunteers? */
859 $right_pos = $left_size - 20;
860 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>';
861 echo '<div ID="showf" style="width=20;font-size:12;display:none;"><a href="javascript:hideframe(false)"><b>>></b></a></div>';
862 echo '<div ID="incrf" style="width=20;font-size:12"><a href="javascript:resizeframe(true)"><b>></b></a></div>';
863 echo '<div ID="decrf" style="width=20;font-size:12"><a href="javascript:resizeframe(false)"><b><</b></a></div></div>';
864 echo '<div ID="leftframe"><br /><br />';
867 echo "\n\n" . html_tag( 'table', '', 'left', '', 'border="0" cellspacing="0" cellpadding="0" width="99%"' ) .
869 html_tag( 'td', '', 'left' ) .
870 '<center><font size="4"><b>'. _("Folders") . "</b><br /></font>\n\n";
872 if ($date_format != 6) {
873 /* First, display the clock. */
874 if ($hour_format == 1) {
876 if ($date_format == 4) {
880 if ($date_format == 4) {
887 switch( $date_format ) {
889 $clk = date('m/d/y '.$hr, time());
892 $clk = date('d/m/y '.$hr, time());
896 $clk = date($hr, time());
899 $clk = substr( getDayName( date( 'w', time() ) ), 0, 3 ) . date( ', ' . $hr, time() );
901 $clk = str_replace(' ',' ',$clk);
903 echo '<center><small>' . str_replace(' ',' ',_("Last Refresh")) .
904 ": $clk</small></center>";
907 /* Next, display the refresh button. */
908 echo '<small>(<a href="../src/left_main.php" target="left">'.
909 _("refresh folder list") . '</a>)</small></center><br />';
911 /* Lastly, display the folder list. */
912 if ( $collapse_folders ) {
913 /* If directed, collapse or uncollapse a folder. */
915 setPref($data_dir, $username, 'collapse_folder_' . $fold, SM_BOX_COLLAPSED
);
916 } else if (isset($unfold)) {
917 setPref($data_dir, $username, 'collapse_folder_' . $unfold, SM_BOX_UNCOLLAPSED
);
921 if ($oldway) { /* normal behaviour SM */
923 $boxes = sqimap_mailbox_list($imapConnection);
924 /* Prepare do do out collapsedness and visibility computation. */
926 $boxcount = count($boxes);
928 /* Compute the collapsedness and visibility of each box. */
930 while ($curbox < $boxcount) {
931 $boxes[$curbox]['visible'] = TRUE;
932 compute_folder_children($curbox, $boxcount);
935 for ($i = 0; $i < count($boxes); $i++
) {
936 if ( $boxes[$i]['visible'] ) {
937 $mailbox = $boxes[$i]['formatted'];
938 $mblevel = substr_count($boxes[$i]['unformatted'], $delimiter) +
1;
940 /* Create the prefix for the folder name and link. */
941 $prefix = str_repeat(' ',$mblevel);
942 if (isset($collapse_folders) && $collapse_folders && $boxes[$i]['parent']) {
943 $prefix = str_replace(' ',' ',substr($prefix,0,strlen($prefix)-2)).
944 create_collapse_link($i) . ' ';
946 $prefix = str_replace(' ',' ',$prefix);
948 $line = "<nobr><tt>$prefix</tt>";
950 /* Add the folder name and link. */
951 if (! isset($color[15])) {
952 $color[15] = $color[6];
955 if (in_array('noselect', $boxes[$i]['flags'])) {
956 if( isSpecialMailbox( $boxes[$i]['unformatted']) ) {
957 $line .= "<font color=\"$color[11]\">";
959 $line .= "<font color=\"$color[15]\">";
961 if (ereg("^( *)([^ ]*)", $mailbox, $regs)) {
962 $mailbox = str_replace(' ','',$mailbox);
963 $line .= str_replace(' ', ' ', $mailbox);
967 $line .= formatMailboxName($imapConnection, $boxes[$i]);
970 /* Put the final touches on our folder line. */
971 $line .= "</nobr><br>\n";
973 /* Output the line for this folder. */
977 } else { /* expiremental code */
978 $boxes = sqimap_mailbox_tree($imapConnection);
979 if (isset($advanced_tree) && $advanced_tree) {
980 echo '<form name="collapse" action="left_main.php" method="post" ' .
981 'enctype="multipart/form-data"'."\n";
982 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 />';
983 echo '<div id="mailboxes" class="mailboxes">'."\n\n";
984 if (!isset($mbx)) $mbx=NULL;
985 ListAdvancedBoxes($boxes, $mbx);
986 echo '</div></small>'."\n";
991 } /* if ($oldway) else ... */
992 do_hook('left_main_after');
993 sqimap_logout($imapConnection);
995 echo '</td></tr></table>' . "\n".
996 "</div></body></html>\n";