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>)" .
103 $line .= concat_hook_function('left_main_after_each_folder',
104 array(isset($numMessages) ?
$numMessages : '',$real_box,$imapConnection));
108 /* Return the final product. */
113 * Recursive function that computes the collapsed status and parent
114 * (or not parent) status of this box, and the visiblity and collapsed
115 * status and parent (or not parent) status for all children boxes.
117 function compute_folder_children(&$parbox, $boxcount) {
118 global $boxes, $data_dir, $username, $collapse_folders;
119 $nextbox = $parbox +
1;
121 /* Retreive the name for the parent box. */
122 $parbox_name = $boxes[$parbox]['unformatted'];
124 /* 'Initialize' this parent box to childless. */
125 $boxes[$parbox]['parent'] = FALSE;
127 /* Compute the collapse status for this box. */
128 if( isset($collapse_folders) && $collapse_folders ) {
129 $collapse = getPref($data_dir, $username, 'collapse_folder_' . $parbox_name);
130 $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED
: $collapse);
132 $collapse = SM_BOX_UNCOLLAPSED
;
134 $boxes[$parbox]['collapse'] = $collapse;
136 /* Otherwise, get the name of the next box. */
137 if (isset($boxes[$nextbox]['unformatted'])) {
138 $nextbox_name = $boxes[$nextbox]['unformatted'];
143 /* Compute any children boxes for this box. */
144 while (($nextbox < $boxcount) &&
145 (is_parent_box($boxes[$nextbox]['unformatted'], $parbox_name))) {
147 /* Note that this 'parent' box has at least one child. */
148 $boxes[$parbox]['parent'] = TRUE;
150 /* Compute the visiblity of this box. */
151 $boxes[$nextbox]['visible'] = ($boxes[$parbox]['visible'] &&
152 ($boxes[$parbox]['collapse'] != SM_BOX_COLLAPSED
));
154 /* Compute the visibility of any child boxes. */
155 compute_folder_children($nextbox, $boxcount);
158 /* Set the parent box to the current next box. */
163 * Create the link for a parent folder that will allow that
164 * parent folder to either be collapsed or expaned, as is
165 * currently appropriate.
167 function create_collapse_link($boxnum) {
168 global $boxes, $imapConnection, $unseen_notify, $color;
169 $mailbox = urlencode($boxes[$boxnum]['unformatted']);
171 /* Create the link for this collapse link. */
172 $link = '<a target="left" style="text-decoration:none" ' .
173 'href="left_main.php?';
174 if ($boxes[$boxnum]['collapse'] == SM_BOX_COLLAPSED
) {
175 $link .= "unfold=$mailbox\">+";
177 $link .= "fold=$mailbox\">-";
181 $hooklink = do_hook_function('create_collapse_link',$link);
185 /* Return the finished product. */
190 * create_unseen_string:
192 * Create unseen and total message count for both this folder and
195 * @param string $boxName name of the current mailbox
196 * @param array $boxArray array for the current mailbox
197 * @param $imapConnection current imap connection in use
198 * @return array[0] unseen message string (for display)
199 * @return array[1] unseen message count
201 function create_unseen_string($boxName, $boxArray, $imapConnection, $unseen_type) {
202 global $boxes, $unseen_type, $color, $unseen_cum;
204 /* Initialize the return value. */
205 $result = array(0,0);
207 /* Initialize the counts for this folder. */
209 $boxMessageCount = 0;
210 $totalUnseenCount = 0;
211 $totalMessageCount = 0;
213 /* Collect the counts for this box alone. */
214 $status = sqimap_status_messages($imapConnection, $boxName);
215 $boxUnseenCount = $status['UNSEEN'];
216 if ($boxUnseenCount === false) {
219 if ($unseen_type == 2) {
220 $boxMessageCount = $status['MESSAGES'];
223 /* Initialize the total counts. */
225 if ($boxArray['collapse'] == SM_BOX_COLLAPSED
&& $unseen_cum) {
226 /* Collect the counts for this boxes subfolders. */
227 $curBoxLength = strlen($boxName);
228 $boxCount = count($boxes);
230 for ($i = 0; $i < $boxCount; ++
$i) {
231 /* Initialize the counts for this subfolder. */
233 $subMessageCount = 0;
235 /* Collect the counts for this subfolder. */
236 if (($boxName != $boxes[$i]['unformatted'])
237 && (substr($boxes[$i]['unformatted'], 0, $curBoxLength) == $boxName)
238 && !in_array('noselect', $boxes[$i]['flags'])) {
239 $status = sqimap_status_messages($imapConnection, $boxes[$i]['unformatted']);
240 $subUnseenCount = $status['UNSEEN'];
241 if ($unseen_type == 2) {
242 $subMessageCount = $status['MESSAGES'];;
244 /* Add the counts for this subfolder to the total. */
245 $totalUnseenCount +
= $subUnseenCount;
246 $totalMessageCount +
= $subMessageCount;
250 /* Add the counts for all subfolders to that of the box. */
251 $boxUnseenCount +
= $totalUnseenCount;
252 $boxMessageCount +
= $totalMessageCount;
255 /* And create the magic unseen count string. */
256 /* Really a lot more then just the unseen count. */
257 if (($unseen_type == 1) && ($boxUnseenCount > 0)) {
258 $result[0] = "($boxUnseenCount)";
259 } else if ($unseen_type == 2) {
260 $result[0] = "($boxUnseenCount/$boxMessageCount)";
261 $result[0] = "<font color=\"$color[11]\">$result[0]</font>";
264 /* Set the unseen count to return to the outside world. */
265 $result[1] = $boxUnseenCount;
267 /* Return our happy result. */
272 * This simple function checks if a box is another box's parent.
274 function is_parent_box($curbox_name, $parbox_name) {
277 /* Extract the name of the parent of the current box. */
278 $curparts = explode($delimiter, $curbox_name);
279 $curname = array_pop($curparts);
280 $actual_parname = implode($delimiter, $curparts);
281 $actual_parname = substr($actual_parname,0,strlen($parbox_name));
283 /* Compare the actual with the given parent name. */
284 return ($parbox_name == $actual_parname);
287 function listBoxes ($boxes, $j=0 ) {
288 global $data_dir, $username, $startmessage, $color, $unseen_notify, $unseen_type,
289 $move_to_trash, $trash_folder, $collapse_folders, $imapConnection;
297 /* Get unseen/total display prefs */
298 $unseen_type = getPref( $data_dir , $username , 'unseen_type' );
299 $unseen_notify = getPref( $data_dir , $username , 'unseen_notify' );
301 if (isset($boxes) && !empty($boxes)) {
302 $mailbox = $boxes->mailboxname_full
;
304 $leader .= str_repeat(' ',$j);
305 $mailboxURL = urlencode($mailbox);
307 /* get unseen/total messages information */
308 /* Only need to display info when option is set */
309 if (isset($unseen_notify) && ($unseen_notify > 1)) {
311 if ($boxes->unseen
!== false) {
312 $unseen = $boxes->unseen
;
318 Should only display unseen info if the folder is inbox
319 or you set the option for all folders
322 if ((strtolower($mailbox) == 'inbox') ||
($unseen_notify == 3)) {
323 $unseen_string = $unseen;
326 /* If users requests, display message count too */
327 if (isset($unseen_type) && ($unseen_type == 2)) {
328 $numMessages = $boxes->total
;
329 $unseen_string .= '/' . $numMessages;
332 $unseen_string = "<font color=\"$color[11]\">($unseen_string)</font>";
335 Finally allow the script to display the values by setting a boolean.
336 This can only occur if the unseen count is great than 0 (if you have
337 unseen count only), or you have the message count too.
339 if (($unseen > 0) ||
(isset($unseen_type) && ($unseen_type ==2))) {
340 $unseen_found = true;
347 if (isset($boxes->mbxs
[0]) && $collapse_folders) {
348 $collapse = getPref($data_dir, $username, 'collapse_folder_' . $mailbox);
349 $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED
: $collapse);
351 $link = '<a target="left" style="text-decoration:none" ' .'href="left_main.php?';
353 $link .= "unfold=$mailboxURL\">$leader+ </tt>";
355 $link .= "fold=$mailboxURL\">$leader- </tt>";
360 $pre.= $leader . ' </tt>';
363 /* If there are unseen message, bold the line. */
364 if (($move_to_trash) && ($mailbox == $trash_folder)) {
365 if (! isset($boxes->total
)) {
366 $boxes->total
= sqimap_status_messages($imapConnection, $mailbox);
371 $pre .= "<a href=\"right_main.php?PG_SHOWALL=0&sort=0;startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\">";
376 if ($boxes->total
> 0) {
380 $pre .= "<a href=\"right_main.php?PG_SHOWALL=0&sort=0;startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\">";
384 $end .= "\n<small>\n" .
385 " (<a href=\"empty_trash.php\" style=\"text-decoration:none\">"._("purge")."</a>)" .
389 if (!$boxes->is_noselect ||
strtolower($boxes->mailboxname_full
)=="inbox") {
393 $pre .= "<a href=\"right_main.php?PG_SHOWALL=0&sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\">";
401 /* Print unseen information. */
402 if (isset($unseen_found) && $unseen_found) {
403 $end .= " <small>$unseen_string</small>";
408 if ($boxes->is_special
) {
409 $font = "<font color=\"$color[11]\">";
410 $fontend = "</font>";
414 if (!$boxes->is_root
) {
415 echo "" . $pre .$font. $boxes->mailboxname_sub
.$fontend . $end. '<br />' . "\n";
419 if (!$collapse ||
$boxes->is_root
) {
420 for ($i = 0; $i <count($boxes->mbxs
); $i++
) {
421 listBoxes($boxes->mbxs
[$i],$j);
427 function ListAdvancedBoxes ($boxes, $mbx, $j='ID.0000' ) {
428 global $data_dir, $username, $startmessage, $color, $unseen_notify, $unseen_type,
429 $move_to_trash, $trash_folder, $collapse_folders;
431 /* use_folder_images only works if the images exist in ../images */
432 $use_folder_images = true;
437 $unseen_found = false;
441 $mailbox = $boxes->mailboxname_full
;
442 $mailboxURL = urlencode($mailbox);
444 /* Only need to display info when option is set */
445 if (isset($unseen_notify) && ($unseen_notify > 1)) {
447 if ($boxes->unseen
!== false) {
448 $unseen = $boxes->unseen
;
454 Should only display unseen info if the folder is inbox
455 or you set the option for all folders
458 if ((strtolower($mailbox) == 'inbox') ||
($unseen_notify == 3)) {
459 $unseen_string = $unseen;
462 /* If users requests, display message count too */
463 if (isset($unseen_type) && ($unseen_type == 2)) {
464 $numMessages = $boxes->total
;
465 $unseen_string .= '/' . $numMessages;
468 $unseen_string = "<font color=\"$color[11]\">($unseen_string)</font>";
471 Finally allow the script to display the values by setting a boolean.
472 This can only occur if the unseen count is great than 0 (if you have
473 unseen count only), or you have the message count too.
475 if (($unseen > 0) ||
(isset($unseen_type) && ($unseen_type ==2))) {
476 $unseen_found = true;
483 /* If there are unseen message, bold the line. */
484 if ($unseen > 0) { $pre .= '<b>'; }
486 /* color special boxes */
487 if ($boxes->is_special
) {
488 $pre .= "<font color=\"$color[11]\">";
492 /* If there are unseen message, close bolding. */
493 if ($unseen > 0) { $end .= '</b>'; }
495 /* Print unseen information. */
496 if (isset($unseen_found) && $unseen_found) {
497 $end .= " $unseen_string";
500 if (($move_to_trash) && ($mailbox == $trash_folder)) {
501 if (! isset($numMessages)) {
502 $numMessages = $boxes->total
;
504 if ($numMessages > 0) {
505 $urlMailbox = urlencode($mailbox);
506 $end .= "\n<small>\n" .
507 " (<a class=\"mbx_link\" href=\"empty_trash.php\">"._("purge")."</a>)" .
511 if (!$boxes->is_noselect
) { /* \Noselect boxes can't be selected */
512 $pre .= "<a class=\"mbx_link\" href=\"right_main.php?PG_SHOWALL=0&sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\">";
517 if (!$boxes->is_root
) {
518 if ($use_folder_images) {
519 if ($boxes->is_inbox
) {
520 $folder_img = '../images/inbox.png';
521 } else if ($boxes->is_sent
) {
522 $folder_img = '../images/senti.png';
523 } else if ($boxes->is_trash
) {
524 $folder_img = '../images/delitem.png';
525 } else if ($boxes->is_draft
) {
526 $folder_img = '../images/draft.png';
527 } else $folder_img = '../images/folder.png';
528 $folder_img = ' <img src="'.$folder_img.'" height="15" valign="center" /> ';
529 } else $folder_img = '';
530 if (!isset($boxes->mbxs
[0])) {
531 echo ' ' . html_tag( 'div',
532 $pre . $folder_img . $boxes->mailboxname_sub
. $end ,
533 'left', '', 'class="mbx_sub" id="' .$j. '"' )
536 /* get collapse information */
537 if ($collapse_folders) {
538 $link = '<a target="left" style="text-decoration:none" ' .'href="left_main.php?';
539 $form_entry = $j.'F';
540 if (isset($mbx) && isset($mbx[$form_entry])) {
541 $collapse = $mbx[$form_entry];
543 setPref($data_dir, $username, 'collapse_folder_'.$boxes->mailboxname_full
, SM_BOX_COLLAPSED
);
545 setPref($data_dir, $username, 'collapse_folder_'.$boxes->mailboxname_full
, SM_BOX_UNCOLLAPSED
);
548 $collapse = getPref($data_dir, $username, 'collapse_folder_' . $mailbox);
549 $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED
: $collapse);
552 $link = '<a href="javascript:void(0)">'." <img src=\"../images/plus.png\" border=\"1\" id=$j onclick=\"hidechilds(this)\" /></a>";
554 $link = '<a href="javascript:void(0)">'."<img src=\"../images/minus.png\" border=\"1\" id=$j onclick=\"hidechilds(this)\" /></a>";
556 $collapse_link = $link;
557 } else $collapse_link='';
558 echo ' ' . html_tag( 'div',
559 $collapse_link . $pre . $folder_img . ' '. $boxes->mailboxname_sub
. $end ,
560 'left', '', 'class="mbx_par" id="' .$j. 'P"' )
562 echo ' <input type="hidden" name="mbx['.$j. 'F]" value="'.$collapse.'" id="mbx['.$j.'F]" />'."\n";
566 $visible = ' style="display:none;"';
568 $visible = ' style="display:block;"';
571 if (isset($boxes->mbxs
[0]) && !$boxes->is_root
) /* mailbox contains childs */
572 echo html_tag( 'div', '', 'left', '', 'class="par_area" id='.$j.'.0000 '. $visible ) . "\n";
574 if ($j !='ID.0000') {
577 for ($i = 0; $i <count($boxes->mbxs
); $i++
) {
579 listAdvancedBoxes($boxes->mbxs
[$i],$mbx,$j);
581 if (isset($boxes->mbxs
[0]) && !$boxes->is_root
) echo '</div>'."\n\n";
588 /* -------------------- MAIN ------------------------ */
591 sqgetGlobalVar('username', $username, SQ_SESSION
);
592 sqgetGlobalVar('key', $key, SQ_COOKIE
);
593 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION
);
594 sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION
);
596 sqgetGlobalVar('fold', $fold, SQ_GET
);
597 sqgetGlobalVar('unfold', $unfold, SQ_GET
);
601 // open a connection on the imap port (143)
602 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 10); // the 10 is to hide the output
605 * Using stristr since older preferences may contain "None" and "none".
607 if (isset($left_refresh) && ($left_refresh != '') &&
608 !stristr($left_refresh, 'none')){
609 $xtra = "\n<meta http-equiv=\"Expires\" content=\"Thu, 01 Dec 1994 16:00:00 GMT\" />\n" .
610 "<meta http-equiv=\"Pragma\" content=\"no-cache\" />\n".
611 "<meta http-equiv=\"REFRESH\" content=\"$left_refresh;URL=left_main.php\" />\n";
617 * $advanced_tree and $oldway are boolean vars which are default set to default
619 * Setting $oldway to false causes left_main.php to use the new experimental
620 * way of getting the mailbox-tree.
621 * Setting $advanced tree to true causes SM to display a experimental
622 * mailbox-tree with dhtml behaviour.
623 * It only works on browsers which supports css and javascript. The used
624 * javascript is experimental and doesn't support all browsers. It is tested on
625 * IE6 an Konquerer 3.0.0-2.
626 * In the function ListAdvancedBoxes there is another var $use_folder_images.
627 * setting this to true is only usefull if the images exists in ../images.
629 * Feel free to experiment with the code and report bugs and enhancements
630 * to marc@its-projects.nl
633 $advanced_tree = false; /* set this to true if you want to see a nicer mailboxtree */
634 $oldway = false; /* default SM behaviour */
636 if ($advanced_tree) {
638 <script language="Javascript" TYPE="text/javascript">
642 function hidechilds(el) {
644 form_id = "mbx[" + el.id +"F]";
646 ele = document.all[id];
648 if(ele.style.display == "none") {
649 ele.style.display = "block";
650 ele.style.visibility = "visible"
651 el.src="../images/minus.png";
652 document.all[form_id].value=0;
654 ele.style.display = "none";
655 ele.style.visibility = "hidden"
656 el.src="../images/plus.png";
657 document.all[form_id].value=1;
660 } else if (document.getElementById) {
661 ele = document.getElementById(id);
663 if(ele.style.display == "none") {
664 ele.style.display = "block";
665 ele.style.visibility = "visible"
666 el.src="../images/minus.png";
667 document.getElementById(form_id).value=0;
669 ele.style.display = "none";
670 ele.style.visibility = "hidden"
671 el.src="../images/plus.png";
672 document.getElementById(form_id).value=1;
679 if (!document.images) return;
680 var ar = new Array();
681 var arguments = preload.arguments;
682 for (var i = 0; i<arguments.length; i++) {
684 ar[i].src = arguments[i];
688 function buttonover(el,on) {
690 el.style.borderColor="blue";}
692 el.style.borderColor="orange";}
695 function buttonclick(el,on) {
697 el.style.border="groove"}
699 el.style.border="ridge";}
702 function hideframe(hide) {
705 $xtra .= " left_size = \"$left_size\";\n";
708 masterf = window.parent.document.all["fs1"];
709 leftf = window.parent.document.all["left"];
710 leftcontent = document.all["leftframe"];
711 leftbutton = document.all["showf"];
712 } else if (document.getElementById) {
713 masterf = window.parent.document.getElementById("fs1");
714 leftf = window.parent.document.getElementById("left");
715 leftcontent = document.getElementById("leftframe");
716 leftbutton = document.getElementById("showf");
721 new_col = calc_col("20");
722 masterf.cols = new_col;
723 document.body.scrollLeft=0;
724 document.body.style.overflow='hidden';
725 leftcontent.style.display = 'none';
726 leftbutton.style.display='block';
728 masterf.cols = calc_col(left_size);
729 document.body.style.overflow='';
730 leftbutton.style.display='none';
731 leftcontent.style.display='block';
736 function calc_col(c_w) {
739 if ($location_of_bar == 'right') {
740 $xtra .= ' right=true;';
742 $xtra .= ' right=false;';
754 function resizeframe(direction) {
756 masterf = window.parent.document.all["fs1"];
757 } else if (document.getElementById) {
758 window.parent.document.getElementById("fs1");
764 if ($location_of_bar == 'right') {
765 $xtra .= ' colPat=/^\*,(\d+)$/;';
767 $xtra .= ' colPat=/^(\d+),.*$/;';
772 old_col = masterf.cols;
773 colPat.exec(old_col);
776 new_col_width = parseInt(RegExp.$1) + 25;
779 if (parseInt(RegExp.$1) > 35) {
780 new_col_width = parseInt(RegExp.$1) - 25;
783 masterf.cols = calc_col(new_col_width);
792 /* style definitions */
796 <style type="text/css">
799 margin: 0px 0px 0px 0px;
800 padding: 5px 5px 5px 5px;
818 text-decoration: none;
819 background-color: $color[0];
824 background-color: $color[9];
846 border-left-width:0.1em;
847 border-left-color:blue;
848 border-bottom: solid;
849 border-bottom-width:0.1em;
850 border-bottom-color:blue;
863 background: $color[0];
877 displayHtmlHeader( 'SquirrelMail', $xtra );
879 /* If requested and not yet complete, attempt to autocreate folders. */
880 if ($auto_create_special && !isset($auto_create_done)) {
881 $autocreate = array($sent_folder, $trash_folder, $draft_folder);
882 foreach( $autocreate as $folder ) {
883 if (($folder != '') && ($folder != 'none')) {
884 if ( !sqimap_mailbox_exists($imapConnection, $folder)) {
885 sqimap_mailbox_create($imapConnection, $folder, '');
886 } else if (!sqimap_mailbox_is_subscribed($imapConnection, $folder)) {
887 sqimap_subscribe($imapConnection, $folder);
892 /* Let the world know that autocreation is complete! Hurrah! */
893 $auto_create_done = TRUE;
894 sqsession_register($auto_create_done, 'auto_create_done');
897 echo "\n<body bgcolor=\"$color[3]\" text=\"$color[6]\" link=\"$color[6]\" vlink=\"$color[6]\" alink=\"$color[6]\">\n";
899 do_hook('left_main_before');
900 if ($advanced_tree) {
901 /* nice future feature, needs layout !! volunteers? */
902 $right_pos = $left_size - 20;
903 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>';
904 echo '<div ID="showf" style="width=20;font-size:12;display:none;"><a href="javascript:hideframe(false)"><b>>></b></a></div>';
905 echo '<div ID="incrf" style="width=20;font-size:12"><a href="javascript:resizeframe(true)"><b>></b></a></div>';
906 echo '<div ID="decrf" style="width=20;font-size:12"><a href="javascript:resizeframe(false)"><b><</b></a></div></div>';
907 echo '<div ID="leftframe"><br /><br />';
910 echo "\n\n" . html_tag( 'table', '', 'left', '', 'border="0" cellspacing="0" cellpadding="0" width="99%"' ) .
912 html_tag( 'td', '', 'left' ) .
913 '<center><font size="4"><b>'. _("Folders") . "</b><br /></font>\n\n";
915 if ($date_format != 6) {
916 /* First, display the clock. */
917 if ($hour_format == 1) {
919 if ($date_format == 4) {
923 if ($date_format == 4) {
930 switch( $date_format ) {
932 $clk = date('m/d/y '.$hr, time());
935 $clk = date('d/m/y '.$hr, time());
939 $clk = date($hr, time());
942 $clk = substr( getDayName( date( 'w', time() ) ), 0, 3 ) . date( ', ' . $hr, time() );
944 $clk = str_replace(' ',' ',$clk);
946 echo '<center><small>' . str_replace(' ',' ',_("Last Refresh")) .
947 ": $clk</small></center>";
950 /* Next, display the refresh button. */
951 echo '<small>(<a href="../src/left_main.php" target="left">'.
952 _("refresh folder list") . '</a>)</small></center><br />';
954 /* Lastly, display the folder list. */
955 if ( $collapse_folders ) {
956 /* If directed, collapse or uncollapse a folder. */
958 setPref($data_dir, $username, 'collapse_folder_' . $fold, SM_BOX_COLLAPSED
);
959 } else if (isset($unfold)) {
960 setPref($data_dir, $username, 'collapse_folder_' . $unfold, SM_BOX_UNCOLLAPSED
);
964 if ($oldway) { /* normal behaviour SM */
966 $boxes = sqimap_mailbox_list($imapConnection);
967 /* Prepare do do out collapsedness and visibility computation. */
969 $boxcount = count($boxes);
971 /* Compute the collapsedness and visibility of each box. */
973 while ($curbox < $boxcount) {
974 $boxes[$curbox]['visible'] = TRUE;
975 compute_folder_children($curbox, $boxcount);
978 for ($i = 0; $i < count($boxes); $i++
) {
979 if ( $boxes[$i]['visible'] ) {
980 $mailbox = $boxes[$i]['formatted'];
981 $mblevel = substr_count($boxes[$i]['unformatted'], $delimiter) +
1;
983 /* Create the prefix for the folder name and link. */
984 $prefix = str_repeat(' ',$mblevel);
985 if (isset($collapse_folders) && $collapse_folders && $boxes[$i]['parent']) {
986 $prefix = str_replace(' ',' ',substr($prefix,0,strlen($prefix)-2)).
987 create_collapse_link($i) . ' ';
989 $prefix = str_replace(' ',' ',$prefix);
991 $line = "<nobr><tt>$prefix</tt>";
993 /* Add the folder name and link. */
994 if (! isset($color[15])) {
995 $color[15] = $color[6];
998 if (in_array('noselect', $boxes[$i]['flags'])) {
999 if( isSpecialMailbox( $boxes[$i]['unformatted']) ) {
1000 $line .= "<font color=\"$color[11]\">";
1002 $line .= "<font color=\"$color[15]\">";
1004 if (ereg("^( *)([^ ]*)", $mailbox, $regs)) {
1005 $mailbox = str_replace(' ','',$mailbox);
1006 $line .= str_replace(' ', ' ', $mailbox);
1010 $line .= formatMailboxName($imapConnection, $boxes[$i]);
1013 /* Put the final touches on our folder line. */
1014 $line .= "</nobr><br>\n";
1016 /* Output the line for this folder. */
1020 } else { /* expiremental code */
1021 $boxes = sqimap_mailbox_tree($imapConnection);
1022 if (isset($advanced_tree) && $advanced_tree) {
1023 echo '<form name="collapse" action="left_main.php" method="post" ' .
1024 'enctype="multipart/form-data"'."\n";
1025 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 />';
1026 echo '<div id="mailboxes" class="mailboxes">'."\n\n";
1027 if (!isset($mbx)) $mbx=NULL;
1028 ListAdvancedBoxes($boxes, $mbx);
1029 echo '</div></small>'."\n";
1030 echo '</form>'."\n";
1032 //sqimap_get_status_mbx_tree($imap_stream,$boxes)
1035 } /* if ($oldway) else ... */
1036 do_hook('left_main_after');
1037 sqimap_logout($imapConnection);
1039 echo '</td></tr></table>' . "\n".
1040 "</div></body></html>\n";