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 if (!defined('SM_PATH'))
18 define('SM_PATH','../');
21 /* SquirrelMail required files. */
22 require_once(SM_PATH
. 'include/validate.php');
23 require_once(SM_PATH
. 'functions/imap.php');
24 require_once(SM_PATH
. 'functions/plugin.php');
25 require_once(SM_PATH
. 'functions/page_header.php');
26 require_once(SM_PATH
. 'functions/html.php');
27 require_once(SM_PATH
. 'functions/date.php');
29 /* These constants are used for folder stuff. */
30 define('SM_BOX_UNCOLLAPSED', 0);
31 define('SM_BOX_COLLAPSED', 1);
33 /* --------------------- FUNCTIONS ------------------------- */
35 function formatMailboxName($imapConnection, $box_array) {
37 global $folder_prefix, $trash_folder, $sent_folder,
38 $color, $move_to_sent, $move_to_trash,
39 $unseen_notify, $unseen_type, $collapse_folders,
40 $draft_folder, $save_as_draft,
41 $use_special_folder_color, $use_frames;
42 $real_box = $box_array['unformatted'];
43 $mailbox = str_replace(' ','',$box_array['formatted']);
44 $mailboxURL = urlencode($real_box);
49 /* Strip down the mailbox name. */
50 if (ereg("^( *)([^ ]*)$", $mailbox, $regs)) {
54 $status = array('','');
55 if (($unseen_notify == 2 && $real_box == 'INBOX') ||
56 $unseen_notify == 3) {
57 $tmp_status = create_unseen_string($real_box, $box_array, $imapConnection, $unseen_type );
58 if ($status !== false) {
59 $status = $tmp_status;
62 list($unseen_string, $unseen) = $status;
63 $special_color = ($use_special_folder_color && isSpecialMailbox($real_box));
65 /* Start off with a blank line. */
68 /* If there are unseen message, bold the line. */
69 if ($unseen > 0) { $line .= '<B>'; }
71 /* Create the link for this folder. */
72 if ($status !== false) {
73 $line .= '<a href="' . SM_PATH
. 'src/right_main.php?PG_SHOWALL=0&sort=0&startMessage=1&mailbox='.
74 $mailboxURL.'" TARGET="' . $target . '" STYLE="text-decoration:none">';
77 $line .= "<font color=\"$color[11]\">";
79 if ( $mailbox == 'INBOX' ) {
82 $line .= str_replace(' ',' ',$mailbox);
84 if ($special_color == TRUE)
86 if ($status !== false) {
90 /* If there are unseen message, close bolding. */
91 if ($unseen > 0) { $line .= "</B>"; }
93 /* Print unseen information. */
94 if ($unseen_string != '') {
95 $line .= " <SMALL>$unseen_string</SMALL>";
98 /* If it's the trash folder, show a purge link when needed */
99 if (($move_to_trash) && ($real_box == $trash_folder)) {
100 if (! isset($numMessages)) {
101 $numMessages = sqimap_get_num_messages($imapConnection, $real_box);
104 if (($numMessages > 0) or ($box_array['parent'] == 1)) {
105 $urlMailbox = urlencode($real_box);
106 $line .= "\n<small>\n" .
107 " (<A HREF=\"" . SM_PATH
. "src/empty_trash.php\" style=\"text-decoration:none\">"._("purge")."</A>)" .
110 $line .= concat_hook_function('left_main_after_each_folder',
111 array(isset($numMessages) ?
$numMessages : '',$real_box,$imapConnection));
115 /* Return the final product. */
120 * Recursive function that computes the collapsed status and parent
121 * (or not parent) status of this box, and the visiblity and collapsed
122 * status and parent (or not parent) status for all children boxes.
124 function compute_folder_children(&$parbox, $boxcount) {
125 global $boxes, $data_dir, $username, $collapse_folders;
126 $nextbox = $parbox +
1;
128 /* Retreive the name for the parent box. */
129 $parbox_name = $boxes[$parbox]['unformatted'];
131 /* 'Initialize' this parent box to childless. */
132 $boxes[$parbox]['parent'] = FALSE;
134 /* Compute the collapse status for this box. */
135 if( isset($collapse_folders) && $collapse_folders ) {
136 $collapse = getPref($data_dir, $username, 'collapse_folder_' . $parbox_name);
137 $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED
: $collapse);
139 $collapse = SM_BOX_UNCOLLAPSED
;
141 $boxes[$parbox]['collapse'] = $collapse;
143 /* Otherwise, get the name of the next box. */
144 if (isset($boxes[$nextbox]['unformatted'])) {
145 $nextbox_name = $boxes[$nextbox]['unformatted'];
150 /* Compute any children boxes for this box. */
151 while (($nextbox < $boxcount) &&
152 (is_parent_box($boxes[$nextbox]['unformatted'], $parbox_name))) {
154 /* Note that this 'parent' box has at least one child. */
155 $boxes[$parbox]['parent'] = TRUE;
157 /* Compute the visiblity of this box. */
158 $boxes[$nextbox]['visible'] = ($boxes[$parbox]['visible'] &&
159 ($boxes[$parbox]['collapse'] != SM_BOX_COLLAPSED
));
161 /* Compute the visibility of any child boxes. */
162 compute_folder_children($nextbox, $boxcount);
165 /* Set the parent box to the current next box. */
170 * Create the link for a parent folder that will allow that
171 * parent folder to either be collapsed or expaned, as is
172 * currently appropriate.
174 function create_collapse_link($boxnum) {
175 global $boxes, $imapConnection, $unseen_notify, $color;
176 $mailbox = urlencode($boxes[$boxnum]['unformatted']);
179 /* Create the link for this collapse link. */
181 $link = '<a target="left" style="text-decoration:none" ' .
182 'href="' . SM_PATH
. 'src/left_main.php?';
184 if ($boxes[$boxnum]['collapse'] == SM_BOX_COLLAPSED
) {
185 $link .= "unfold=$mailbox\">+";
187 $link .= "fold=$mailbox\">-";
191 $hooklink = do_hook_function('create_collapse_link',$link);
195 /* Return the finished product. */
200 * create_unseen_string:
202 * Create unseen and total message count for both this folder and
205 * @param string $boxName name of the current mailbox
206 * @param array $boxArray array for the current mailbox
207 * @param $imapConnection current imap connection in use
208 * @return array unseen message string (for display), unseen message count
210 function create_unseen_string($boxName, $boxArray, $imapConnection, $unseen_type) {
211 global $boxes, $unseen_type, $color, $unseen_cum;
213 /* Initialize the return value. */
214 $result = array(0,0);
216 /* Initialize the counts for this folder. */
218 $boxMessageCount = 0;
219 $totalUnseenCount = 0;
220 $totalMessageCount = 0;
222 /* Collect the counts for this box alone. */
223 $status = sqimap_status_messages($imapConnection, $boxName);
224 $boxUnseenCount = $status['UNSEEN'];
225 if ($boxUnseenCount === false) {
228 if ($unseen_type == 2) {
229 $boxMessageCount = $status['MESSAGES'];
232 /* Initialize the total counts. */
234 if ($boxArray['collapse'] == SM_BOX_COLLAPSED
&& $unseen_cum) {
235 /* Collect the counts for this boxes subfolders. */
236 $curBoxLength = strlen($boxName);
237 $boxCount = count($boxes);
239 for ($i = 0; $i < $boxCount; ++
$i) {
240 /* Initialize the counts for this subfolder. */
242 $subMessageCount = 0;
244 /* Collect the counts for this subfolder. */
245 if (($boxName != $boxes[$i]['unformatted'])
246 && (substr($boxes[$i]['unformatted'], 0, $curBoxLength) == $boxName)
247 && !in_array('noselect', $boxes[$i]['flags'])) {
248 $status = sqimap_status_messages($imapConnection, $boxes[$i]['unformatted']);
249 $subUnseenCount = $status['UNSEEN'];
250 if ($unseen_type == 2) {
251 $subMessageCount = $status['MESSAGES'];;
253 /* Add the counts for this subfolder to the total. */
254 $totalUnseenCount +
= $subUnseenCount;
255 $totalMessageCount +
= $subMessageCount;
259 /* Add the counts for all subfolders to that of the box. */
260 $boxUnseenCount +
= $totalUnseenCount;
261 $boxMessageCount +
= $totalMessageCount;
264 /* And create the magic unseen count string. */
265 /* Really a lot more then just the unseen count. */
266 if (($unseen_type == 1) && ($boxUnseenCount > 0)) {
267 $result[0] = "($boxUnseenCount)";
268 } else if ($unseen_type == 2) {
269 $result[0] = "($boxUnseenCount/$boxMessageCount)";
270 $result[0] = "<font color=\"$color[11]\">$result[0]</font>";
273 /* Set the unseen count to return to the outside world. */
274 $result[1] = $boxUnseenCount;
276 /* Return our happy result. */
281 * This simple function checks if a box is another box's parent.
283 function is_parent_box($curbox_name, $parbox_name) {
286 /* Extract the name of the parent of the current box. */
287 $curparts = explode($delimiter, $curbox_name);
288 $curname = array_pop($curparts);
289 $actual_parname = implode($delimiter, $curparts);
290 $actual_parname = substr($actual_parname,0,strlen($parbox_name));
292 /* Compare the actual with the given parent name. */
293 return ($parbox_name == $actual_parname);
296 function ListBoxes ($boxes, $j=0 ) {
297 global $data_dir, $username, $startmessage, $color, $unseen_notify, $unseen_type,
298 $move_to_trash, $trash_folder, $collapse_folders, $imapConnection, $use_frames;
305 if (isset($boxes) && !empty($boxes)) {
306 $mailbox = $boxes->mailboxname_full
;
308 $leader .= str_repeat(' ',$j);
309 $mailboxURL = urlencode($mailbox);
311 /* get unseen/total messages information */
312 /* Only need to display info when option is set */
313 if (isset($unseen_notify) && ($unseen_notify > 1)) {
315 if ($boxes->unseen
!== false) {
316 $unseen = $boxes->unseen
;
322 Should only display unseen info if the folder is inbox
323 or you set the option for all folders
326 if ((strtolower($mailbox) == 'inbox') ||
($unseen_notify == 3)) {
327 $unseen_string = $unseen;
330 /* If users requests, display message count too */
331 if (isset($unseen_type) && ($unseen_type == 2)) {
332 $numMessages = $boxes->total
;
333 $unseen_string .= '/' . $numMessages;
336 $unseen_string = "<font color=\"$color[11]\">($unseen_string)</font>";
339 Finally allow the script to display the values by setting a boolean.
340 This can only occur if the unseen count is great than 0 (if you have
341 unseen count only), or you have the message count too.
343 if (($unseen > 0) ||
(isset($unseen_type) && ($unseen_type ==2))) {
344 $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="' . SM_PATH
. 'src/left_main.php?';
357 $link = '<a style="text-decoration:none" ' .'href="' . SM_PATH
. 'src/right_main.php?';
359 $link .= "unfold=$mailboxURL\">$leader+ </tt>";
361 $link .= "fold=$mailboxURL\">$leader- </tt>";
366 $pre.= $leader . ' </tt>';
374 /* If there are unseen message, bold the line. */
375 if (($move_to_trash) && ($mailbox == $trash_folder)) {
376 if (! isset($boxes->total
)) {
377 $boxes->total
= sqimap_status_messages($imapConnection, $mailbox);
382 $pre .= "<a href=\"" . SM_PATH
. "src/right_main.php?PG_SHOWALL=0&sort=0;startMessage=1&mailbox=$mailboxURL\" target=\"$target\" style=\"text-decoration:none\">";
387 if ($boxes->total
> 0) {
391 $pre .= "<a href=\"" . SM_PATH
. "src/right_main.php?PG_SHOWALL=0&sort=0;startMessage=1&mailbox=$mailboxURL\" target=\"$target\" style=\"text-decoration:none\">";
395 /* Print unseen information. */
396 if (isset($unseen_found) && $unseen_found) {
397 $end .= " <small>$unseen_string</small>";
399 $end .= "\n<small>\n" .
400 " (<a href=\"" . SM_PATH
. "src/empty_trash.php\" style=\"text-decoration:none\">"._("purge")."</a>)" .
404 if (!$boxes->is_noselect
) {
408 $pre .= "<a href=\"" . SM_PATH
. "src/right_main.php?PG_SHOWALL=0&sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"$target\" style=\"text-decoration:none\">";
414 /* Print unseen information. */
415 if (isset($unseen_found) && $unseen_found) {
416 $end .= " <small>$unseen_string</small>";
423 if ($boxes->is_special
) {
424 $font = "<font color=\"$color[11]\">";
425 $fontend = "</font>";
429 if (!$boxes->is_root
) {
430 echo "" . $pre .$font. $boxes->mailboxname_sub
.$fontend . $end. '<br />' . "\n";
434 if (!$collapse ||
$boxes->is_root
) {
435 for ($i = 0; $i <count($boxes->mbxs
); $i++
) {
436 listBoxes($boxes->mbxs
[$i],$j);
442 function ListAdvancedBoxes ($boxes, $mbx, $j='ID.0000' ) {
443 global $data_dir, $username, $startmessage, $color, $unseen_notify, $unseen_type,
444 $move_to_trash, $trash_folder, $collapse_folders, $use_frames;
454 /* use_folder_images only works if the images exist in ../images */
455 $use_folder_images = true;
460 $unseen_found = false;
463 $mailbox = $boxes->mailboxname_full
;
464 $mailboxURL = urlencode($mailbox);
466 /* Only need to display info when option is set */
467 if (isset($unseen_notify) && ($unseen_notify > 1) && (($boxes->unseen
!== false) ||
($boxes->total
!== false))) {
469 if ($boxes->unseen
!== false)
470 $unseen = $boxes->unseen
;
473 Should only display unseen info if the folder is inbox
474 or you set the option for all folders
477 if ((strtolower($mailbox) == 'inbox') ||
($unseen_notify == 3)) {
478 $unseen_string = $unseen;
480 /* If users requests, display message count too */
481 if (isset($unseen_type) && ($unseen_type == 2) && ($boxes->total
!== false))
482 $unseen_string .= '/' . $boxes->total
;
484 $unseen_string = "<font color=\"$color[11]\">($unseen_string)</font>";
487 Finally allow the script to display the values by setting a boolean.
488 This can only occur if the unseen count is great than 0 (if you have
489 unseen count only), or you have the message count too.
491 if (($unseen > 0) ||
(isset($unseen_type) && ($unseen_type ==2))) {
492 $unseen_found = true;
499 /* If there are unseen message, bold the line. */
500 if ($unseen > 0) { $pre .= '<b>'; }
502 /* color special boxes */
503 if ($boxes->is_special
) {
504 $pre .= "<font color=\"$color[11]\">";
508 /* If there are unseen message, close bolding. */
509 if ($unseen > 0) { $end .= '</b>'; }
511 /* Print unseen information. */
512 if (isset($unseen_found) && $unseen_found) {
513 $end .= " $unseen_string";
516 if (($move_to_trash) && ($mailbox == $trash_folder)) {
517 if (! isset($numMessages)) {
518 $numMessages = $boxes->total
;
520 $pre = "<a class=\"mbx_link\" href=\"" . SM_PATH
. "src/right_main.php?PG_SHOWALL=0&sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"$target\">" . $pre;
522 if ($numMessages > 0) {
523 $urlMailbox = urlencode($mailbox);
524 $end .= "\n<small>\n" .
525 " (<a class=\"mbx_link\" href=\"" . SM_PATH
. "src/empty_trash.php\">"._("purge")."</a>)" .
529 if (!$boxes->is_noselect
) { /* \Noselect boxes can't be selected */
530 $pre = "<a class=\"mbx_link\" href=\"" . SM_PATH
. "src/right_main.php?PG_SHOWALL=0&sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"$target\">" . $pre;
535 if (!$boxes->is_root
) {
536 if ($use_folder_images) {
537 if ($boxes->is_inbox
) {
538 $folder_img = '../images/inbox.png';
539 } else if ($boxes->is_sent
) {
540 $folder_img = '../images/senti.png';
541 } else if ($boxes->is_trash
) {
542 $folder_img = '../images/delitem.png';
543 } else if ($boxes->is_draft
) {
544 $folder_img = '../images/draft.png';
545 } else if ($boxes->is_noinferiors
) {
546 $folder_img = '../images/folder_noinf.png';
547 } else $folder_img = '../images/folder.png';
548 $folder_img = ' <img src="'.$folder_img.'" height="15" valign="center" /> ';
549 } else $folder_img = '';
550 if (!isset($boxes->mbxs
[0])) {
551 echo ' ' . html_tag( 'div',
552 '<tt>'. $pre . $folder_img . '</tt>'. $boxes->mailboxname_sub
. $end,
553 'left', '', 'class="mbx_sub" id="' .$j. '"' ) . "\n";
556 /* get collapse information */
557 if ($collapse_folders) {
558 $form_entry = $j.'F';
559 if (isset($mbx) && isset($mbx[$form_entry])) {
560 $collapse = $mbx[$form_entry];
561 setPref($data_dir, $username, 'collapse_folder_'.$boxes->mailboxname_full
, $collapse ? SM_BOX_COLLAPSED
: SM_BOX_UNCOLLAPSED
);
564 $collapse = getPref($data_dir, $username, 'collapse_folder_' . $mailbox);
565 $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED
: $collapse);
567 $img_src = ($collapse ?
'../images/plus.png' : '../images/minus.png');
568 $collapse_link = '<a href="javascript:void(0)">'." <img src=\"$img_src\" border=\"1\" id=$j onclick=\"hidechilds(this)\" style=\"cursor:hand\" /></a>";
572 echo ' ' . html_tag( 'div',
573 $collapse_link . $pre . $folder_img . ' '. $boxes->mailboxname_sub
. $end ,
574 'left', '', 'class="mbx_par" id="' .$j. 'P"' ) . "\n";
575 echo ' <input type="hidden" name="mbx['.$j. 'F]" value="'.$collapse.'" id="mbx['.$j.'F]" />'."\n";
579 $visible = ($collapse ?
' style="display:none"' : ' style="display:block"');
580 if (isset($boxes->mbxs
[0]) && !$boxes->is_root
) /* mailbox contains childs */
581 echo html_tag( 'div', '', 'left', '', 'class="par_area" id='.$j.'.0000 '. $visible ) . "\n";
585 for ($i = 0; $i <count($boxes->mbxs
); $i++
) {
587 ListAdvancedBoxes($boxes->mbxs
[$i],$mbx,$j);
589 if (isset($boxes->mbxs
[0]) && !$boxes->is_root
)
590 echo '</div>'."\n\n";
596 /* -------------------- MAIN ------------------------ */
599 sqgetGlobalVar('username', $username, SQ_SESSION
);
600 sqgetGlobalVar('key', $key, SQ_COOKIE
);
601 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION
);
602 sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION
);
604 sqgetGlobalVar('fold', $fold, SQ_GET
);
605 sqgetGlobalVar('unfold', $unfold, SQ_GET
);
609 // open a connection on the imap port (143)
612 if (!$imapConnection)
613 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 10); // the 10 is to hide the output
616 * Using stristr since older preferences may contain "None" and "none".
618 if (isset($left_refresh) && ($left_refresh != '') &&
619 !stristr($left_refresh, 'none')){
620 $xtra = "\n<meta http-equiv=\"Expires\" content=\"Thu, 01 Dec 1994 16:00:00 GMT\" />\n" .
621 "<meta http-equiv=\"Pragma\" content=\"no-cache\" />\n".
622 "<meta http-equiv=\"REFRESH\" content=\"$left_refresh;URL=" . SM_PATH
. "src/left_main.php\" />\n";
628 * $advanced_tree and $oldway are boolean vars which are default set to default
630 * Setting $oldway to false causes left_main.php to use the new experimental
631 * way of getting the mailbox-tree.
632 * Setting $advanced tree to true causes SM to display a experimental
633 * mailbox-tree with dhtml behaviour.
634 * It only works on browsers which supports css and javascript. The used
635 * javascript is experimental and doesn't support all browsers.
636 * It has been tested on IE6 an Konquerer 3.0.0-2.
637 * It is now tested and working on: (please test and update this list)
638 * Windows: IE 5.5 SP2, IE 6 SP1, Gecko based (Mozilla, Firebird) and Opera7
641 * In the function ListAdvancedBoxes there is another var $use_folder_images.
642 * setting this to true is only usefull if the images exists in ../images.
644 * Feel free to experiment with the code and report bugs and enhancements
645 * to marc@its-projects.nl
648 /* set this to true if you want to see a nicer mailboxtree */
649 if (! isset($advanced_tree) ||
$advanced_tree=="" ) {
650 $advanced_tree=false; }
651 /* default SM behaviour */
652 if (! isset($oldway) ||
$oldway=="" ) {
655 if ($advanced_tree) {
657 <script language="Javascript" TYPE="text/javascript">
662 if (document.images) {
663 var treeImages = new Array;
664 var arguments = preload.arguments;
665 for (var i = 0; i<arguments.length; i++) {
666 treeImages[i] = new Image();
667 treeImages[i].src = arguments[i];
676 function fTreeTimeout() {
677 if (vTreeDiv.readyState == "complete")
678 vTreeImg.src = vTreeSrc;
680 setTimeout("fTreeTimeout()", 100);
683 function hidechilds(img) {
684 id = img.id + ".0000";
685 form_id = "mbx[" + img.id +"F]";
686 if (document.all) { //IE, Opera7
687 div = document.all[id];
689 if (div.style.display == "none") {
690 vTreeSrc = "../images/minus.png";
695 vTreeSrc = "../images/plus.png";
701 if (typeof vTreeDiv.readyState != "undefined") //IE
702 setTimeout("fTreeTimeout()",100);
704 vTreeImg.src = vTreeSrc;
705 div.style.display = style;
706 document.all[form_id].value = value;
709 else if (document.getElementById) { //Gecko
710 div = document.getElementById(id);
712 if (div.style.display == "none") {
713 src = "../images/minus.png";
718 src = "../images/plus.png";
722 div.style.display = style;
724 document.getElementById(form_id).value = value;
729 function buttonover(el,on) {
731 // el.style.borderColor="$color[9]";}
732 el.style.background="$color[0]";}
734 el.style.background="$color[9]";}
737 function buttonclick(el,on) {
739 el.style.border="groove";}
741 el.style.border="ridge";}
744 function hideframe(hide) {
747 $xtra .= " left_size = \"$left_size\";\n";
750 masterf = window.parent.document.all["fs1"];
751 leftf = window.parent.document.all["left"];
752 leftcontent = document.all["leftframe"];
753 leftbutton = document.all["showf"];
754 } else if (document.getElementById) {
755 masterf = window.parent.document.getElementById("fs1");
756 leftf = window.parent.document.getElementById("left");
757 leftcontent = document.getElementById("leftframe");
758 leftbutton = document.getElementById("showf");
763 new_col = calc_col("20");
764 masterf.cols = new_col;
765 document.body.scrollLeft=0;
766 document.body.style.overflow='hidden';
767 leftcontent.style.display = 'none';
768 leftbutton.style.display='block';
770 masterf.cols = calc_col(left_size);
771 document.body.style.overflow='';
772 leftbutton.style.display='none';
773 leftcontent.style.display='block';
778 function calc_col(c_w) {
781 if ($location_of_bar == 'right') {
782 $xtra .= ' right=true;';
784 $xtra .= ' right=false;';
796 function resizeframe(direction) {
798 masterf = window.parent.document.all["fs1"];
799 } else if (document.getElementById) {
800 window.parent.document.getElementById("fs1");
806 if ($location_of_bar == 'right') {
807 $xtra .= ' colPat=/^\*,(\d+)$/;';
809 $xtra .= ' colPat=/^(\d+),.*$/;';
814 old_col = masterf.cols;
815 colPat.exec(old_col);
818 new_col_width = parseInt(RegExp.$1) + 25;
821 if (parseInt(RegExp.$1) > 35) {
822 new_col_width = parseInt(RegExp.$1) - 25;
825 masterf.cols = calc_col(new_col_width);
834 /* style definitions */
838 <style type="text/css">
841 margin: 0px 0px 0px 0px;
842 padding: 5px 5px 5px 5px;
847 border-color: $color[9];
848 background:$color[0];
861 text-decoration: none;
862 background-color: $color[0];
867 background-color: $color[9];
889 border-left-width:0.1em;
890 border-left-color:$color[9];
891 border-bottom: solid;
892 border-bottom-width:0.1em;
893 border-bottom-color:$color[9];
905 border-color:$color[9];
906 background: $color[0];
919 displayHtmlHeader( 'SquirrelMail', $xtra );
922 /* If requested and not yet complete, attempt to autocreate folders. */
923 if ($auto_create_special && !isset($auto_create_done)) {
924 $autocreate = array($sent_folder, $trash_folder, $draft_folder);
925 foreach( $autocreate as $folder ) {
926 if (($folder != '') && ($folder != 'none')) {
927 if ( !sqimap_mailbox_exists($imapConnection, $folder)) {
928 sqimap_mailbox_create($imapConnection, $folder, '');
929 } else if (!sqimap_mailbox_is_subscribed($imapConnection, $folder)) {
930 sqimap_subscribe($imapConnection, $folder);
935 /* Let the world know that autocreation is complete! Hurrah! */
936 $auto_create_done = TRUE;
937 sqsession_register($auto_create_done, 'auto_create_done');
942 ' onload="preload(\'../images/minus.png\',\'../images/plus.png\')"' .
943 " bgcolor=\"$color[3]\" text=\"$color[6]\" link=\"$color[6]\" vlink=\"$color[6]\" alink=\"$color[6]\">\n";
945 echo "\n<body bgcolor=\"$color[3]\" text=\"$color[6]\" link=\"$color[6]\" vlink=\"$color[6]\" alink=\"$color[6]\">\n";
947 do_hook('left_main_before');
948 if ($advanced_tree) {
949 /* nice future feature, needs layout !! volunteers? */
950 $right_pos = $left_size - 20;
951 /* 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>';
952 echo '<div ID="showf" style="width=20;font-size:12;display:none;"><a href="javascript:hideframe(false)"><b>>></b></a></div>';
953 echo '<div ID="incrf" style="width=20;font-size:12"><a href="javascript:resizeframe(true)"><b>></b></a></div>';
954 echo '<div ID="decrf" style="width=20;font-size:12"><a href="javascript:resizeframe(false)"><b><</b></a></div></div>';
955 echo '<div ID="leftframe"><br /><br />';*/
958 echo "\n\n" . html_tag( 'table', '', 'left', '', 'border="0" cellspacing="0" cellpadding="0" width="99%"' ) .
960 html_tag( 'td', '', 'left' );
961 if ($use_frames != 1)
962 '<center><font size="4"><b>'. _("Folders") . "</b><br /></font>\n\n";
964 if ($date_format != 6) {
965 /* First, display the clock. */
966 if ($hour_format == 1) {
968 if ($date_format == 4) {
972 if ($date_format == 4) {
979 switch( $date_format ) {
981 $clk = date('m/d/y '.$hr, time());
984 $clk = date('d/m/y '.$hr, time());
988 $clk = date($hr, time());
991 $clk = getDayAbrv( date( 'w', time() ) ) . date( ', ' . $hr, time() );
993 $clk = str_replace(' ',' ',$clk);
995 echo '<center><small>' . str_replace(' ',' ',_("Last Refresh")) .
996 ": $clk</small></center>";
999 /* Next, display the refresh button. */
1001 echo '<small>(<a href="' . SM_PATH
. 'src/left_main.php" target="left">'.
1002 _("refresh folder list") . '</a>)</small></center><br />';
1004 // echo '<small>(<a href="' . SM_PATH . 'src/left_main.php">'.
1005 // _("refresh folder list") . '</a>)</small></center><br />';
1006 echo '</center><br />';
1007 $collapse_folders = 0;
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="' . SM_PATH
. 'src/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 ... */
1117 do_hook('left_main_after');
1118 if ($location_of_bar == right
&& !$use_frames)
1119 sqimap_logout($imapConnection);
1121 echo '<br></td></tr></table>' . "\n";
1123 echo "</div></body></html>\n";