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 /* Print unseen information. */
386 if (isset($unseen_found) && $unseen_found) {
387 $end .= " <small>$unseen_string</small>";
389 $end .= "\n<small>\n" .
390 " (<a href=\"empty_trash.php\" style=\"text-decoration:none\">"._("purge")."</a>)" .
394 if (!$boxes->is_noselect
) {
398 $pre .= "<a href=\"right_main.php?PG_SHOWALL=0&sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\">";
404 /* Print unseen information. */
405 if (isset($unseen_found) && $unseen_found) {
406 $end .= " <small>$unseen_string</small>";
413 if ($boxes->is_special
) {
414 $font = "<font color=\"$color[11]\">";
415 $fontend = "</font>";
419 if (!$boxes->is_root
) {
420 echo "" . $pre .$font. $boxes->mailboxname_sub
.$fontend . $end. '<br />' . "\n";
424 if (!$collapse ||
$boxes->is_root
) {
425 for ($i = 0; $i <count($boxes->mbxs
); $i++
) {
426 listBoxes($boxes->mbxs
[$i],$j);
432 function ListAdvancedBoxes ($boxes, $mbx, $j='ID.0000' ) {
433 global $data_dir, $username, $startmessage, $color, $unseen_notify, $unseen_type,
434 $move_to_trash, $trash_folder, $collapse_folders;
436 /* use_folder_images only works if the images exist in ../images */
437 $use_folder_images = true;
442 $unseen_found = false;
446 $mailbox = $boxes->mailboxname_full
;
447 $mailboxURL = urlencode($mailbox);
449 /* Only need to display info when option is set */
450 if (isset($unseen_notify) && ($unseen_notify > 1) && (($boxes->unseen
!== false) ||
($boxes->total
!== false))) {
452 if ($boxes->unseen
!== false)
453 $unseen = $boxes->unseen
;
456 Should only display unseen info if the folder is inbox
457 or you set the option for all folders
460 if ((strtolower($mailbox) == 'inbox') ||
($unseen_notify == 3)) {
461 $unseen_string = $unseen;
463 /* If users requests, display message count too */
464 if (isset($unseen_type) && ($unseen_type == 2) && ($boxes->total
!== false))
465 $unseen_string .= '/' . $boxes->total
;
467 $unseen_string = "<font color=\"$color[11]\">($unseen_string)</font>";
470 Finally allow the script to display the values by setting a boolean.
471 This can only occur if the unseen count is great than 0 (if you have
472 unseen count only), or you have the message count too.
474 if (($unseen > 0) ||
(isset($unseen_type) && ($unseen_type ==2))) {
475 $unseen_found = true;
482 /* If there are unseen message, bold the line. */
483 if ($unseen > 0) { $pre .= '<b>'; }
485 /* color special boxes */
486 if ($boxes->is_special
) {
487 $pre .= "<font color=\"$color[11]\">";
491 /* If there are unseen message, close bolding. */
492 if ($unseen > 0) { $end .= '</b>'; }
494 /* Print unseen information. */
495 if (isset($unseen_found) && $unseen_found) {
496 $end .= " $unseen_string";
499 if (($move_to_trash) && ($mailbox == $trash_folder)) {
500 if (! isset($numMessages)) {
501 $numMessages = $boxes->total
;
503 $pre .= "<a class=\"mbx_link\" href=\"right_main.php?PG_SHOWALL=0&sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\">";
505 if ($numMessages > 0) {
506 $urlMailbox = urlencode($mailbox);
507 $end .= "\n<small>\n" .
508 " (<a class=\"mbx_link\" href=\"empty_trash.php\">"._("purge")."</a>)" .
512 if (!$boxes->is_noselect
) { /* \Noselect boxes can't be selected */
513 $pre .= "<a class=\"mbx_link\" href=\"right_main.php?PG_SHOWALL=0&sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\">";
518 if (!$boxes->is_root
) {
519 if ($use_folder_images) {
520 if ($boxes->is_inbox
) {
521 $folder_img = '../images/inbox.png';
522 } else if ($boxes->is_sent
) {
523 $folder_img = '../images/senti.png';
524 } else if ($boxes->is_trash
) {
525 $folder_img = '../images/delitem.png';
526 } else if ($boxes->is_draft
) {
527 $folder_img = '../images/draft.png';
528 } else if ($boxes->is_noinferiors
) {
529 $folder_img = '../images/folder_noinf.png';
530 } else $folder_img = '../images/folder.png';
531 $folder_img = ' <img src="'.$folder_img.'" height="15" valign="center" /> ';
532 } else $folder_img = '';
533 if (!isset($boxes->mbxs
[0])) {
534 echo ' ' . html_tag( 'div',
535 '<tt>'. $pre . $folder_img . '</tt>'. $boxes->mailboxname_sub
. $end,
536 'left', '', 'class="mbx_sub" id="' .$j. '"' ) . "\n";
539 /* get collapse information */
540 if ($collapse_folders) {
541 $form_entry = $j.'F';
542 if (isset($mbx) && isset($mbx[$form_entry])) {
543 $collapse = $mbx[$form_entry];
544 setPref($data_dir, $username, 'collapse_folder_'.$boxes->mailboxname_full
, $collapse ? SM_BOX_COLLAPSED
: SM_BOX_UNCOLLAPSED
);
547 $collapse = getPref($data_dir, $username, 'collapse_folder_' . $mailbox);
548 $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED
: $collapse);
550 $img_src = ($collapse ?
'../images/plus.png' : '../images/minus.png');
551 $collapse_link = '<a href="javascript:void(0)">'." <img src=\"$img_src\" border=\"1\" id=$j onclick=\"hidechilds(this)\" style=\"cursor:hand\" /></a>";
555 echo ' ' . html_tag( 'div',
556 $collapse_link . $pre . $folder_img . ' '. $boxes->mailboxname_sub
. $end ,
557 'left', '', 'class="mbx_par" id="' .$j. 'P"' ) . "\n";
558 echo ' <input type="hidden" name="mbx['.$j. 'F]" value="'.$collapse.'" id="mbx['.$j.'F]" />'."\n";
562 $visible = ($collapse ?
' style="display:none"' : ' style="display:block"');
563 if (isset($boxes->mbxs
[0]) && !$boxes->is_root
) /* mailbox contains childs */
564 echo html_tag( 'div', '', 'left', '', 'class="par_area" id='.$j.'.0000 '. $visible ) . "\n";
568 for ($i = 0; $i <count($boxes->mbxs
); $i++
) {
570 ListAdvancedBoxes($boxes->mbxs
[$i],$mbx,$j);
572 if (isset($boxes->mbxs
[0]) && !$boxes->is_root
)
573 echo '</div>'."\n\n";
580 /* -------------------- MAIN ------------------------ */
583 sqgetGlobalVar('username', $username, SQ_SESSION
);
584 sqgetGlobalVar('key', $key, SQ_COOKIE
);
585 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION
);
586 sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION
);
588 sqgetGlobalVar('fold', $fold, SQ_GET
);
589 sqgetGlobalVar('unfold', $unfold, SQ_GET
);
593 // open a connection on the imap port (143)
594 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 10); // the 10 is to hide the output
597 * Using stristr since older preferences may contain "None" and "none".
599 if (isset($left_refresh) && ($left_refresh != '') &&
600 !stristr($left_refresh, 'none')){
601 $xtra = "\n<meta http-equiv=\"Expires\" content=\"Thu, 01 Dec 1994 16:00:00 GMT\" />\n" .
602 "<meta http-equiv=\"Pragma\" content=\"no-cache\" />\n".
603 "<meta http-equiv=\"REFRESH\" content=\"$left_refresh;URL=left_main.php\" />\n";
609 * $advanced_tree and $oldway are boolean vars which are default set to default
611 * Setting $oldway to false causes left_main.php to use the new experimental
612 * way of getting the mailbox-tree.
613 * Setting $advanced tree to true causes SM to display a experimental
614 * mailbox-tree with dhtml behaviour.
615 * It only works on browsers which supports css and javascript. The used
616 * javascript is experimental and doesn't support all browsers.
617 * It has been tested on IE6 an Konquerer 3.0.0-2.
618 * It is now tested and working on: (please test and update this list)
619 * Windows: IE 5.5 SP2, IE 6 SP1, Gecko based (Mozilla, Firebird) and Opera7
622 * In the function ListAdvancedBoxes there is another var $use_folder_images.
623 * setting this to true is only usefull if the images exists in ../images.
625 * Feel free to experiment with the code and report bugs and enhancements
626 * to marc@its-projects.nl
629 $advanced_tree = false;
630 $oldway = false; /* default SM behaviour */
632 if ($advanced_tree) {
634 <script language="Javascript" TYPE="text/javascript">
639 if (document.images) {
640 var treeImages = new Array;
641 var arguments = preload.arguments;
642 for (var i = 0; i<arguments.length; i++) {
643 treeImages[i] = new Image();
644 treeImages[i].src = arguments[i];
653 function fTreeTimeout() {
654 if (vTreeDiv.readyState == "complete")
655 vTreeImg.src = vTreeSrc;
657 setTimeout("fTreeTimeout()", 100);
660 function hidechilds(img) {
661 id = img.id + ".0000";
662 form_id = "mbx[" + img.id +"F]";
663 if (document.all) { //IE, Opera7
664 div = document.all[id];
666 if (div.style.display == "none") {
667 vTreeSrc = "../images/minus.png";
672 vTreeSrc = "../images/plus.png";
678 if (typeof vTreeDiv.readyState != "undefined") //IE
679 setTimeout("fTreeTimeout()",100);
681 vTreeImg.src = vTreeSrc;
682 div.style.display = style;
683 document.all[form_id].value = value;
686 else if (document.getElementById) { //Gecko
687 div = document.getElementById(id);
689 if (div.style.display == "none") {
690 src = "../images/minus.png";
695 src = "../images/plus.png";
699 div.style.display = style;
701 document.getElementById(form_id).value = value;
706 function buttonover(el,on) {
708 // el.style.borderColor="$color[9]";}
709 el.style.background="$color[0]";}
711 el.style.background="$color[9]";}
714 function buttonclick(el,on) {
716 el.style.border="groove";}
718 el.style.border="ridge";}
721 function hideframe(hide) {
724 $xtra .= " left_size = \"$left_size\";\n";
727 masterf = window.parent.document.all["fs1"];
728 leftf = window.parent.document.all["left"];
729 leftcontent = document.all["leftframe"];
730 leftbutton = document.all["showf"];
731 } else if (document.getElementById) {
732 masterf = window.parent.document.getElementById("fs1");
733 leftf = window.parent.document.getElementById("left");
734 leftcontent = document.getElementById("leftframe");
735 leftbutton = document.getElementById("showf");
740 new_col = calc_col("20");
741 masterf.cols = new_col;
742 document.body.scrollLeft=0;
743 document.body.style.overflow='hidden';
744 leftcontent.style.display = 'none';
745 leftbutton.style.display='block';
747 masterf.cols = calc_col(left_size);
748 document.body.style.overflow='';
749 leftbutton.style.display='none';
750 leftcontent.style.display='block';
755 function calc_col(c_w) {
758 if ($location_of_bar == 'right') {
759 $xtra .= ' right=true;';
761 $xtra .= ' right=false;';
773 function resizeframe(direction) {
775 masterf = window.parent.document.all["fs1"];
776 } else if (document.getElementById) {
777 window.parent.document.getElementById("fs1");
783 if ($location_of_bar == 'right') {
784 $xtra .= ' colPat=/^\*,(\d+)$/;';
786 $xtra .= ' colPat=/^(\d+),.*$/;';
791 old_col = masterf.cols;
792 colPat.exec(old_col);
795 new_col_width = parseInt(RegExp.$1) + 25;
798 if (parseInt(RegExp.$1) > 35) {
799 new_col_width = parseInt(RegExp.$1) - 25;
802 masterf.cols = calc_col(new_col_width);
811 /* style definitions */
815 <style type="text/css">
818 margin: 0px 0px 0px 0px;
819 padding: 5px 5px 5px 5px;
824 border-color: $color[9];
825 background:$color[0];
838 text-decoration: none;
839 background-color: $color[0];
844 background-color: $color[9];
866 border-left-width:0.1em;
867 border-left-color:$color[9];
868 border-bottom: solid;
869 border-bottom-width:0.1em;
870 border-bottom-color:$color[9];
882 border-color:$color[9];
883 background: $color[0];
897 displayHtmlHeader( 'SquirrelMail', $xtra );
899 /* If requested and not yet complete, attempt to autocreate folders. */
900 if ($auto_create_special && !isset($auto_create_done)) {
901 $autocreate = array($sent_folder, $trash_folder, $draft_folder);
902 foreach( $autocreate as $folder ) {
903 if (($folder != '') && ($folder != 'none')) {
904 if ( !sqimap_mailbox_exists($imapConnection, $folder)) {
905 sqimap_mailbox_create($imapConnection, $folder, '');
906 } else if (!sqimap_mailbox_is_subscribed($imapConnection, $folder)) {
907 sqimap_subscribe($imapConnection, $folder);
912 /* Let the world know that autocreation is complete! Hurrah! */
913 $auto_create_done = TRUE;
914 sqsession_register($auto_create_done, 'auto_create_done');
919 ' onload="preload(\'../images/minus.png\',\'../images/plus.png\')"' .
920 " bgcolor=\"$color[3]\" text=\"$color[6]\" link=\"$color[6]\" vlink=\"$color[6]\" alink=\"$color[6]\">\n";
922 echo "\n<body bgcolor=\"$color[3]\" text=\"$color[6]\" link=\"$color[6]\" vlink=\"$color[6]\" alink=\"$color[6]\">\n";
924 do_hook('left_main_before');
925 if ($advanced_tree) {
926 /* nice future feature, needs layout !! volunteers? */
927 $right_pos = $left_size - 20;
928 /* 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>';
929 echo '<div ID="showf" style="width=20;font-size:12;display:none;"><a href="javascript:hideframe(false)"><b>>></b></a></div>';
930 echo '<div ID="incrf" style="width=20;font-size:12"><a href="javascript:resizeframe(true)"><b>></b></a></div>';
931 echo '<div ID="decrf" style="width=20;font-size:12"><a href="javascript:resizeframe(false)"><b><</b></a></div></div>';
932 echo '<div ID="leftframe"><br /><br />';*/
935 echo "\n\n" . html_tag( 'table', '', 'left', '', 'border="0" cellspacing="0" cellpadding="0" width="99%"' ) .
937 html_tag( 'td', '', 'left' ) .
938 '<center><font size="4"><b>'. _("Folders") . "</b><br /></font>\n\n";
940 if ($date_format != 6) {
941 /* First, display the clock. */
942 if ($hour_format == 1) {
944 if ($date_format == 4) {
948 if ($date_format == 4) {
955 switch( $date_format ) {
957 $clk = date('m/d/y '.$hr, time());
960 $clk = date('d/m/y '.$hr, time());
964 $clk = date($hr, time());
967 $clk = substr( getDayName( date( 'w', time() ) ), 0, 3 ) . date( ', ' . $hr, time() );
969 $clk = str_replace(' ',' ',$clk);
971 echo '<center><small>' . str_replace(' ',' ',_("Last Refresh")) .
972 ": $clk</small></center>";
975 /* Next, display the refresh button. */
976 echo '<small>(<a href="../src/left_main.php" target="left">'.
977 _("refresh folder list") . '</a>)</small></center><br />';
979 /* Lastly, display the folder list. */
980 if ( $collapse_folders ) {
981 /* If directed, collapse or uncollapse a folder. */
983 setPref($data_dir, $username, 'collapse_folder_' . $fold, SM_BOX_COLLAPSED
);
984 } else if (isset($unfold)) {
985 setPref($data_dir, $username, 'collapse_folder_' . $unfold, SM_BOX_UNCOLLAPSED
);
989 if ($oldway) { /* normal behaviour SM */
991 $boxes = sqimap_mailbox_list($imapConnection);
992 /* Prepare do do out collapsedness and visibility computation. */
994 $boxcount = count($boxes);
996 /* Compute the collapsedness and visibility of each box. */
998 while ($curbox < $boxcount) {
999 $boxes[$curbox]['visible'] = TRUE;
1000 compute_folder_children($curbox, $boxcount);
1003 for ($i = 0; $i < count($boxes); $i++
) {
1004 if ( $boxes[$i]['visible'] ) {
1005 $mailbox = $boxes[$i]['formatted'];
1006 $mblevel = substr_count($boxes[$i]['unformatted'], $delimiter) +
1;
1008 /* Create the prefix for the folder name and link. */
1009 $prefix = str_repeat(' ',$mblevel);
1010 if (isset($collapse_folders) && $collapse_folders && $boxes[$i]['parent']) {
1011 $prefix = str_replace(' ',' ',substr($prefix,0,strlen($prefix)-2)).
1012 create_collapse_link($i) . ' ';
1014 $prefix = str_replace(' ',' ',$prefix);
1016 $line = "<nobr><tt>$prefix</tt>";
1018 /* Add the folder name and link. */
1019 if (! isset($color[15])) {
1020 $color[15] = $color[6];
1023 if (in_array('noselect', $boxes[$i]['flags'])) {
1024 if( isSpecialMailbox( $boxes[$i]['unformatted']) ) {
1025 $line .= "<font color=\"$color[11]\">";
1027 $line .= "<font color=\"$color[15]\">";
1029 if (ereg("^( *)([^ ]*)", $mailbox, $regs)) {
1030 $mailbox = str_replace(' ','',$mailbox);
1031 $line .= str_replace(' ', ' ', $mailbox);
1035 $line .= formatMailboxName($imapConnection, $boxes[$i]);
1038 /* Put the final touches on our folder line. */
1039 $line .= "</nobr><br>\n";
1041 /* Output the line for this folder. */
1045 } else { /* expiremental code */
1046 $boxes = sqimap_mailbox_tree($imapConnection);
1047 if (isset($advanced_tree) && $advanced_tree) {
1048 echo '<form name="collapse" action="left_main.php" method="post" ' .
1049 'enctype="multipart/form-data"'."\n";
1051 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 />';
1052 echo '<div id="mailboxes" class="mailboxes">'."\n\n";
1053 sqgetGlobalVar('mbx', $mbx, SQ_POST
);
1054 if (!isset($mbx)) $mbx=NULL;
1055 ListAdvancedBoxes($boxes, $mbx);
1058 echo '</form>'."\n";
1060 //sqimap_get_status_mbx_tree($imap_stream,$boxes)
1063 } /* if ($oldway) else ... */
1064 do_hook('left_main_after');
1065 sqimap_logout($imapConnection);
1067 echo '</td></tr></table>' . "\n".
1068 "</div></body></html>\n";