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');
24 require_once(SM_PATH
. 'functions/date.php');
26 /* These constants are used for folder stuff. */
27 define('SM_BOX_UNCOLLAPSED', 0);
28 define('SM_BOX_COLLAPSED', 1);
30 /* --------------------- FUNCTIONS ------------------------- */
32 function formatMailboxName($imapConnection, $box_array) {
34 global $folder_prefix, $trash_folder, $sent_folder,
35 $color, $move_to_sent, $move_to_trash,
36 $unseen_notify, $unseen_type, $collapse_folders,
37 $draft_folder, $save_as_draft,
38 $use_special_folder_color;
39 $real_box = $box_array['unformatted'];
40 $mailbox = str_replace(' ','',$box_array['formatted']);
41 $mailboxURL = urlencode($real_box);
43 /* Strip down the mailbox name. */
44 if (ereg("^( *)([^ ]*)$", $mailbox, $regs)) {
48 $status = array('','');
49 if (($unseen_notify == 2 && $real_box == 'INBOX') ||
50 $unseen_notify == 3) {
51 $tmp_status = create_unseen_string($real_box, $box_array, $imapConnection, $unseen_type );
52 if ($status !== false) {
53 $status = $tmp_status;
56 list($unseen_string, $unseen) = $status;
57 $special_color = ($use_special_folder_color && isSpecialMailbox($real_box));
59 /* Start off with a blank line. */
62 /* If there are unseen message, bold the line. */
63 if ($unseen > 0) { $line .= '<B>'; }
65 /* Create the link for this folder. */
66 if ($status !== false) {
67 $line .= '<a href="right_main.php?PG_SHOWALL=0&sort=0&startMessage=1&mailbox='.
68 $mailboxURL.'" TARGET="right" STYLE="text-decoration:none">';
71 $line .= "<font color=\"$color[11]\">";
73 if ( $mailbox == 'INBOX' ) {
76 $line .= str_replace(' ',' ',$mailbox);
78 if ($special_color == TRUE)
80 if ($status !== false) {
84 /* If there are unseen message, close bolding. */
85 if ($unseen > 0) { $line .= "</B>"; }
87 /* Print unseen information. */
88 if ($unseen_string != '') {
89 $line .= " <SMALL>$unseen_string</SMALL>";
92 /* If it's the trash folder, show a purge link when needed */
93 if (($move_to_trash) && ($real_box == $trash_folder)) {
94 if (! isset($numMessages)) {
95 $numMessages = sqimap_get_num_messages($imapConnection, $real_box);
98 if (($numMessages > 0) or ($box_array['parent'] == 1)) {
99 $urlMailbox = urlencode($real_box);
100 $line .= "\n<small>\n" .
101 " (<A HREF=\"empty_trash.php\" style=\"text-decoration:none\">"._("purge")."</A>)" .
104 $line .= concat_hook_function('left_main_after_each_folder',
105 array(isset($numMessages) ?
$numMessages : '',$real_box,$imapConnection));
109 /* Return the final product. */
114 * Recursive function that computes the collapsed status and parent
115 * (or not parent) status of this box, and the visiblity and collapsed
116 * status and parent (or not parent) status for all children boxes.
118 function compute_folder_children(&$parbox, $boxcount) {
119 global $boxes, $data_dir, $username, $collapse_folders;
120 $nextbox = $parbox +
1;
122 /* Retreive the name for the parent box. */
123 $parbox_name = $boxes[$parbox]['unformatted'];
125 /* 'Initialize' this parent box to childless. */
126 $boxes[$parbox]['parent'] = FALSE;
128 /* Compute the collapse status for this box. */
129 if( isset($collapse_folders) && $collapse_folders ) {
130 $collapse = getPref($data_dir, $username, 'collapse_folder_' . $parbox_name);
131 $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED
: $collapse);
133 $collapse = SM_BOX_UNCOLLAPSED
;
135 $boxes[$parbox]['collapse'] = $collapse;
137 /* Otherwise, get the name of the next box. */
138 if (isset($boxes[$nextbox]['unformatted'])) {
139 $nextbox_name = $boxes[$nextbox]['unformatted'];
144 /* Compute any children boxes for this box. */
145 while (($nextbox < $boxcount) &&
146 (is_parent_box($boxes[$nextbox]['unformatted'], $parbox_name))) {
148 /* Note that this 'parent' box has at least one child. */
149 $boxes[$parbox]['parent'] = TRUE;
151 /* Compute the visiblity of this box. */
152 $boxes[$nextbox]['visible'] = ($boxes[$parbox]['visible'] &&
153 ($boxes[$parbox]['collapse'] != SM_BOX_COLLAPSED
));
155 /* Compute the visibility of any child boxes. */
156 compute_folder_children($nextbox, $boxcount);
159 /* Set the parent box to the current next box. */
164 * Create the link for a parent folder that will allow that
165 * parent folder to either be collapsed or expaned, as is
166 * currently appropriate.
168 function create_collapse_link($boxnum) {
169 global $boxes, $imapConnection, $unseen_notify, $color;
170 $mailbox = urlencode($boxes[$boxnum]['unformatted']);
172 /* Create the link for this collapse link. */
173 $link = '<a target="left" style="text-decoration:none" ' .
174 'href="left_main.php?';
175 if ($boxes[$boxnum]['collapse'] == SM_BOX_COLLAPSED
) {
176 $link .= "unfold=$mailbox\">+";
178 $link .= "fold=$mailbox\">-";
182 $hooklink = do_hook_function('create_collapse_link',$link);
186 /* Return the finished product. */
191 * create_unseen_string:
193 * Create unseen and total message count for both this folder and
196 * @param string $boxName name of the current mailbox
197 * @param array $boxArray array for the current mailbox
198 * @param $imapConnection current imap connection in use
199 * @return array[0] unseen message string (for display)
200 * @return array[1] unseen message count
202 function create_unseen_string($boxName, $boxArray, $imapConnection, $unseen_type) {
203 global $boxes, $unseen_type, $color, $unseen_cum;
205 /* Initialize the return value. */
206 $result = array(0,0);
208 /* Initialize the counts for this folder. */
210 $boxMessageCount = 0;
211 $totalUnseenCount = 0;
212 $totalMessageCount = 0;
214 /* Collect the counts for this box alone. */
215 $status = sqimap_status_messages($imapConnection, $boxName);
216 $boxUnseenCount = $status['UNSEEN'];
217 if ($boxUnseenCount === false) {
220 if ($unseen_type == 2) {
221 $boxMessageCount = $status['MESSAGES'];
224 /* Initialize the total counts. */
226 if ($boxArray['collapse'] == SM_BOX_COLLAPSED
&& $unseen_cum) {
227 /* Collect the counts for this boxes subfolders. */
228 $curBoxLength = strlen($boxName);
229 $boxCount = count($boxes);
231 for ($i = 0; $i < $boxCount; ++
$i) {
232 /* Initialize the counts for this subfolder. */
234 $subMessageCount = 0;
236 /* Collect the counts for this subfolder. */
237 if (($boxName != $boxes[$i]['unformatted'])
238 && (substr($boxes[$i]['unformatted'], 0, $curBoxLength) == $boxName)
239 && !in_array('noselect', $boxes[$i]['flags'])) {
240 $status = sqimap_status_messages($imapConnection, $boxes[$i]['unformatted']);
241 $subUnseenCount = $status['UNSEEN'];
242 if ($unseen_type == 2) {
243 $subMessageCount = $status['MESSAGES'];;
245 /* Add the counts for this subfolder to the total. */
246 $totalUnseenCount +
= $subUnseenCount;
247 $totalMessageCount +
= $subMessageCount;
251 /* Add the counts for all subfolders to that of the box. */
252 $boxUnseenCount +
= $totalUnseenCount;
253 $boxMessageCount +
= $totalMessageCount;
256 /* And create the magic unseen count string. */
257 /* Really a lot more then just the unseen count. */
258 if (($unseen_type == 1) && ($boxUnseenCount > 0)) {
259 $result[0] = "($boxUnseenCount)";
260 } else if ($unseen_type == 2) {
261 $result[0] = "($boxUnseenCount/$boxMessageCount)";
262 $result[0] = "<font color=\"$color[11]\">$result[0]</font>";
265 /* Set the unseen count to return to the outside world. */
266 $result[1] = $boxUnseenCount;
268 /* Return our happy result. */
273 * This simple function checks if a box is another box's parent.
275 function is_parent_box($curbox_name, $parbox_name) {
278 /* Extract the name of the parent of the current box. */
279 $curparts = explode($delimiter, $curbox_name);
280 $curname = array_pop($curparts);
281 $actual_parname = implode($delimiter, $curparts);
282 $actual_parname = substr($actual_parname,0,strlen($parbox_name));
284 /* Compare the actual with the given parent name. */
285 return ($parbox_name == $actual_parname);
288 function listBoxes ($boxes, $j=0 ) {
289 global $data_dir, $username, $startmessage, $color, $unseen_notify, $unseen_type,
290 $move_to_trash, $trash_folder, $collapse_folders, $imapConnection;
298 /* Get unseen/total display prefs */
299 $unseen_type = getPref( $data_dir , $username , 'unseen_type' );
300 $unseen_notify = getPref( $data_dir , $username , 'unseen_notify' );
302 if (isset($boxes) && !empty($boxes)) {
303 $mailbox = $boxes->mailboxname_full
;
305 $leader .= str_repeat(' ',$j);
306 $mailboxURL = urlencode($mailbox);
308 /* get unseen/total messages information */
309 /* Only need to display info when option is set */
310 if (isset($unseen_notify) && ($unseen_notify > 1)) {
312 if ($boxes->unseen
!== false) {
313 $unseen = $boxes->unseen
;
319 Should only display unseen info if the folder is inbox
320 or you set the option for all folders
323 if ((strtolower($mailbox) == 'inbox') ||
($unseen_notify == 3)) {
324 $unseen_string = $unseen;
327 /* If users requests, display message count too */
328 if (isset($unseen_type) && ($unseen_type == 2)) {
329 $numMessages = $boxes->total
;
330 $unseen_string .= '/' . $numMessages;
333 $unseen_string = "<font color=\"$color[11]\">($unseen_string)</font>";
336 Finally allow the script to display the values by setting a boolean.
337 This can only occur if the unseen count is great than 0 (if you have
338 unseen count only), or you have the message count too.
340 if (($unseen > 0) ||
(isset($unseen_type) && ($unseen_type ==2))) {
341 $unseen_found = true;
348 if (isset($boxes->mbxs
[0]) && $collapse_folders) {
349 $collapse = getPref($data_dir, $username, 'collapse_folder_' . $mailbox);
350 $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED
: $collapse);
352 $link = '<a target="left" style="text-decoration:none" ' .'href="left_main.php?';
354 $link .= "unfold=$mailboxURL\">$leader+ </tt>";
356 $link .= "fold=$mailboxURL\">$leader- </tt>";
361 $pre.= $leader . ' </tt>';
364 /* If there are unseen message, bold the line. */
365 if (($move_to_trash) && ($mailbox == $trash_folder)) {
366 if (! isset($boxes->total
)) {
367 $boxes->total
= sqimap_status_messages($imapConnection, $mailbox);
372 $pre .= "<a href=\"right_main.php?PG_SHOWALL=0&sort=0;startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\">";
377 if ($boxes->total
> 0) {
381 $pre .= "<a href=\"right_main.php?PG_SHOWALL=0&sort=0;startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\">";
385 $end .= "\n<small>\n" .
386 " (<a href=\"empty_trash.php\" style=\"text-decoration:none\">"._("purge")."</a>)" .
390 if (!$boxes->is_noselect
) {
394 $pre .= "<a href=\"right_main.php?PG_SHOWALL=0&sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\">";
402 /* Print unseen information. */
403 if (isset($unseen_found) && $unseen_found) {
404 $end .= " <small>$unseen_string</small>";
409 if ($boxes->is_special
) {
410 $font = "<font color=\"$color[11]\">";
411 $fontend = "</font>";
415 if (!$boxes->is_root
) {
416 echo "" . $pre .$font. $boxes->mailboxname_sub
.$fontend . $end. '<br />' . "\n";
420 if (!$collapse ||
$boxes->is_root
) {
421 for ($i = 0; $i <count($boxes->mbxs
); $i++
) {
422 listBoxes($boxes->mbxs
[$i],$j);
428 function ListAdvancedBoxes ($boxes, $mbx, $j='ID.0000' ) {
429 global $data_dir, $username, $startmessage, $color, $unseen_notify, $unseen_type,
430 $move_to_trash, $trash_folder, $collapse_folders;
432 /* use_folder_images only works if the images exist in ../images */
433 $use_folder_images = true;
438 $unseen_found = false;
442 $mailbox = $boxes->mailboxname_full
;
443 $mailboxURL = urlencode($mailbox);
445 /* Only need to display info when option is set */
446 if (isset($unseen_notify) && ($unseen_notify > 1) && (($boxes->unseen
!== false) ||
($boxes->total
!== false))) {
448 if ($boxes->unseen
!== false)
449 $unseen = $boxes->unseen
;
452 Should only display unseen info if the folder is inbox
453 or you set the option for all folders
456 if ((strtolower($mailbox) == 'inbox') ||
($unseen_notify == 3)) {
457 $unseen_string = $unseen;
459 /* If users requests, display message count too */
460 if (isset($unseen_type) && ($unseen_type == 2) && ($boxes->total
!== false))
461 $unseen_string .= '/' . $boxes->total
;
463 $unseen_string = "<font color=\"$color[11]\">($unseen_string)</font>";
466 Finally allow the script to display the values by setting a boolean.
467 This can only occur if the unseen count is great than 0 (if you have
468 unseen count only), or you have the message count too.
470 if (($unseen > 0) ||
(isset($unseen_type) && ($unseen_type ==2))) {
471 $unseen_found = true;
478 /* If there are unseen message, bold the line. */
479 if ($unseen > 0) { $pre .= '<b>'; }
481 /* color special boxes */
482 if ($boxes->is_special
) {
483 $pre .= "<font color=\"$color[11]\">";
487 /* If there are unseen message, close bolding. */
488 if ($unseen > 0) { $end .= '</b>'; }
490 /* Print unseen information. */
491 if (isset($unseen_found) && $unseen_found) {
492 $end .= " $unseen_string";
495 if (($move_to_trash) && ($mailbox == $trash_folder)) {
496 if (! isset($numMessages)) {
497 $numMessages = $boxes->total
;
499 $pre .= "<a class=\"mbx_link\" href=\"right_main.php?PG_SHOWALL=0&sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\">";
501 if ($numMessages > 0) {
502 $urlMailbox = urlencode($mailbox);
503 $end .= "\n<small>\n" .
504 " (<a class=\"mbx_link\" href=\"empty_trash.php\">"._("purge")."</a>)" .
508 if (!$boxes->is_noselect
) { /* \Noselect boxes can't be selected */
509 $pre .= "<a class=\"mbx_link\" href=\"right_main.php?PG_SHOWALL=0&sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\">";
514 if (!$boxes->is_root
) {
515 if ($use_folder_images) {
516 if ($boxes->is_inbox
) {
517 $folder_img = '../images/inbox.png';
518 } else if ($boxes->is_sent
) {
519 $folder_img = '../images/senti.png';
520 } else if ($boxes->is_trash
) {
521 $folder_img = '../images/delitem.png';
522 } else if ($boxes->is_draft
) {
523 $folder_img = '../images/draft.png';
524 } else if ($boxes->is_noinferiors
) {
525 $folder_img = '../images/folder_noinf.png';
526 } else $folder_img = '../images/folder.png';
527 $folder_img = ' <img src="'.$folder_img.'" height="15" valign="center" /> ';
528 } else $folder_img = '';
529 if (!isset($boxes->mbxs
[0])) {
530 echo ' ' . html_tag( 'div',
531 '<tt>'. $pre . $folder_img . '</tt>'. $boxes->mailboxname_sub
. $end,
532 'left', '', 'class="mbx_sub" id="' .$j. '"' )
535 /* get collapse information */
536 if ($collapse_folders) {
537 $link = '<a target="left" style="text-decoration:none" ' .'href="left_main.php?';
538 $form_entry = $j.'F';
539 if (isset($mbx) && isset($mbx[$form_entry])) {
540 $collapse = $mbx[$form_entry];
542 setPref($data_dir, $username, 'collapse_folder_'.$boxes->mailboxname_full
, SM_BOX_COLLAPSED
);
544 setPref($data_dir, $username, 'collapse_folder_'.$boxes->mailboxname_full
, SM_BOX_UNCOLLAPSED
);
547 $collapse = getPref($data_dir, $username, 'collapse_folder_' . $mailbox);
548 $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED
: $collapse);
551 $link = '<a href="javascript:void(0)">'." <img src=\"../images/plus.png\" border=\"1\" id=$j onclick=\"hidechilds(this)\" /></a>";
553 $link = '<a href="javascript:void(0)">'."<img src=\"../images/minus.png\" border=\"1\" id=$j onclick=\"hidechilds(this)\" /></a>";
555 $collapse_link = $link;
556 } else $collapse_link='';
557 echo ' ' . html_tag( 'div',
558 $collapse_link . $pre . $folder_img . ' '. $boxes->mailboxname_sub
. $end ,
559 'left', '', 'class="mbx_par" id="' .$j. 'P"' )
561 echo ' <input type="hidden" name="mbx['.$j. 'F]" value="'.$collapse.'" id="mbx['.$j.'F]" />'."\n";
565 $visible = ' style="display:none;"';
567 $visible = ' style="display:block;"';
570 if (isset($boxes->mbxs
[0]) && !$boxes->is_root
) /* mailbox contains childs */
571 echo html_tag( 'div', '', 'left', '', 'class="par_area" id='.$j.'.0000 '. $visible ) . "\n";
573 if ($j !='ID.0000') {
576 for ($i = 0; $i <count($boxes->mbxs
); $i++
) {
578 listAdvancedBoxes($boxes->mbxs
[$i],$mbx,$j);
580 if (isset($boxes->mbxs
[0]) && !$boxes->is_root
) echo '</div>'."\n\n";
587 /* -------------------- MAIN ------------------------ */
590 sqgetGlobalVar('username', $username, SQ_SESSION
);
591 sqgetGlobalVar('key', $key, SQ_COOKIE
);
592 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION
);
593 sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION
);
595 sqgetGlobalVar('fold', $fold, SQ_GET
);
596 sqgetGlobalVar('unfold', $unfold, SQ_GET
);
600 // open a connection on the imap port (143)
601 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 10); // the 10 is to hide the output
604 * Using stristr since older preferences may contain "None" and "none".
606 if (isset($left_refresh) && ($left_refresh != '') &&
607 !stristr($left_refresh, 'none')){
608 $xtra = "\n<meta http-equiv=\"Expires\" content=\"Thu, 01 Dec 1994 16:00:00 GMT\" />\n" .
609 "<meta http-equiv=\"Pragma\" content=\"no-cache\" />\n".
610 "<meta http-equiv=\"REFRESH\" content=\"$left_refresh;URL=left_main.php\" />\n";
616 * $advanced_tree and $oldway are boolean vars which are default set to default
618 * Setting $oldway to false causes left_main.php to use the new experimental
619 * way of getting the mailbox-tree.
620 * Setting $advanced tree to true causes SM to display a experimental
621 * mailbox-tree with dhtml behaviour.
622 * It only works on browsers which supports css and javascript. The used
623 * javascript is experimental and doesn't support all browsers. It is tested on
624 * IE6 an Konquerer 3.0.0-2.
625 * In the function ListAdvancedBoxes there is another var $use_folder_images.
626 * setting this to true is only usefull if the images exists in ../images.
628 * Feel free to experiment with the code and report bugs and enhancements
629 * to marc@its-projects.nl
632 $advanced_tree = false; /* set this to true if you want to see a nicer mailboxtree */
633 $oldway = false; /* default SM behaviour */
635 if ($advanced_tree) {
637 <script language="Javascript" TYPE="text/javascript">
642 if (document.images) {
643 var treeImages = new Array;
644 var arguments = preload.arguments;
645 for (var i = 0; i<arguments.length; i++) {
646 treeImages[i] = new Image();
647 treeImages[i].src = arguments[i];
652 function hidechilds(el) {
654 form_id = "mbx[" + el.id +"F]";
656 ele = document.all[id];
658 if (ele.style.display == "none") {
659 el.src = "../images/minus.png";
660 for (i = 0; i < 200000; i++);
661 ele.style.display = "block";
662 document.all[form_id].value=0;
664 el.src = "../images/plus.png";
665 for (i = 0; i < 200000; i++);
666 ele.style.display = "none";
667 document.all[form_id].value=1;
670 } else if (document.getElementById) {
671 ele = document.getElementById(id);
673 if(ele.style.display == "none") {
674 ele.style.display = "block";
675 // ele.style.visibility = "visible";
676 el.src="../images/minus.png";
677 document.getElementById(form_id).value=0;
679 ele.style.display = "none";
680 // ele.style.visibility = "hidden";
681 el.src="../images/plus.png";
682 document.getElementById(form_id).value=1;
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:$color[9];
848 border-bottom: solid;
849 border-bottom-width:0.1em;
850 border-bottom-color:$color[9];
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');
899 ' onload="preload(\'../images/minus.png\',\'../images/plus.png\')"' .
900 " bgcolor=\"$color[3]\" text=\"$color[6]\" link=\"$color[6]\" vlink=\"$color[6]\" alink=\"$color[6]\">\n";
902 echo "\n<body bgcolor=\"$color[3]\" text=\"$color[6]\" link=\"$color[6]\" vlink=\"$color[6]\" alink=\"$color[6]\">\n";
904 do_hook('left_main_before');
905 if ($advanced_tree) {
906 /* nice future feature, needs layout !! volunteers? */
907 $right_pos = $left_size - 20;
908 /* 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>';
909 echo '<div ID="showf" style="width=20;font-size:12;display:none;"><a href="javascript:hideframe(false)"><b>>></b></a></div>';
910 echo '<div ID="incrf" style="width=20;font-size:12"><a href="javascript:resizeframe(true)"><b>></b></a></div>';
911 echo '<div ID="decrf" style="width=20;font-size:12"><a href="javascript:resizeframe(false)"><b><</b></a></div></div>';
912 echo '<div ID="leftframe"><br /><br />';*/
915 echo "\n\n" . html_tag( 'table', '', 'left', '', 'border="0" cellspacing="0" cellpadding="0" width="99%"' ) .
917 html_tag( 'td', '', 'left' ) .
918 '<center><font size="4"><b>'. _("Folders") . "</b><br /></font>\n\n";
920 if ($date_format != 6) {
921 /* First, display the clock. */
922 if ($hour_format == 1) {
924 if ($date_format == 4) {
928 if ($date_format == 4) {
935 switch( $date_format ) {
937 $clk = date('m/d/y '.$hr, time());
940 $clk = date('d/m/y '.$hr, time());
944 $clk = date($hr, time());
947 $clk = substr( getDayName( date( 'w', time() ) ), 0, 3 ) . date( ', ' . $hr, time() );
949 $clk = str_replace(' ',' ',$clk);
951 echo '<center><small>' . str_replace(' ',' ',_("Last Refresh")) .
952 ": $clk</small></center>";
955 /* Next, display the refresh button. */
956 echo '<small>(<a href="../src/left_main.php" target="left">'.
957 _("refresh folder list") . '</a>)</small></center><br />';
959 /* Lastly, display the folder list. */
960 if ( $collapse_folders ) {
961 /* If directed, collapse or uncollapse a folder. */
963 setPref($data_dir, $username, 'collapse_folder_' . $fold, SM_BOX_COLLAPSED
);
964 } else if (isset($unfold)) {
965 setPref($data_dir, $username, 'collapse_folder_' . $unfold, SM_BOX_UNCOLLAPSED
);
969 if ($oldway) { /* normal behaviour SM */
971 $boxes = sqimap_mailbox_list($imapConnection);
972 /* Prepare do do out collapsedness and visibility computation. */
974 $boxcount = count($boxes);
976 /* Compute the collapsedness and visibility of each box. */
978 while ($curbox < $boxcount) {
979 $boxes[$curbox]['visible'] = TRUE;
980 compute_folder_children($curbox, $boxcount);
983 for ($i = 0; $i < count($boxes); $i++
) {
984 if ( $boxes[$i]['visible'] ) {
985 $mailbox = $boxes[$i]['formatted'];
986 $mblevel = substr_count($boxes[$i]['unformatted'], $delimiter) +
1;
988 /* Create the prefix for the folder name and link. */
989 $prefix = str_repeat(' ',$mblevel);
990 if (isset($collapse_folders) && $collapse_folders && $boxes[$i]['parent']) {
991 $prefix = str_replace(' ',' ',substr($prefix,0,strlen($prefix)-2)).
992 create_collapse_link($i) . ' ';
994 $prefix = str_replace(' ',' ',$prefix);
996 $line = "<nobr><tt>$prefix</tt>";
998 /* Add the folder name and link. */
999 if (! isset($color[15])) {
1000 $color[15] = $color[6];
1003 if (in_array('noselect', $boxes[$i]['flags'])) {
1004 if( isSpecialMailbox( $boxes[$i]['unformatted']) ) {
1005 $line .= "<font color=\"$color[11]\">";
1007 $line .= "<font color=\"$color[15]\">";
1009 if (ereg("^( *)([^ ]*)", $mailbox, $regs)) {
1010 $mailbox = str_replace(' ','',$mailbox);
1011 $line .= str_replace(' ', ' ', $mailbox);
1015 $line .= formatMailboxName($imapConnection, $boxes[$i]);
1018 /* Put the final touches on our folder line. */
1019 $line .= "</nobr><br>\n";
1021 /* Output the line for this folder. */
1025 } else { /* expiremental code */
1026 $boxes = sqimap_mailbox_tree($imapConnection);
1027 if (isset($advanced_tree) && $advanced_tree) {
1028 echo '<form name="collapse" action="left_main.php" method="post" ' .
1029 'enctype="multipart/form-data"'."\n";
1031 /* echo '<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 />';*/
1032 echo '<div id="mailboxes" class="mailboxes">'."\n\n";
1033 if (!isset($mbx)) $mbx=NULL;
1034 ListAdvancedBoxes($boxes, $mbx);
1035 echo '</div></small>'."\n";
1036 echo '</form>'."\n";
1038 //sqimap_get_status_mbx_tree($imap_stream,$boxes)
1041 } /* if ($oldway) else ... */
1042 do_hook('left_main_after');
1043 sqimap_logout($imapConnection);
1045 echo '</td></tr></table>' . "\n".
1046 "</div></body></html>\n";