29a689fbee3b4c6f152353c15624685cddda6e7c
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.
13 * @package squirrelmail
16 /** Path for SquirrelMail required files. */
17 define('SM_PATH','../');
19 /* SquirrelMail required files. */
20 require_once(SM_PATH
. 'include/validate.php');
21 require_once(SM_PATH
. 'functions/imap.php');
22 require_once(SM_PATH
. 'functions/plugin.php');
23 require_once(SM_PATH
. 'functions/page_header.php');
24 require_once(SM_PATH
. 'functions/html.php');
25 require_once(SM_PATH
. 'functions/date.php');
27 /* These constants are used for folder stuff. */
28 define('SM_BOX_UNCOLLAPSED', 0);
29 define('SM_BOX_COLLAPSED', 1);
31 /* --------------------- FUNCTIONS ------------------------- */
33 function formatMailboxName($imapConnection, $box_array) {
35 global $folder_prefix, $trash_folder, $sent_folder,
36 $color, $move_to_sent, $move_to_trash,
37 $unseen_notify, $unseen_type, $collapse_folders,
38 $draft_folder, $save_as_draft,
39 $use_special_folder_color;
40 $real_box = $box_array['unformatted'];
41 $mailbox = str_replace(' ','',$box_array['formatted']);
42 $mailboxURL = urlencode($real_box);
44 /* Strip down the mailbox name. */
45 if (ereg("^( *)([^ ]*)$", $mailbox, $regs)) {
49 $status = array('','');
50 if (($unseen_notify == 2 && $real_box == 'INBOX') ||
51 $unseen_notify == 3) {
52 $tmp_status = create_unseen_string($real_box, $box_array, $imapConnection, $unseen_type );
53 if ($status !== false) {
54 $status = $tmp_status;
57 list($unseen_string, $unseen) = $status;
58 $special_color = ($use_special_folder_color && isSpecialMailbox($real_box));
60 /* Start off with a blank line. */
63 /* If there are unseen message, bold the line. */
64 if ($unseen > 0) { $line .= '<B>'; }
66 /* Create the link for this folder. */
67 if ($status !== false) {
68 $line .= '<a href="right_main.php?PG_SHOWALL=0&sort=0&startMessage=1&mailbox='.
69 $mailboxURL.'" TARGET="right" STYLE="text-decoration:none">';
72 $line .= "<font color=\"$color[11]\">";
74 if ( $mailbox == 'INBOX' ) {
77 $line .= str_replace(' ',' ',$mailbox);
79 if ($special_color == TRUE)
81 if ($status !== false) {
85 /* If there are unseen message, close bolding. */
86 if ($unseen > 0) { $line .= "</B>"; }
88 /* Print unseen information. */
89 if ($unseen_string != '') {
90 $line .= " <SMALL>$unseen_string</SMALL>";
93 /* If it's the trash folder, show a purge link when needed */
94 if (($move_to_trash) && ($real_box == $trash_folder)) {
95 if (! isset($numMessages)) {
96 $numMessages = sqimap_get_num_messages($imapConnection, $real_box);
99 if (($numMessages > 0) or ($box_array['parent'] == 1)) {
100 $urlMailbox = urlencode($real_box);
101 $line .= "\n<small>\n" .
102 " (<A HREF=\"empty_trash.php\" style=\"text-decoration:none\">"._("purge")."</A>)" .
108 // let plugins fiddle with end of line
109 $line .= concat_hook_function('left_main_after_each_folder',
110 array(isset($numMessages) ?
$numMessages : '', $real_box, $imapConnection));
113 /* Return the final product. */
118 * Recursive function that computes the collapsed status and parent
119 * (or not parent) status of this box, and the visiblity and collapsed
120 * status and parent (or not parent) status for all children boxes.
122 function compute_folder_children(&$parbox, $boxcount) {
123 global $boxes, $data_dir, $username, $collapse_folders;
124 $nextbox = $parbox +
1;
126 /* Retreive the name for the parent box. */
127 $parbox_name = $boxes[$parbox]['unformatted'];
129 /* 'Initialize' this parent box to childless. */
130 $boxes[$parbox]['parent'] = FALSE;
132 /* Compute the collapse status for this box. */
133 if( isset($collapse_folders) && $collapse_folders ) {
134 $collapse = getPref($data_dir, $username, 'collapse_folder_' . $parbox_name);
135 $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED
: $collapse);
137 $collapse = SM_BOX_UNCOLLAPSED
;
139 $boxes[$parbox]['collapse'] = $collapse;
141 /* Otherwise, get the name of the next box. */
142 if (isset($boxes[$nextbox]['unformatted'])) {
143 $nextbox_name = $boxes[$nextbox]['unformatted'];
148 /* Compute any children boxes for this box. */
149 while (($nextbox < $boxcount) &&
150 (is_parent_box($boxes[$nextbox]['unformatted'], $parbox_name))) {
152 /* Note that this 'parent' box has at least one child. */
153 $boxes[$parbox]['parent'] = TRUE;
155 /* Compute the visiblity of this box. */
156 $boxes[$nextbox]['visible'] = ($boxes[$parbox]['visible'] &&
157 ($boxes[$parbox]['collapse'] != SM_BOX_COLLAPSED
));
159 /* Compute the visibility of any child boxes. */
160 compute_folder_children($nextbox, $boxcount);
163 /* Set the parent box to the current next box. */
168 * Create the link for a parent folder that will allow that
169 * parent folder to either be collapsed or expaned, as is
170 * currently appropriate.
172 function create_collapse_link($boxnum) {
173 global $boxes, $imapConnection, $unseen_notify, $color;
174 $mailbox = urlencode($boxes[$boxnum]['unformatted']);
176 /* Create the link for this collapse link. */
177 $link = '<a target="left" style="text-decoration:none" ' .
178 'href="left_main.php?';
179 if ($boxes[$boxnum]['collapse'] == SM_BOX_COLLAPSED
) {
180 $link .= "unfold=$mailbox\">+";
182 $link .= "fold=$mailbox\">-";
186 $hooklink = do_hook_function('create_collapse_link',$link);
190 /* Return the finished product. */
195 * create_unseen_string:
197 * Create unseen and total message count for both this folder and
200 * @param string $boxName name of the current mailbox
201 * @param array $boxArray array for the current mailbox
202 * @param $imapConnection current imap connection in use
203 * @return array unseen message string (for display), unseen message count
205 function create_unseen_string($boxName, $boxArray, $imapConnection, $unseen_type) {
206 global $boxes, $unseen_type, $color, $unseen_cum;
208 /* Initialize the return value. */
209 $result = array(0,0);
211 /* Initialize the counts for this folder. */
213 $boxMessageCount = 0;
214 $totalUnseenCount = 0;
215 $totalMessageCount = 0;
217 /* Collect the counts for this box alone. */
218 $status = sqimap_status_messages($imapConnection, $boxName);
219 $boxUnseenCount = $status['UNSEEN'];
220 if ($boxUnseenCount === false) {
223 if ($unseen_type == 2) {
224 $boxMessageCount = $status['MESSAGES'];
227 /* Initialize the total counts. */
229 if ($boxArray['collapse'] == SM_BOX_COLLAPSED
&& $unseen_cum) {
230 /* Collect the counts for this boxes subfolders. */
231 $curBoxLength = strlen($boxName);
232 $boxCount = count($boxes);
234 for ($i = 0; $i < $boxCount; ++
$i) {
235 /* Initialize the counts for this subfolder. */
237 $subMessageCount = 0;
239 /* Collect the counts for this subfolder. */
240 if (($boxName != $boxes[$i]['unformatted'])
241 && (substr($boxes[$i]['unformatted'], 0, $curBoxLength) == $boxName)
242 && !in_array('noselect', $boxes[$i]['flags'])) {
243 $status = sqimap_status_messages($imapConnection, $boxes[$i]['unformatted']);
244 $subUnseenCount = $status['UNSEEN'];
245 if ($unseen_type == 2) {
246 $subMessageCount = $status['MESSAGES'];;
248 /* Add the counts for this subfolder to the total. */
249 $totalUnseenCount +
= $subUnseenCount;
250 $totalMessageCount +
= $subMessageCount;
254 /* Add the counts for all subfolders to that of the box. */
255 $boxUnseenCount +
= $totalUnseenCount;
256 $boxMessageCount +
= $totalMessageCount;
259 /* And create the magic unseen count string. */
260 /* Really a lot more then just the unseen count. */
261 if (($unseen_type == 1) && ($boxUnseenCount > 0)) {
262 $result[0] = "($boxUnseenCount)";
263 } else if ($unseen_type == 2) {
264 $result[0] = "($boxUnseenCount/$boxMessageCount)";
265 $result[0] = "<font color=\"$color[11]\">$result[0]</font>";
268 /* Set the unseen count to return to the outside world. */
269 $result[1] = $boxUnseenCount;
271 /* Return our happy result. */
276 * This simple function checks if a box is another box's parent.
278 function is_parent_box($curbox_name, $parbox_name) {
281 /* Extract the name of the parent of the current box. */
282 $curparts = explode($delimiter, $curbox_name);
283 $curname = array_pop($curparts);
284 $actual_parname = implode($delimiter, $curparts);
285 $actual_parname = substr($actual_parname,0,strlen($parbox_name));
287 /* Compare the actual with the given parent name. */
288 return ($parbox_name == $actual_parname);
291 function ListBoxes ($boxes, $j=0 ) {
292 global $data_dir, $username, $startmessage, $color, $unseen_notify, $unseen_type,
293 $move_to_trash, $trash_folder, $collapse_folders, $imapConnection;
295 if (!isset($boxes) ||
empty($boxes))
301 $unseen_found = false;
304 $mailbox = $boxes->mailboxname_full
;
306 $leader .= str_repeat(' ',$j);
307 $mailboxURL = urlencode($mailbox);
309 /* get unseen/total messages information */
310 /* Only need to display info when option is set */
311 if (isset($unseen_notify) && ($unseen_notify > 1) &&
312 (($boxes->unseen
!== false) ||
($boxes->total
!== false))) {
314 if ($boxes->unseen
!== false)
315 $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;
325 /* If users requests, display message count too */
326 if (isset($unseen_type) && ($unseen_type == 2) && ($boxes->total
!== false)) {
327 $unseen_string .= '/' . $boxes->total
;
330 $unseen_string = "<font color=\"$color[11]\">($unseen_string)</font>";
333 Finally allow the script to display the values by setting a boolean.
334 This can only occur if the unseen count is great than 0 (if you have
335 unseen count only), or you have the message count too.
337 if (($unseen > 0) ||
(isset($unseen_type) && ($unseen_type ==2))) {
338 $unseen_found = true;
343 if (isset($boxes->mbxs
[0]) && $collapse_folders) {
344 $collapse = getPref($data_dir, $username, 'collapse_folder_' . $mailbox);
345 $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED
: $collapse);
347 $link = '<a target="left" style="text-decoration:none" ' .'href="left_main.php?';
349 $link .= "unfold=$mailboxURL\">$leader+ </tt>";
351 $link .= "fold=$mailboxURL\">$leader- </tt>";
356 $pre.= $leader . ' </tt>';
359 /* If there are unseen message, bold the line. */
360 if (($move_to_trash) && ($mailbox == $trash_folder)) {
361 if (! isset($boxes->total
)) {
362 $boxes->total
= sqimap_status_messages($imapConnection, $mailbox);
367 $pre .= "<a href=\"right_main.php?PG_SHOWALL=0&sort=0;startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\">";
372 if ($boxes->total
> 0) {
376 $pre .= "<a href=\"right_main.php?PG_SHOWALL=0&sort=0;startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\">";
380 /* Print unseen information. */
382 $end .= " <small>$unseen_string</small>";
384 $end .= "\n<small>\n" .
385 " (<a href=\"empty_trash.php\" style=\"text-decoration:none\">"._("purge")."</a>)" .
389 if (!$boxes->is_noselect
) {
393 $pre .= "<a href=\"right_main.php?PG_SHOWALL=0&sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\">";
399 /* Print unseen information. */
401 $end .= " <small>$unseen_string</small>";
408 if ($boxes->is_special
) {
409 $font = "<font color=\"$color[11]\">";
410 $fontend = "</font>";
413 // let plugins fiddle with end of line
414 $end .= concat_hook_function('left_main_after_each_folder',
415 array(isset($numMessages) ?
$numMessages : '',
416 $boxes->mailboxname_full
, $imapConnection));
420 if (!$boxes->is_root
) {
421 echo "" . $pre .$font. $boxes->mailboxname_sub
.$fontend . $end. '<br />' . "\n";
425 if (!$collapse ||
$boxes->is_root
) {
426 for ($i = 0; $i <count($boxes->mbxs
); $i++
) {
427 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 if (!isset($boxes) ||
empty($boxes))
439 /* use_folder_images only works if the images exist in ../images */
440 $use_folder_images = true;
445 $unseen_found = false;
448 $mailbox = $boxes->mailboxname_full
;
449 $mailboxURL = urlencode($mailbox);
451 /* get unseen/total messages information */
452 /* Only need to display info when option is set */
453 if (isset($unseen_notify) && ($unseen_notify > 1) &&
454 (($boxes->unseen
!== false) ||
($boxes->total
!== false))) {
456 if ($boxes->unseen
!== false)
457 $unseen = $boxes->unseen
;
460 Should only display unseen info if the folder is inbox
461 or you set the option for all folders
464 if ((strtolower($mailbox) == 'inbox') ||
($unseen_notify == 3)) {
465 $unseen_string = $unseen;
467 /* If users requests, display message count too */
468 if (isset($unseen_type) && ($unseen_type == 2) && ($boxes->total
!== false)) {
469 $unseen_string .= '/' . $boxes->total
;
472 $unseen_string = "<font color=\"$color[11]\">($unseen_string)</font>";
475 Finally allow the script to display the values by setting a boolean.
476 This can only occur if the unseen count is great than 0 (if you have
477 unseen count only), or you have the message count too.
479 if (($unseen > 0) ||
(isset($unseen_type) && ($unseen_type ==2))) {
480 $unseen_found = true;
485 /* If there are unseen message, bold the line. */
486 if ($unseen > 0) { $pre .= '<b>'; }
488 /* color special boxes */
489 if ($boxes->is_special
) {
490 $pre .= "<font color=\"$color[11]\">";
494 /* If there are unseen message, close bolding. */
495 if ($unseen > 0) { $end .= '</b>'; }
497 /* Print unseen information. */
499 $end .= " $unseen_string";
502 if (($move_to_trash) && ($mailbox == $trash_folder)) {
503 if (! isset($numMessages)) {
504 $numMessages = $boxes->total
;
506 $pre = "<a class=\"mbx_link\" href=\"right_main.php?PG_SHOWALL=0&sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\">" . $pre;
508 if ($numMessages > 0) {
509 $urlMailbox = urlencode($mailbox);
510 $end .= "\n<small>\n" .
511 " (<a class=\"mbx_link\" href=\"empty_trash.php\">"._("purge")."</a>)" .
515 if (!$boxes->is_noselect
) { /* \Noselect boxes can't be selected */
516 $pre = "<a class=\"mbx_link\" href=\"right_main.php?PG_SHOWALL=0&sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\">" . $pre;
521 // let plugins fiddle with end of line
522 global $imapConnection;
523 $end .= concat_hook_function('left_main_after_each_folder',
524 array(isset($numMessages) ?
$numMessages : '',
525 $boxes->mailboxname_full
, $imapConnection));
527 if (!$boxes->is_root
) {
528 if ($use_folder_images) {
529 if ($boxes->is_inbox
) {
530 $folder_img = '../images/inbox.png';
531 } else if ($boxes->is_sent
) {
532 $folder_img = '../images/senti.png';
533 } else if ($boxes->is_trash
) {
534 $folder_img = '../images/delitem.png';
535 } else if ($boxes->is_draft
) {
536 $folder_img = '../images/draft.png';
537 } else if ($boxes->is_noinferiors
) {
538 $folder_img = '../images/folder_noinf.png';
540 $folder_img = '../images/folder.png';
542 $folder_img = ' <img src="'.$folder_img.'" height="15" valign="center" /> ';
546 if (!isset($boxes->mbxs
[0])) {
547 echo ' ' . html_tag( 'div',
548 '<tt>'. $pre . $folder_img . '</tt>'. $boxes->mailboxname_sub
. $end,
549 'left', '', 'class="mbx_sub" id="' .$j. '"' ) . "\n";
551 /* get collapse information */
552 if ($collapse_folders) {
553 $form_entry = $j.'F';
554 if (isset($mbx) && isset($mbx[$form_entry])) {
555 $collapse = $mbx[$form_entry];
556 setPref($data_dir, $username, 'collapse_folder_'.$boxes->mailboxname_full
, $collapse ? SM_BOX_COLLAPSED
: SM_BOX_UNCOLLAPSED
);
558 $collapse = getPref($data_dir, $username, 'collapse_folder_' . $mailbox);
559 $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED
: $collapse);
561 $img_src = ($collapse ?
'../images/plus.png' : '../images/minus.png');
562 $collapse_link = '<a href="javascript:void(0)">'." <img src=\"$img_src\" border=\"1\" id=$j onclick=\"hidechilds(this)\" style=\"cursor:hand\" /></a>";
566 echo ' ' . html_tag( 'div',
567 $collapse_link . $pre . $folder_img . ' '. $boxes->mailboxname_sub
. $end ,
568 'left', '', 'class="mbx_par" id="' .$j. 'P"' ) . "\n";
569 echo ' <input type="hidden" name="mbx['.$j. 'F]" value="'.$collapse.'" id="mbx['.$j.'F]" />'."\n";
573 $visible = ($collapse ?
' style="display:none"' : ' style="display:block"');
574 if (isset($boxes->mbxs
[0]) && !$boxes->is_root
) /* mailbox contains childs */
575 echo html_tag( 'div', '', 'left', '', 'class="par_area" id='.$j.'.0000 '. $visible ) . "\n";
579 for ($i = 0; $i <count($boxes->mbxs
); $i++
) {
581 ListAdvancedBoxes($boxes->mbxs
[$i],$mbx,$j);
583 if (isset($boxes->mbxs
[0]) && !$boxes->is_root
)
584 echo '</div>'."\n\n";
590 /* -------------------- MAIN ------------------------ */
593 sqgetGlobalVar('username', $username, SQ_SESSION
);
594 sqgetGlobalVar('key', $key, SQ_COOKIE
);
595 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION
);
596 sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION
);
598 sqgetGlobalVar('fold', $fold, SQ_GET
);
599 sqgetGlobalVar('unfold', $unfold, SQ_GET
);
603 // open a connection on the imap port (143)
604 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 10); // the 10 is to hide the output
607 * Using stristr since older preferences may contain "None" and "none".
609 if (isset($left_refresh) && ($left_refresh != '') &&
610 !stristr($left_refresh, 'none')){
611 $xtra = "\n<meta http-equiv=\"Expires\" content=\"Thu, 01 Dec 1994 16:00:00 GMT\" />\n" .
612 "<meta http-equiv=\"Pragma\" content=\"no-cache\" />\n".
613 "<meta http-equiv=\"REFRESH\" content=\"$left_refresh;URL=left_main.php\" />\n";
619 * $advanced_tree and $oldway are boolean vars which are default set to default
621 * Setting $oldway to false causes left_main.php to use the new experimental
622 * way of getting the mailbox-tree.
623 * Setting $advanced tree to true causes SM to display a experimental
624 * mailbox-tree with dhtml behaviour.
625 * It only works on browsers which supports css and javascript. The used
626 * javascript is experimental and doesn't support all browsers.
627 * It has been tested on IE6 an Konquerer 3.0.0-2.
628 * It is now tested and working on: (please test and update this list)
629 * Windows: IE 5.5 SP2, IE 6 SP1, Gecko based (Mozilla, Firebird) and Opera7
632 * In the function ListAdvancedBoxes there is another var $use_folder_images.
633 * setting this to true is only usefull if the images exists in ../images.
635 * Feel free to experiment with the code and report bugs and enhancements
636 * to marc@its-projects.nl
639 /* set this to true if you want to see a nicer mailboxtree */
640 if (! isset($advanced_tree) ||
$advanced_tree=="" ) {
641 $advanced_tree=false;
643 /* default SM behaviour */
644 if (! isset($oldway) ||
$oldway=="" ) {
648 if ($advanced_tree) {
650 <script language="Javascript" TYPE="text/javascript">
655 if (document.images) {
656 var treeImages = new Array;
657 var arguments = preload.arguments;
658 for (var i = 0; i<arguments.length; i++) {
659 treeImages[i] = new Image();
660 treeImages[i].src = arguments[i];
669 function fTreeTimeout() {
670 if (vTreeDiv.readyState == "complete")
671 vTreeImg.src = vTreeSrc;
673 setTimeout("fTreeTimeout()", 100);
676 function hidechilds(img) {
677 id = img.id + ".0000";
678 form_id = "mbx[" + img.id +"F]";
679 if (document.all) { //IE, Opera7
680 div = document.all[id];
682 if (div.style.display == "none") {
683 vTreeSrc = "../images/minus.png";
688 vTreeSrc = "../images/plus.png";
694 if (typeof vTreeDiv.readyState != "undefined") //IE
695 setTimeout("fTreeTimeout()",100);
697 vTreeImg.src = vTreeSrc;
698 div.style.display = style;
699 document.all[form_id].value = value;
702 else if (document.getElementById) { //Gecko
703 div = document.getElementById(id);
705 if (div.style.display == "none") {
706 src = "../images/minus.png";
711 src = "../images/plus.png";
715 div.style.display = style;
717 document.getElementById(form_id).value = value;
722 function buttonover(el,on) {
724 // el.style.borderColor="$color[9]";}
725 el.style.background="$color[0]";}
727 el.style.background="$color[9]";}
730 function buttonclick(el,on) {
732 el.style.border="groove";}
734 el.style.border="ridge";}
737 function hideframe(hide) {
740 $xtra .= " left_size = \"$left_size\";\n";
743 masterf = window.parent.document.all["fs1"];
744 leftf = window.parent.document.all["left"];
745 leftcontent = document.all["leftframe"];
746 leftbutton = document.all["showf"];
747 } else if (document.getElementById) {
748 masterf = window.parent.document.getElementById("fs1");
749 leftf = window.parent.document.getElementById("left");
750 leftcontent = document.getElementById("leftframe");
751 leftbutton = document.getElementById("showf");
756 new_col = calc_col("20");
757 masterf.cols = new_col;
758 document.body.scrollLeft=0;
759 document.body.style.overflow='hidden';
760 leftcontent.style.display = 'none';
761 leftbutton.style.display='block';
763 masterf.cols = calc_col(left_size);
764 document.body.style.overflow='';
765 leftbutton.style.display='none';
766 leftcontent.style.display='block';
771 function calc_col(c_w) {
774 if ($location_of_bar == 'right') {
775 $xtra .= ' right=true;';
777 $xtra .= ' right=false;';
789 function resizeframe(direction) {
791 masterf = window.parent.document.all["fs1"];
792 } else if (document.getElementById) {
793 window.parent.document.getElementById("fs1");
799 if ($location_of_bar == 'right') {
800 $xtra .= ' colPat=/^\*,(\d+)$/;';
802 $xtra .= ' colPat=/^(\d+),.*$/;';
807 old_col = masterf.cols;
808 colPat.exec(old_col);
811 new_col_width = parseInt(RegExp.$1) + 25;
814 if (parseInt(RegExp.$1) > 35) {
815 new_col_width = parseInt(RegExp.$1) - 25;
818 masterf.cols = calc_col(new_col_width);
827 /* style definitions */
831 <style type="text/css">
834 margin: 0px 0px 0px 0px;
835 padding: 5px 5px 5px 5px;
840 border-color: $color[9];
841 background:$color[0];
854 text-decoration: none;
855 background-color: $color[0];
860 background-color: $color[9];
882 border-left-width:0.1em;
883 border-left-color:$color[9];
884 border-bottom: solid;
885 border-bottom-width:0.1em;
886 border-bottom-color:$color[9];
898 border-color:$color[9];
899 background: $color[0];
910 displayHtmlHeader( 'SquirrelMail', $xtra );
912 /* If requested and not yet complete, attempt to autocreate folders. */
913 if ($auto_create_special && !isset($auto_create_done)) {
914 $autocreate = array($sent_folder, $trash_folder, $draft_folder);
915 foreach( $autocreate as $folder ) {
916 if (($folder != '') && ($folder != 'none')) {
917 if ( !sqimap_mailbox_exists($imapConnection, $folder)) {
918 sqimap_mailbox_create($imapConnection, $folder, '');
919 } else if (!sqimap_mailbox_is_subscribed($imapConnection, $folder)) {
920 sqimap_subscribe($imapConnection, $folder);
925 /* Let the world know that autocreation is complete! Hurrah! */
926 $auto_create_done = TRUE;
927 sqsession_register($auto_create_done, 'auto_create_done');
932 ' onload="preload(\'../images/minus.png\',\'../images/plus.png\')"' .
933 " bgcolor=\"$color[3]\" text=\"$color[6]\" link=\"$color[6]\" vlink=\"$color[6]\" alink=\"$color[6]\">\n";
935 echo "\n<body bgcolor=\"$color[3]\" text=\"$color[6]\" link=\"$color[6]\" vlink=\"$color[6]\" alink=\"$color[6]\">\n";
937 do_hook('left_main_before');
938 if ($advanced_tree) {
939 /* nice future feature, needs layout !! volunteers? */
940 $right_pos = $left_size - 20;
941 /* 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>';
942 echo '<div ID="showf" style="width=20;font-size:12;display:none;"><a href="javascript:hideframe(false)"><b>>></b></a></div>';
943 echo '<div ID="incrf" style="width=20;font-size:12"><a href="javascript:resizeframe(true)"><b>></b></a></div>';
944 echo '<div ID="decrf" style="width=20;font-size:12"><a href="javascript:resizeframe(false)"><b><</b></a></div></div>';
945 echo '<div ID="leftframe"><br /><br />';*/
948 echo "\n\n" . html_tag( 'table', '', 'left', '', 'border="0" cellspacing="0" cellpadding="0" width="99%"' ) .
950 html_tag( 'td', '', 'left' ) .
951 '<center><font size="4"><b>'. _("Folders") . "</b><br /></font>\n\n";
953 if ($date_format != 6) {
954 /* First, display the clock. */
955 if ($hour_format == 1) {
957 if ($date_format == 4) {
961 if ($date_format == 4) {
968 switch( $date_format ) {
970 $clk = date('m/d/y '.$hr, time());
973 $clk = date('d/m/y '.$hr, time());
977 $clk = date($hr, time());
980 $clk = getDayAbrv( date( 'w', time() ) ) . date( ', ' . $hr, time() );
982 $clk = str_replace(' ',' ',$clk);
984 echo '<center><small>' . str_replace(' ',' ',_("Last Refresh")) .
985 ": $clk</small></center>";
988 /* Next, display the refresh button. */
989 echo '<small>(<a href="../src/left_main.php" target="left">'.
990 _("refresh folder list") . '</a>)</small></center><br />';
992 /* Lastly, display the folder list. */
993 if ( $collapse_folders ) {
994 /* If directed, collapse or uncollapse a folder. */
996 setPref($data_dir, $username, 'collapse_folder_' . $fold, SM_BOX_COLLAPSED
);
997 } else if (isset($unfold)) {
998 setPref($data_dir, $username, 'collapse_folder_' . $unfold, SM_BOX_UNCOLLAPSED
);
1002 /* Get unseen/total display prefs */
1003 $unseen_type = getPref( $data_dir , $username , 'unseen_type' );
1004 $unseen_notify = getPref( $data_dir , $username , 'unseen_notify' );
1006 if (!isset($unseen_type) ||
empty($unseen_type)) {
1007 if (isset($default_unseen_type) && !empty($default_unseen_type)) {
1008 $unseen_type = $default_unseen_type;
1014 if (!isset($unseen_notify) ||
empty($unseen_notify)) {
1015 if (isset($default_unseen_notify) && !empty($default_unseen_notify)) {
1016 $unseen_notify = $default_unseen_notify;
1022 if ($oldway) { /* normal behaviour SM */
1024 $boxes = sqimap_mailbox_list($imapConnection);
1025 /* Prepare do do out collapsedness and visibility computation. */
1027 $boxcount = count($boxes);
1029 /* Compute the collapsedness and visibility of each box. */
1031 while ($curbox < $boxcount) {
1032 $boxes[$curbox]['visible'] = TRUE;
1033 compute_folder_children($curbox, $boxcount);
1036 for ($i = 0; $i < count($boxes); $i++
) {
1037 if ( $boxes[$i]['visible'] ) {
1038 $mailbox = $boxes[$i]['formatted'];
1039 $mblevel = substr_count($boxes[$i]['unformatted'], $delimiter) +
1;
1041 /* Create the prefix for the folder name and link. */
1042 $prefix = str_repeat(' ',$mblevel);
1043 if (isset($collapse_folders) && $collapse_folders && $boxes[$i]['parent']) {
1044 $prefix = str_replace(' ',' ',substr($prefix,0,strlen($prefix)-2)).
1045 create_collapse_link($i) . ' ';
1047 $prefix = str_replace(' ',' ',$prefix);
1049 $line = "<nobr><tt>$prefix</tt>";
1051 /* Add the folder name and link. */
1052 if (! isset($color[15])) {
1053 $color[15] = $color[6];
1056 if (in_array('noselect', $boxes[$i]['flags'])) {
1057 if( isSpecialMailbox( $boxes[$i]['unformatted']) ) {
1058 $line .= "<font color=\"$color[11]\">";
1060 $line .= "<font color=\"$color[15]\">";
1062 if (ereg("^( *)([^ ]*)", $mailbox, $regs)) {
1063 $mailbox = str_replace(' ','',$mailbox);
1064 $line .= str_replace(' ', ' ', $mailbox);
1068 $line .= formatMailboxName($imapConnection, $boxes[$i]);
1071 /* Put the final touches on our folder line. */
1072 $line .= "</nobr><br>\n";
1074 /* Output the line for this folder. */
1078 } else { /* expiremental code */
1079 $boxes = sqimap_mailbox_tree($imapConnection);
1080 if (isset($advanced_tree) && $advanced_tree) {
1081 echo '<form name="collapse" action="left_main.php" method="post" ' .
1082 'enctype="multipart/form-data"'."\n";
1084 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 />';
1085 echo '<div id="mailboxes" class="mailboxes">'."\n\n";
1086 sqgetGlobalVar('mbx', $mbx, SQ_POST
);
1087 if (!isset($mbx)) $mbx=NULL;
1088 ListAdvancedBoxes($boxes, $mbx);
1091 echo '</form>'."\n";
1093 //sqimap_get_status_mbx_tree($imap_stream,$boxes)
1096 } /* if ($oldway) else ... */
1097 do_hook('left_main_after');
1098 sqimap_logout($imapConnection);
1100 echo '</td></tr></table>' . "\n".
1101 "</div></body></html>\n";