6 * Copyright (c) 1999-2004 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.
13 * @package squirrelmail
17 * Path for SquirrelMail required files.
20 define('SM_PATH','../');
22 /* SquirrelMail required files. */
23 require_once(SM_PATH
. 'include/validate.php');
24 require_once(SM_PATH
. 'functions/imap.php');
25 require_once(SM_PATH
. 'functions/plugin.php');
26 require_once(SM_PATH
. 'functions/page_header.php');
27 require_once(SM_PATH
. 'functions/html.php');
28 require_once(SM_PATH
. 'functions/date.php');
30 /* These constants are used for folder stuff. */
31 define('SM_BOX_UNCOLLAPSED', 0);
32 define('SM_BOX_COLLAPSED', 1);
34 /* --------------------- FUNCTIONS ------------------------- */
36 function formatMailboxName($imapConnection, $box_array) {
38 global $folder_prefix, $trash_folder, $sent_folder,
39 $color, $move_to_sent, $move_to_trash,
40 $unseen_notify, $unseen_type, $collapse_folders,
41 $draft_folder, $save_as_draft,
42 $use_special_folder_color;
43 $real_box = $box_array['unformatted'];
44 $mailbox = str_replace(' ','',$box_array['formatted']);
45 $mailboxURL = urlencode($real_box);
47 /* Strip down the mailbox name. */
48 if (ereg("^( *)([^ ]*)$", $mailbox, $regs)) {
52 $status = array('','');
53 if (($unseen_notify == 2 && $real_box == 'INBOX') ||
54 $unseen_notify == 3) {
55 $tmp_status = create_unseen_string($real_box, $box_array, $imapConnection, $unseen_type );
56 if ($status !== false) {
57 $status = $tmp_status;
60 list($unseen_string, $unseen) = $status;
61 $special_color = ($use_special_folder_color && isSpecialMailbox($real_box));
63 /* Start off with a blank line. */
66 /* If there are unseen message, bold the line. */
67 if ($unseen > 0) { $line .= '<B>'; }
69 /* Create the link for this folder. */
70 if ($status !== false) {
71 $line .= '<a href="right_main.php?PG_SHOWALL=0&sort=0&startMessage=1&mailbox='.
72 $mailboxURL.'" TARGET="right" STYLE="text-decoration:none">';
75 $line .= "<font color=\"$color[11]\">";
77 if ( $mailbox == 'INBOX' ) {
80 $line .= str_replace(array(' ','<','>'),array(' ','<','>'),$mailbox);
82 if ($special_color == TRUE)
84 if ($status !== false) {
88 /* If there are unseen message, close bolding. */
89 if ($unseen > 0) { $line .= "</B>"; }
91 /* Print unseen information. */
92 if ($unseen_string != '') {
93 $line .= " <SMALL>$unseen_string</SMALL>";
96 /* If it's the trash folder, show a purge link when needed */
97 if (($move_to_trash) && ($real_box == $trash_folder)) {
98 if (! isset($numMessages)) {
99 $numMessages = sqimap_get_num_messages($imapConnection, $real_box);
102 if (($numMessages > 0) or ($box_array['parent'] == 1)) {
103 $urlMailbox = urlencode($real_box);
104 $line .= "\n<small>\n" .
105 " (<A HREF=\"empty_trash.php\" style=\"text-decoration:none\">"._("purge")."</A>)" .
111 // let plugins fiddle with end of line
112 $line .= concat_hook_function('left_main_after_each_folder',
113 array(isset($numMessages) ?
$numMessages : '', $real_box, $imapConnection));
116 /* Return the final product. */
121 * Recursive function that computes the collapsed status and parent
122 * (or not parent) status of this box, and the visiblity and collapsed
123 * status and parent (or not parent) status for all children boxes.
125 function compute_folder_children(&$parbox, $boxcount) {
126 global $boxes, $data_dir, $username, $collapse_folders;
127 $nextbox = $parbox +
1;
129 /* Retreive the name for the parent box. */
130 $parbox_name = $boxes[$parbox]['unformatted'];
132 /* 'Initialize' this parent box to childless. */
133 $boxes[$parbox]['parent'] = FALSE;
135 /* Compute the collapse status for this box. */
136 if( isset($collapse_folders) && $collapse_folders ) {
137 $collapse = getPref($data_dir, $username, 'collapse_folder_' . $parbox_name);
138 $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED
: $collapse);
140 $collapse = SM_BOX_UNCOLLAPSED
;
142 $boxes[$parbox]['collapse'] = $collapse;
144 /* Otherwise, get the name of the next box. */
145 if (isset($boxes[$nextbox]['unformatted'])) {
146 $nextbox_name = $boxes[$nextbox]['unformatted'];
151 /* Compute any children boxes for this box. */
152 while (($nextbox < $boxcount) &&
153 (is_parent_box($boxes[$nextbox]['unformatted'], $parbox_name))) {
155 /* Note that this 'parent' box has at least one child. */
156 $boxes[$parbox]['parent'] = TRUE;
158 /* Compute the visiblity of this box. */
159 $boxes[$nextbox]['visible'] = ($boxes[$parbox]['visible'] &&
160 ($boxes[$parbox]['collapse'] != SM_BOX_COLLAPSED
));
162 /* Compute the visibility of any child boxes. */
163 compute_folder_children($nextbox, $boxcount);
166 /* Set the parent box to the current next box. */
171 * Create the link for a parent folder that will allow that
172 * parent folder to either be collapsed or expaned, as is
173 * currently appropriate.
175 function create_collapse_link($boxnum) {
176 global $boxes, $imapConnection, $unseen_notify, $color, $use_icons, $icon_theme;
177 $mailbox = urlencode($boxes[$boxnum]['unformatted']);
179 /* Create the link for this collapse link. */
180 $link = '<a target="left" style="text-decoration:none" ' .
181 'href="left_main.php?';
182 if ($boxes[$boxnum]['collapse'] == SM_BOX_COLLAPSED
) {
183 if ($use_icons && $icon_theme != 'none') {
184 $link .= "unfold=$mailbox\"><IMG src=\"" . SM_PATH
. "images/plus.png\" border=\"0\" height=\"7\" width=\"7\">";
186 $link .= "unfold=$mailbox\">+";
189 if ($use_icons && $icon_theme != 'none') {
190 $link .= "fold=$mailbox\"><IMG src=\"" . SM_PATH
. "images/minus.png\" border=\"0\" height=\"7\" width=\"7\">";
192 $link .= "fold=$mailbox\">-";
197 /* Return the finished product. */
202 * create_unseen_string:
204 * Create unseen and total message count for both this folder and
207 * @param string $boxName name of the current mailbox
208 * @param array $boxArray array for the current mailbox
209 * @param $imapConnection current imap connection in use
210 * @return array unseen message string (for display), unseen message count
212 function create_unseen_string($boxName, $boxArray, $imapConnection, $unseen_type) {
213 global $boxes, $unseen_type, $color, $unseen_cum;
215 /* Initialize the return value. */
216 $result = array(0,0);
218 /* Initialize the counts for this folder. */
220 $boxMessageCount = 0;
221 $totalUnseenCount = 0;
222 $totalMessageCount = 0;
224 /* Collect the counts for this box alone. */
225 $status = sqimap_status_messages($imapConnection, $boxName);
226 $boxUnseenCount = $status['UNSEEN'];
227 if ($boxUnseenCount === false) {
230 if ($unseen_type == 2) {
231 $boxMessageCount = $status['MESSAGES'];
234 /* Initialize the total counts. */
236 if ($boxArray['collapse'] == SM_BOX_COLLAPSED
&& $unseen_cum) {
237 /* Collect the counts for this boxes subfolders. */
238 $curBoxLength = strlen($boxName);
239 $boxCount = count($boxes);
241 for ($i = 0; $i < $boxCount; ++
$i) {
242 /* Initialize the counts for this subfolder. */
244 $subMessageCount = 0;
246 /* Collect the counts for this subfolder. */
247 if (($boxName != $boxes[$i]['unformatted'])
248 && (substr($boxes[$i]['unformatted'], 0, $curBoxLength) == $boxName)
249 && !in_array('noselect', $boxes[$i]['flags'])) {
250 $status = sqimap_status_messages($imapConnection, $boxes[$i]['unformatted']);
251 $subUnseenCount = $status['UNSEEN'];
252 if ($unseen_type == 2) {
253 $subMessageCount = $status['MESSAGES'];;
255 /* Add the counts for this subfolder to the total. */
256 $totalUnseenCount +
= $subUnseenCount;
257 $totalMessageCount +
= $subMessageCount;
261 /* Add the counts for all subfolders to that of the box. */
262 $boxUnseenCount +
= $totalUnseenCount;
263 $boxMessageCount +
= $totalMessageCount;
266 /* And create the magic unseen count string. */
267 /* Really a lot more then just the unseen count. */
268 if (($unseen_type == 1) && ($boxUnseenCount > 0)) {
269 $result[0] = "($boxUnseenCount)";
270 } else if ($unseen_type == 2) {
271 $result[0] = "($boxUnseenCount/$boxMessageCount)";
272 $result[0] = "<font color=\"$color[11]\">$result[0]</font>";
275 /* Set the unseen count to return to the outside world. */
276 $result[1] = $boxUnseenCount;
278 /* Return our happy result. */
283 * This simple function checks if a box is another box's parent.
285 function is_parent_box($curbox_name, $parbox_name) {
288 /* Extract the name of the parent of the current box. */
289 $curparts = explode($delimiter, $curbox_name);
290 $curname = array_pop($curparts);
291 $actual_parname = implode($delimiter, $curparts);
292 $actual_parname = substr($actual_parname,0,strlen($parbox_name));
294 /* Compare the actual with the given parent name. */
295 return ($parbox_name == $actual_parname);
298 function ListBoxes ($boxes, $j=0 ) {
299 global $data_dir, $username, $startmessage, $color, $unseen_notify, $unseen_type,
300 $move_to_trash, $trash_folder, $collapse_folders, $imapConnection,
301 $use_icons, $icon_theme;
303 if (!isset($boxes) ||
empty($boxes))
309 $unseen_found = false;
312 $mailbox = $boxes->mailboxname_full
;
314 $leader .= str_repeat(' ',$j);
315 $mailboxURL = urlencode($mailbox);
317 /* get unseen/total messages information */
318 /* Only need to display info when option is set */
319 if (isset($unseen_notify) && ($unseen_notify > 1) &&
320 (($boxes->unseen
!== false) ||
($boxes->total
!== false))) {
322 if ($boxes->unseen
!== false)
323 $unseen = $boxes->unseen
;
326 Should only display unseen info if the folder is inbox
327 or you set the option for all folders
330 if ((strtolower($mailbox) == 'inbox') ||
($unseen_notify == 3)) {
331 $unseen_string = $unseen;
333 /* If users requests, display message count too */
334 if (isset($unseen_type) && ($unseen_type == 2) && ($boxes->total
!== false)) {
335 $unseen_string .= '/' . $boxes->total
;
338 $unseen_string = "<font color=\"$color[11]\">($unseen_string)</font>";
341 Finally allow the script to display the values by setting a boolean.
342 This can only occur if the unseen count is great than 0 (if you have
343 unseen count only), or you have the message count too.
345 if (($unseen > 0) ||
(isset($unseen_type) && ($unseen_type ==2))) {
346 $unseen_found = true;
351 if (isset($boxes->mbxs
[0]) && $collapse_folders) {
352 $collapse = getPref($data_dir, $username, 'collapse_folder_' . $mailbox);
353 $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED
: $collapse);
355 $link = '<a target="left" style="text-decoration:none" ' .'href="left_main.php?';
357 if ($use_icons && $icon_theme != 'none') {
358 $link .= "unfold=$mailboxURL\">$leader<IMG src=\"" . SM_PATH
. "images/plus.png\" border=\"0\" height=\"7\" width=\"7\"> </tt>";
360 $link .= "unfold=$mailboxURL\">$leader+ </tt>";
363 if ($use_icons && $icon_theme != 'none') {
364 $link .= "fold=$mailboxURL\">$leader<IMG src=\"" . SM_PATH
. "images/minus.png\" border=\"0\" height=\"7\" width=\"7\"> </tt>";
366 $link .= "fold=$mailboxURL\">$leader- </tt>";
372 $pre.= $leader . ' </tt>';
375 /* If there are unseen message, bold the line. */
376 if (($move_to_trash) && ($mailbox == $trash_folder)) {
377 if (! isset($boxes->total
)) {
378 $boxes->total
= sqimap_status_messages($imapConnection, $mailbox);
383 $pre .= "<a href=\"right_main.php?PG_SHOWALL=0&sort=0;startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\">";
388 if ($boxes->total
> 0) {
392 $pre .= "<a href=\"right_main.php?PG_SHOWALL=0&sort=0;startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\">";
396 /* Print unseen information. */
398 $end .= " <small>$unseen_string</small>";
400 $end .= "\n<small>\n" .
401 " (<a href=\"empty_trash.php\" style=\"text-decoration:none\">"._("purge")."</a>)" .
405 if (!$boxes->is_noselect
) {
409 $pre .= "<a href=\"right_main.php?PG_SHOWALL=0&sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\">";
415 /* Print unseen information. */
417 $end .= " <small>$unseen_string</small>";
424 if ($boxes->is_special
) {
425 $font = "<font color=\"$color[11]\">";
426 $fontend = "</font>";
429 // let plugins fiddle with end of line
430 $end .= concat_hook_function('left_main_after_each_folder',
431 array(isset($numMessages) ?
$numMessages : '',
432 $boxes->mailboxname_full
, $imapConnection));
436 if (!$boxes->is_root
) {
437 echo "" . $pre .$font. str_replace(array(' ','<','>'),array(' ','<','>'),$boxes->mailboxname_sub
) .$fontend . $end. '<br />' . "\n";
441 if (!$collapse ||
$boxes->is_root
) {
442 for ($i = 0; $i <count($boxes->mbxs
); $i++
) {
443 listBoxes($boxes->mbxs
[$i],$j);
448 function ListAdvancedBoxes ($boxes, $mbx, $j='ID.0000' ) {
449 global $data_dir, $username, $startmessage, $color, $unseen_notify, $unseen_type,
450 $move_to_trash, $trash_folder, $collapse_folders;
452 if (!isset($boxes) ||
empty($boxes))
455 /* use_folder_images only works if the images exist in ../images */
456 $use_folder_images = true;
461 $unseen_found = false;
464 $mailbox = $boxes->mailboxname_full
;
465 $mailboxURL = urlencode($mailbox);
467 /* get unseen/total messages information */
468 /* Only need to display info when option is set */
469 if (isset($unseen_notify) && ($unseen_notify > 1) &&
470 (($boxes->unseen
!== false) ||
($boxes->total
!== false))) {
472 if ($boxes->unseen
!== false)
473 $unseen = $boxes->unseen
;
476 Should only display unseen info if the folder is inbox
477 or you set the option for all folders
480 if ((strtolower($mailbox) == 'inbox') ||
($unseen_notify == 3)) {
481 $unseen_string = $unseen;
483 /* If users requests, display message count too */
484 if (isset($unseen_type) && ($unseen_type == 2) && ($boxes->total
!== false)) {
485 $unseen_string .= '/' . $boxes->total
;
488 $unseen_string = "<font color=\"$color[11]\">($unseen_string)</font>";
491 Finally allow the script to display the values by setting a boolean.
492 This can only occur if the unseen count is great than 0 (if you have
493 unseen count only), or you have the message count too.
495 if (($unseen > 0) ||
(isset($unseen_type) && ($unseen_type ==2))) {
496 $unseen_found = true;
501 /* If there are unseen message, bold the line. */
502 if ($unseen > 0) { $pre .= '<b>'; }
504 /* color special boxes */
505 if ($boxes->is_special
) {
506 $pre .= "<font color=\"$color[11]\">";
510 /* If there are unseen message, close bolding. */
511 if ($unseen > 0) { $end .= '</b>'; }
513 /* Print unseen information. */
515 $end .= " $unseen_string";
518 if (($move_to_trash) && ($mailbox == $trash_folder)) {
519 if (! isset($numMessages)) {
520 $numMessages = $boxes->total
;
522 $pre = "<a class=\"mbx_link\" href=\"right_main.php?PG_SHOWALL=0&sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\">" . $pre;
524 if ($numMessages > 0) {
525 $urlMailbox = urlencode($mailbox);
526 $end .= "\n<small>\n" .
527 " (<a class=\"mbx_link\" href=\"empty_trash.php\">"._("purge")."</a>)" .
531 if (!$boxes->is_noselect
) { /* \Noselect boxes can't be selected */
532 $pre = "<a class=\"mbx_link\" href=\"right_main.php?PG_SHOWALL=0&sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\">" . $pre;
537 // let plugins fiddle with end of line
538 global $imapConnection;
539 $end .= concat_hook_function('left_main_after_each_folder',
540 array(isset($numMessages) ?
$numMessages : '',
541 $boxes->mailboxname_full
, $imapConnection));
543 if (!$boxes->is_root
) {
544 if ($use_folder_images) {
545 if ($boxes->is_inbox
) {
546 $folder_img = '../images/inbox.png';
547 } else if ($boxes->is_sent
) {
548 $folder_img = '../images/senti.png';
549 } else if ($boxes->is_trash
) {
550 $folder_img = '../images/delitem.png';
551 } else if ($boxes->is_draft
) {
552 $folder_img = '../images/draft.png';
553 } else if ($boxes->is_noinferiors
) {
554 $folder_img = '../images/folder_noinf.png';
556 $folder_img = '../images/folder.png';
558 $folder_img = ' <img src="'.$folder_img.'" height="15" valign="center" /> ';
562 if (!isset($boxes->mbxs
[0])) {
563 echo ' ' . html_tag( 'div',
564 '<tt>'. $pre . $folder_img . '</tt>'. str_replace(array(' ','<','>'),array(' ','<','>'),$boxes->mailboxname_sub
) . $end,
565 'left', '', 'class="mbx_sub" id="' .$j. '"' ) . "\n";
567 /* get collapse information */
568 if ($collapse_folders) {
569 $form_entry = $j.'F';
570 if (isset($mbx) && isset($mbx[$form_entry])) {
571 $collapse = $mbx[$form_entry];
572 setPref($data_dir, $username, 'collapse_folder_'.$boxes->mailboxname_full
, $collapse ? SM_BOX_COLLAPSED
: SM_BOX_UNCOLLAPSED
);
574 $collapse = getPref($data_dir, $username, 'collapse_folder_' . $mailbox);
575 $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED
: $collapse);
577 $img_src = ($collapse ?
'../images/plus.png' : '../images/minus.png');
578 $collapse_link = '<a href="javascript:void(0)">'." <img src=\"$img_src\" border=\"1\" id=$j onclick=\"hidechilds(this)\" style=\"cursor:hand\" /></a>";
582 echo ' ' . html_tag( 'div',
583 $collapse_link . $pre . $folder_img . ' '. $boxes->mailboxname_sub
. $end ,
584 'left', '', 'class="mbx_par" id="' .$j. 'P"' ) . "\n";
585 echo ' <input type="hidden" name="mbx['.$j. 'F]" value="'.$collapse.'" id="mbx['.$j.'F]" />'."\n";
589 $visible = ($collapse ?
' style="display:none"' : ' style="display:block"');
590 if (isset($boxes->mbxs
[0]) && !$boxes->is_root
) /* mailbox contains childs */
591 echo html_tag( 'div', '', 'left', '', 'class="par_area" id='.$j.'.0000 '. $visible ) . "\n";
595 for ($i = 0; $i <count($boxes->mbxs
); $i++
) {
597 ListAdvancedBoxes($boxes->mbxs
[$i],$mbx,$j);
599 if (isset($boxes->mbxs
[0]) && !$boxes->is_root
)
600 echo '</div>'."\n\n";
606 /* -------------------- MAIN ------------------------ */
609 sqgetGlobalVar('username', $username, SQ_SESSION
);
610 sqgetGlobalVar('key', $key, SQ_COOKIE
);
611 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION
);
612 sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION
);
614 sqgetGlobalVar('fold', $fold, SQ_GET
);
615 sqgetGlobalVar('unfold', $unfold, SQ_GET
);
619 // open a connection on the imap port (143)
620 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 10); // the 10 is to hide the output
623 * Using stristr since older preferences may contain "None" and "none".
625 if (isset($left_refresh) && ($left_refresh != '') &&
626 !stristr($left_refresh, 'none')){
627 $xtra = "\n<meta http-equiv=\"Expires\" content=\"Thu, 01 Dec 1994 16:00:00 GMT\" />\n" .
628 "<meta http-equiv=\"Pragma\" content=\"no-cache\" />\n".
629 "<meta http-equiv=\"REFRESH\" content=\"$left_refresh;URL=left_main.php\" />\n";
635 * $advanced_tree and $oldway are boolean vars which are default set to default
637 * Setting $oldway to false causes left_main.php to use the new experimental
638 * way of getting the mailbox-tree.
639 * Setting $advanced tree to true causes SM to display a experimental
640 * mailbox-tree with dhtml behaviour.
641 * It only works on browsers which supports css and javascript. The used
642 * javascript is experimental and doesn't support all browsers.
643 * It has been tested on IE6 an Konquerer 3.0.0-2.
644 * It is now tested and working on: (please test and update this list)
645 * Windows: IE 5.5 SP2, IE 6 SP1, Gecko based (Mozilla, Firebird) and Opera7
648 * In the function ListAdvancedBoxes there is another var $use_folder_images.
649 * setting this to true is only usefull if the images exists in ../images.
651 * Feel free to experiment with the code and report bugs and enhancements
652 * to marc@its-projects.nl
655 /* set this to true if you want to see a nicer mailboxtree */
656 if (! isset($advanced_tree) ||
$advanced_tree=="" ) {
657 $advanced_tree=false;
659 /* default SM behaviour */
660 if (! isset($oldway) ||
$oldway=="" ) {
664 if ($advanced_tree) {
666 <script language="Javascript" TYPE="text/javascript">
671 if (document.images) {
672 var treeImages = new Array;
673 var arguments = preload.arguments;
674 for (var i = 0; i<arguments.length; i++) {
675 treeImages[i] = new Image();
676 treeImages[i].src = arguments[i];
685 function fTreeTimeout() {
686 if (vTreeDiv.readyState == "complete")
687 vTreeImg.src = vTreeSrc;
689 setTimeout("fTreeTimeout()", 100);
692 function hidechilds(img) {
693 id = img.id + ".0000";
694 form_id = "mbx[" + img.id +"F]";
695 if (document.all) { //IE, Opera7
696 div = document.all[id];
698 if (div.style.display == "none") {
699 vTreeSrc = "../images/minus.png";
704 vTreeSrc = "../images/plus.png";
710 if (typeof vTreeDiv.readyState != "undefined") //IE
711 setTimeout("fTreeTimeout()",100);
713 vTreeImg.src = vTreeSrc;
714 div.style.display = style;
715 document.all[form_id].value = value;
718 else if (document.getElementById) { //Gecko
719 div = document.getElementById(id);
721 if (div.style.display == "none") {
722 src = "../images/minus.png";
727 src = "../images/plus.png";
731 div.style.display = style;
733 document.getElementById(form_id).value = value;
738 function buttonover(el,on) {
740 // el.style.borderColor="$color[9]";}
741 el.style.background="$color[0]";}
743 el.style.background="$color[9]";}
746 function buttonclick(el,on) {
748 el.style.border="groove";}
750 el.style.border="ridge";}
753 function hideframe(hide) {
756 $xtra .= " left_size = \"$left_size\";\n";
759 masterf = window.parent.document.all["fs1"];
760 leftf = window.parent.document.all["left"];
761 leftcontent = document.all["leftframe"];
762 leftbutton = document.all["showf"];
763 } else if (document.getElementById) {
764 masterf = window.parent.document.getElementById("fs1");
765 leftf = window.parent.document.getElementById("left");
766 leftcontent = document.getElementById("leftframe");
767 leftbutton = document.getElementById("showf");
772 new_col = calc_col("20");
773 masterf.cols = new_col;
774 document.body.scrollLeft=0;
775 document.body.style.overflow='hidden';
776 leftcontent.style.display = 'none';
777 leftbutton.style.display='block';
779 masterf.cols = calc_col(left_size);
780 document.body.style.overflow='';
781 leftbutton.style.display='none';
782 leftcontent.style.display='block';
787 function calc_col(c_w) {
790 if ($location_of_bar == 'right') {
791 $xtra .= ' right=true;';
793 $xtra .= ' right=false;';
805 function resizeframe(direction) {
807 masterf = window.parent.document.all["fs1"];
808 } else if (document.getElementById) {
809 window.parent.document.getElementById("fs1");
815 if ($location_of_bar == 'right') {
816 $xtra .= ' colPat=/^\*,(\d+)$/;';
818 $xtra .= ' colPat=/^(\d+),.*$/;';
823 old_col = masterf.cols;
824 colPat.exec(old_col);
827 new_col_width = parseInt(RegExp.$1) + 25;
830 if (parseInt(RegExp.$1) > 35) {
831 new_col_width = parseInt(RegExp.$1) - 25;
834 masterf.cols = calc_col(new_col_width);
843 /* style definitions */
847 <style type="text/css">
850 margin: 0px 0px 0px 0px;
851 padding: 5px 5px 5px 5px;
856 border-color: $color[9];
857 background:$color[0];
870 text-decoration: none;
871 background-color: $color[0];
876 background-color: $color[9];
898 border-left-width:0.1em;
899 border-left-color:$color[9];
900 border-bottom: solid;
901 border-bottom-width:0.1em;
902 border-bottom-color:$color[9];
914 border-color:$color[9];
915 background: $color[0];
926 displayHtmlHeader( 'SquirrelMail', $xtra );
928 /* If requested and not yet complete, attempt to autocreate folders. */
929 if ($auto_create_special && !isset($auto_create_done)) {
930 $autocreate = array($sent_folder, $trash_folder, $draft_folder);
931 foreach( $autocreate as $folder ) {
932 if (($folder != '') && ($folder != 'none')) {
933 if ( !sqimap_mailbox_exists($imapConnection, $folder)) {
934 sqimap_mailbox_create($imapConnection, $folder, '');
935 } else if (!sqimap_mailbox_is_subscribed($imapConnection, $folder)) {
936 sqimap_subscribe($imapConnection, $folder);
941 /* Let the world know that autocreation is complete! Hurrah! */
942 $auto_create_done = TRUE;
943 sqsession_register($auto_create_done, 'auto_create_done');
948 ' onload="preload(\'../images/minus.png\',\'../images/plus.png\')"' .
949 " bgcolor=\"$color[3]\" text=\"$color[6]\" link=\"$color[6]\" vlink=\"$color[6]\" alink=\"$color[6]\">\n";
951 echo "\n<body bgcolor=\"$color[3]\" text=\"$color[6]\" link=\"$color[6]\" vlink=\"$color[6]\" alink=\"$color[6]\">\n";
953 do_hook('left_main_before');
954 if ($advanced_tree) {
955 /* nice future feature, needs layout !! volunteers? */
956 $right_pos = $left_size - 20;
957 /* 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>';
958 echo '<div ID="showf" style="width=20;font-size:12;display:none;"><a href="javascript:hideframe(false)"><b>>></b></a></div>';
959 echo '<div ID="incrf" style="width=20;font-size:12"><a href="javascript:resizeframe(true)"><b>></b></a></div>';
960 echo '<div ID="decrf" style="width=20;font-size:12"><a href="javascript:resizeframe(false)"><b><</b></a></div></div>';
961 echo '<div ID="leftframe"><br /><br />';*/
964 echo "\n\n" . html_tag( 'table', '', 'left', '', 'border="0" cellspacing="0" cellpadding="0" width="99%"' ) .
966 html_tag( 'td', '', 'left' ) .
967 '<center><font size="4"><b>'. _("Folders") . "</b><br /></font>\n\n";
969 if ($date_format != 6) {
970 /* First, display the clock. */
971 if ($hour_format == 1) {
973 if ($date_format == 4) {
977 if ($date_format == 4) {
984 switch( $date_format ) {
986 $clk = date('Y-m-d '.$hr. ' T', time());
989 $clk = date('m/d/y '.$hr, time());
992 $clk = date('d/m/y '.$hr, time());
996 $clk = date($hr, time());
999 $clk = getDayAbrv( date( 'w', time() ) ) . date( ', ' . $hr, time() );
1001 $clk = str_replace(' ',' ',$clk);
1003 echo '<center><small>' . str_replace(' ',' ',_("Last Refresh")) .
1004 ": $clk</small></center>";
1007 /* Next, display the refresh button. */
1008 echo '<small>(<a href="../src/left_main.php" target="left">'.
1009 _("refresh folder list") . '</a>)</small></center><br />';
1011 /* Lastly, display the folder list. */
1012 if ( $collapse_folders ) {
1013 /* If directed, collapse or uncollapse a folder. */
1015 setPref($data_dir, $username, 'collapse_folder_' . $fold, SM_BOX_COLLAPSED
);
1016 } else if (isset($unfold)) {
1017 setPref($data_dir, $username, 'collapse_folder_' . $unfold, SM_BOX_UNCOLLAPSED
);
1021 /* Get unseen/total display prefs */
1022 $unseen_type = getPref( $data_dir , $username , 'unseen_type' );
1023 $unseen_notify = getPref( $data_dir , $username , 'unseen_notify' );
1025 if (!isset($unseen_type) ||
empty($unseen_type)) {
1026 if (isset($default_unseen_type) && !empty($default_unseen_type)) {
1027 $unseen_type = $default_unseen_type;
1033 if (!isset($unseen_notify) ||
empty($unseen_notify)) {
1034 if (isset($default_unseen_notify) && !empty($default_unseen_notify)) {
1035 $unseen_notify = $default_unseen_notify;
1041 if ($oldway) { /* normal behaviour SM */
1043 $boxes = sqimap_mailbox_list($imapConnection);
1044 /* Prepare do do out collapsedness and visibility computation. */
1046 $boxcount = count($boxes);
1048 /* Compute the collapsedness and visibility of each box. */
1050 while ($curbox < $boxcount) {
1051 $boxes[$curbox]['visible'] = TRUE;
1052 compute_folder_children($curbox, $boxcount);
1055 for ($i = 0; $i < count($boxes); $i++
) {
1056 if ( $boxes[$i]['visible'] ) {
1057 $mailbox = $boxes[$i]['formatted'];
1058 $mblevel = substr_count($boxes[$i]['unformatted'], $delimiter) +
1;
1060 /* Create the prefix for the folder name and link. */
1061 $prefix = str_repeat(' ',$mblevel);
1062 if (isset($collapse_folders) && $collapse_folders && $boxes[$i]['parent']) {
1063 $prefix = str_replace(' ',' ',substr($prefix,0,strlen($prefix)-2)).
1064 create_collapse_link($i) . ' ';
1066 $prefix = str_replace(' ',' ',$prefix);
1068 $line = "<nobr><tt>$prefix</tt>";
1070 /* Add the folder name and link. */
1071 if (! isset($color[15])) {
1072 $color[15] = $color[6];
1075 if (in_array('noselect', $boxes[$i]['flags'])) {
1076 if( isSpecialMailbox( $boxes[$i]['unformatted']) ) {
1077 $line .= "<font color=\"$color[11]\">";
1079 $line .= "<font color=\"$color[15]\">";
1081 if (ereg("^( *)([^ ]*)", $mailbox, $regs)) {
1082 $mailbox = str_replace(' ','',$mailbox);
1083 $line .= str_replace(' ', ' ', $mailbox);
1087 $line .= formatMailboxName($imapConnection, $boxes[$i]);
1090 /* Put the final touches on our folder line. */
1091 $line .= "</nobr><br>\n";
1093 /* Output the line for this folder. */
1097 } else { /* expiremental code */
1098 $boxes = sqimap_mailbox_tree($imapConnection);
1099 if (isset($advanced_tree) && $advanced_tree) {
1100 echo '<form name="collapse" action="left_main.php" method="post" ' .
1101 'enctype="multipart/form-data"'."\n";
1103 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 />';
1104 echo '<div id="mailboxes" class="mailboxes">'."\n\n";
1105 sqgetGlobalVar('mbx', $mbx, SQ_POST
);
1106 if (!isset($mbx)) $mbx=NULL;
1107 ListAdvancedBoxes($boxes, $mbx);
1110 echo '</form>'."\n";
1112 //sqimap_get_status_mbx_tree($imap_stream,$boxes)
1115 } /* if ($oldway) else ... */
1116 do_hook('left_main_after');
1117 sqimap_logout($imapConnection);
1119 echo '</td></tr></table>' . "\n".
1120 "</div></body></html>\n";