027fa990946052e95dfcd223d3c42c286b0bc4d3
6 * Copyright (c) 1999-2005 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 $trash_folder, $color, $move_to_trash,
39 $unseen_notify, $unseen_type, $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&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(array(' ','<','>'),array(' ','<','>'),$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">'._("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, $unseen_notify, $color, $use_icons, $icon_theme;
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 if ($use_icons && $icon_theme != 'none') {
181 $link .= "unfold=$mailbox\"><img src=\"" . SM_PATH
. 'images/plus.png" border="0" height="7" width="7" />';
183 $link .= "unfold=$mailbox\">+";
186 if ($use_icons && $icon_theme != 'none') {
187 $link .= "fold=$mailbox\"><img src=\"" . SM_PATH
. 'images/minus.png" border="0" height="7" width="7" />';
189 $link .= "fold=$mailbox\">-";
194 /* Return the finished product. */
199 * create_unseen_string:
201 * Create unseen and total message count for both this folder and
204 * @param string $boxName name of the current mailbox
205 * @param array $boxArray array for the current mailbox
206 * @param $imapConnection current imap connection in use
207 * @return array unseen message string (for display), unseen message count
209 function create_unseen_string($boxName, $boxArray, $imapConnection, $unseen_type) {
210 global $boxes, $color, $unseen_cum;
212 /* Initialize the return value. */
213 $result = array(0,0);
215 /* Initialize the counts for this folder. */
217 $boxMessageCount = 0;
218 $totalUnseenCount = 0;
219 $totalMessageCount = 0;
221 /* Collect the counts for this box alone. */
222 $status = sqimap_status_messages($imapConnection, $boxName);
223 $boxUnseenCount = $status['UNSEEN'];
224 if ($boxUnseenCount === false) {
227 if ($unseen_type == 2) {
228 $boxMessageCount = $status['MESSAGES'];
231 /* Initialize the total counts. */
233 if ($boxArray['collapse'] == SM_BOX_COLLAPSED
&& $unseen_cum) {
234 /* Collect the counts for this boxes subfolders. */
235 $curBoxLength = strlen($boxName);
236 $boxCount = count($boxes);
238 for ($i = 0; $i < $boxCount; ++
$i) {
239 /* Initialize the counts for this subfolder. */
241 $subMessageCount = 0;
243 /* Collect the counts for this subfolder. */
244 if (($boxName != $boxes[$i]['unformatted'])
245 && (substr($boxes[$i]['unformatted'], 0, $curBoxLength) == $boxName)
246 && !in_array('noselect', $boxes[$i]['flags'])) {
247 $status = sqimap_status_messages($imapConnection, $boxes[$i]['unformatted']);
248 $subUnseenCount = $status['UNSEEN'];
249 if ($unseen_type == 2) {
250 $subMessageCount = $status['MESSAGES'];;
252 /* Add the counts for this subfolder to the total. */
253 $totalUnseenCount +
= $subUnseenCount;
254 $totalMessageCount +
= $subMessageCount;
258 /* Add the counts for all subfolders to that of the box. */
259 $boxUnseenCount +
= $totalUnseenCount;
260 $boxMessageCount +
= $totalMessageCount;
263 /* And create the magic unseen count string. */
264 /* Really a lot more then just the unseen count. */
265 if (($unseen_type == 1) && ($boxUnseenCount > 0)) {
266 $result[0] = "($boxUnseenCount)";
267 } else if ($unseen_type == 2) {
268 $result[0] = "($boxUnseenCount/$boxMessageCount)";
269 $result[0] = "<font color=\"$color[11]\">$result[0]</font>";
272 /* Set the unseen count to return to the outside world. */
273 $result[1] = $boxUnseenCount;
275 /* Return our happy result. */
280 * This simple function checks if a box is another box's parent.
282 function is_parent_box($curbox_name, $parbox_name) {
285 /* Extract the name of the parent of the current box. */
286 $curparts = explode($delimiter, $curbox_name);
287 $curname = array_pop($curparts);
288 $actual_parname = implode($delimiter, $curparts);
289 $actual_parname = substr($actual_parname,0,strlen($parbox_name));
291 /* Compare the actual with the given parent name. */
292 return ($parbox_name == $actual_parname);
295 function ListBoxes ($boxes, $j=0 ) {
296 global $data_dir, $username, $color, $unseen_notify, $unseen_type,
297 $move_to_trash, $trash_folder, $collapse_folders, $imapConnection,
298 $use_icons, $icon_theme, $use_special_folder_color;
300 if (!isset($boxes) ||
empty($boxes))
306 $unseen_found = false;
309 $mailbox = $boxes->mailboxname_full
;
311 $leader .= str_repeat(' ',$j);
312 $mailboxURL = urlencode($mailbox);
314 /* get unseen/total messages information */
315 /* Only need to display info when option is set */
316 if (isset($unseen_notify) && ($unseen_notify > 1) &&
317 (($boxes->unseen
!== false) ||
($boxes->total
!== false))) {
319 if ($boxes->unseen
!== false)
320 $unseen = $boxes->unseen
;
323 Should only display unseen info if the folder is inbox
324 or you set the option for all folders
327 if ((strtolower($mailbox) == 'inbox') ||
($unseen_notify == 3)) {
328 $unseen_string = $unseen;
330 /* If users requests, display message count too */
331 if (isset($unseen_type) && ($unseen_type == 2) && ($boxes->total
!== false)) {
332 $unseen_string .= '/' . $boxes->total
;
335 $unseen_string = "<font color=\"$color[11]\">($unseen_string)</font>";
338 Finally allow the script to display the values by setting a boolean.
339 This can only occur if the unseen count is great than 0 (if you have
340 unseen count only), or you have the message count too.
342 if (($unseen > 0) ||
(isset($unseen_type) && ($unseen_type ==2))) {
343 $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 if ($use_icons && $icon_theme != 'none') {
355 $link .= "unfold=$mailboxURL\">$leader<img src=\"" . SM_PATH
. 'images/plus.png" border="0" height="7" width="7" /> </tt>';
357 $link .= "unfold=$mailboxURL\">$leader+ </tt>";
360 if ($use_icons && $icon_theme != 'none') {
361 $link .= "fold=$mailboxURL\">$leader<img src=\"" . SM_PATH
. 'images/minus.png" border="0" height="7" width="7" /> </tt>';
363 $link .= "fold=$mailboxURL\">$leader- </tt>";
369 $pre.= $leader . ' </tt>';
372 /* If there are unseen message, bold the line. */
373 if (($move_to_trash) && ($mailbox == $trash_folder)) {
374 if (! isset($boxes->total
)) {
375 $boxes->total
= sqimap_status_messages($imapConnection, $mailbox);
380 $pre .= "<a href=\"right_main.php?PG_SHOWALL=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\">";
385 if ($boxes->total
> 0) {
389 $pre .= "<a href=\"right_main.php?PG_SHOWALL=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\">";
393 /* Print unseen information. */
395 $end .= " <small>$unseen_string</small>";
397 $end .= "\n<small>\n" .
398 ' [<a href="empty_trash.php">'._("Purge").'</a>]'.
402 if (!$boxes->is_noselect
) {
406 $pre .= "<a href=\"right_main.php?PG_SHOWALL=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\">";
412 /* Print unseen information. */
414 $end .= " <small>$unseen_string</small>";
421 if ($use_special_folder_color && $boxes->is_special
) {
422 $font = "<font color=\"$color[11]\">";
423 $fontend = "</font>";
426 // let plugins fiddle with end of line
427 $end .= concat_hook_function('left_main_after_each_folder',
428 array(isset($numMessages) ?
$numMessages : '',
429 $boxes->mailboxname_full
, $imapConnection));
433 if (!$boxes->is_root
) {
434 echo "" . $pre .$font. str_replace(array(' ','<','>'),array(' ','<','>'),$boxes->mailboxname_sub
) .$fontend . $end. '<br />' . "\n";
438 if (!$collapse ||
$boxes->is_root
) {
439 for ($i = 0; $i <count($boxes->mbxs
); $i++
) {
440 listBoxes($boxes->mbxs
[$i],$j);
445 function ListAdvancedBoxes ($boxes, $mbx, $j='ID.0000' ) {
446 global $data_dir, $username, $color, $unseen_notify, $unseen_type,
447 $move_to_trash, $trash_folder, $collapse_folders, $use_special_folder_color;
449 if (!isset($boxes) ||
empty($boxes))
452 /* use_folder_images only works if the images exist in ../images */
453 $use_folder_images = true;
458 $unseen_found = false;
461 $mailbox = $boxes->mailboxname_full
;
462 $mailboxURL = urlencode($mailbox);
464 /* get unseen/total messages information */
465 /* Only need to display info when option is set */
466 if (isset($unseen_notify) && ($unseen_notify > 1) &&
467 (($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
;
485 $unseen_string = "<font color=\"$color[11]\">($unseen_string)</font>";
488 Finally allow the script to display the values by setting a boolean.
489 This can only occur if the unseen count is great than 0 (if you have
490 unseen count only), or you have the message count too.
492 if (($unseen > 0) ||
(isset($unseen_type) && ($unseen_type ==2))) {
493 $unseen_found = true;
498 /* If there are unseen message, bold the line. */
499 if ($unseen > 0) { $pre .= '<b>'; }
501 /* color special boxes */
502 if ($use_special_folder_color && $boxes->is_special
) {
503 $pre .= "<font color=\"$color[11]\">";
507 /* If there are unseen message, close bolding. */
508 if ($unseen > 0) { $end .= '</b>'; }
510 /* Print unseen information. */
512 $end .= " $unseen_string";
515 if (($move_to_trash) && ($mailbox == $trash_folder)) {
516 if (! isset($numMessages)) {
517 $numMessages = $boxes->total
;
519 $pre = "<a class=\"mbx_link\" href=\"right_main.php?PG_SHOWALL=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\">" . $pre;
521 if ($numMessages > 0) {
522 $end .= "\n<small>\n" .
523 ' [<a class="mbx_link" href="empty_trash.php">'._("Purge").'</a>]'.
527 if (!$boxes->is_noselect
) { /* \Noselect boxes can't be selected */
528 $pre = "<a class=\"mbx_link\" href=\"right_main.php?PG_SHOWALL=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\">" . $pre;
533 // let plugins fiddle with end of line
534 global $imapConnection;
535 $end .= concat_hook_function('left_main_after_each_folder',
536 array(isset($numMessages) ?
$numMessages : '',
537 $boxes->mailboxname_full
, $imapConnection));
539 if (!$boxes->is_root
) {
540 if ($use_folder_images) {
541 if ($boxes->is_inbox
) {
542 $folder_img = '../images/inbox.png';
543 } else if ($boxes->is_sent
) {
544 $folder_img = '../images/senti.png';
545 } else if ($boxes->is_trash
) {
546 $folder_img = '../images/delitem.png';
547 } else if ($boxes->is_draft
) {
548 $folder_img = '../images/draft.png';
549 } else if ($boxes->is_noinferiors
) {
550 $folder_img = '../images/folder_noinf.png';
552 $folder_img = '../images/folder.png';
554 $folder_img = ' <img src="'.$folder_img.'" height="15" valign="center" /> ';
558 if (!isset($boxes->mbxs
[0])) {
559 echo ' ' . html_tag( 'div',
560 '<tt>'. $pre . $folder_img . '</tt>'. str_replace(array(' ','<','>'),array(' ','<','>'),$boxes->mailboxname_sub
) . $end,
561 'left', '', 'class="mbx_sub" id="' .$j. '"' ) . "\n";
563 /* get collapse information */
564 if ($collapse_folders) {
565 $form_entry = $j.'F';
566 if (isset($mbx) && isset($mbx[$form_entry])) {
567 $collapse = $mbx[$form_entry];
568 setPref($data_dir, $username, 'collapse_folder_'.$boxes->mailboxname_full
, $collapse ? SM_BOX_COLLAPSED
: SM_BOX_UNCOLLAPSED
);
570 $collapse = getPref($data_dir, $username, 'collapse_folder_' . $mailbox);
571 $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED
: $collapse);
573 $img_src = ($collapse ?
'../images/plus.png' : '../images/minus.png');
574 $collapse_link = '<a href="javascript:void(0)">'." <img src=\"$img_src\" border=\"1\" id=$j onclick=\"hidechilds(this)\" style=\"cursor:hand\" /></a>";
578 echo ' ' . html_tag( 'div',
579 $collapse_link . $pre . $folder_img . ' '. $boxes->mailboxname_sub
. $end ,
580 'left', '', 'class="mbx_par" id="' .$j. 'P"' ) . "\n";
581 echo ' <input type="hidden" name="mbx['.$j. 'F]" value="'.$collapse.'" id="mbx['.$j.'F]" />'."\n";
585 $visible = ($collapse ?
' style="display:none"' : ' style="display:block"');
586 if (isset($boxes->mbxs
[0]) && !$boxes->is_root
) /* mailbox contains childs */
587 echo html_tag( 'div', '', 'left', '', 'class="par_area" id='.$j.'.0000 '. $visible ) . "\n";
591 for ($i = 0; $i <count($boxes->mbxs
); $i++
) {
593 ListAdvancedBoxes($boxes->mbxs
[$i],$mbx,$j);
595 if (isset($boxes->mbxs
[0]) && !$boxes->is_root
)
596 echo '</div>'."\n\n";
602 /* -------------------- MAIN ------------------------ */
605 sqgetGlobalVar('username', $username, SQ_SESSION
);
606 sqgetGlobalVar('key', $key, SQ_COOKIE
);
607 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION
);
608 sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION
);
610 sqgetGlobalVar('fold', $fold, SQ_GET
);
611 sqgetGlobalVar('unfold', $unfold, SQ_GET
);
615 // open a connection on the imap port (143)
616 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 10); // the 10 is to hide the output
619 * Using stristr since older preferences may contain "None" and "none".
621 if (isset($left_refresh) && ($left_refresh != '') &&
622 !stristr($left_refresh, 'none')){
623 $xtra = "\n<meta http-equiv=\"Expires\" content=\"Thu, 01 Dec 1994 16:00:00 GMT\" />\n" .
624 "<meta http-equiv=\"Pragma\" content=\"no-cache\" />\n".
625 "<meta http-equiv=\"REFRESH\" content=\"$left_refresh;URL=left_main.php\" />\n";
631 * $advanced_tree and $oldway are boolean vars which are default set to default
633 * Setting $oldway to false causes left_main.php to use the new experimental
634 * way of getting the mailbox-tree.
635 * Setting $advanced tree to true causes SM to display a experimental
636 * mailbox-tree with dhtml behaviour.
637 * It only works on browsers which supports css and javascript. The used
638 * javascript is experimental and doesn't support all browsers.
639 * It has been tested on IE6 an Konquerer 3.0.0-2.
640 * It is now tested and working on: (please test and update this list)
641 * Windows: IE 5.5 SP2, IE 6 SP1, Gecko based (Mozilla, Firebird) and Opera7
644 * In the function ListAdvancedBoxes there is another var $use_folder_images.
645 * setting this to true is only usefull if the images exists in ../images.
647 * Feel free to experiment with the code and report bugs and enhancements
648 * to marc@its-projects.nl
651 /* set this to true if you want to see a nicer mailboxtree */
652 if (! isset($advanced_tree) ||
$advanced_tree=="" ) {
653 $advanced_tree=false;
655 /* default SM behaviour */
656 if (! isset($oldway) ||
$oldway=="" ) {
660 if ($advanced_tree) {
661 $xtra .= '<script language="Javascript" type="text/javascript">'."\n".
663 ' function preload() {'."\n".
664 ' if (document.images) {'."\n".
665 ' var treeImages = new Array;'."\n".
666 ' var arguments = preload.arguments;'."\n".
667 ' for (var i = 0; i<arguments.length; i++) {'."\n".
668 ' treeImages[i] = new Image();'."\n".
669 ' treeImages[i].src = arguments[i];'."\n".
673 'var vTreeImg;'."\n".
674 'var vTreeDiv;'."\n".
675 'var vTreeSrc;'."\n".
676 ' function fTreeTimeout() {'."\n".
677 ' if (vTreeDiv.readyState == "complete")'."\n".
678 ' vTreeImg.src = vTreeSrc;'."\n".
680 ' setTimeout("fTreeTimeout()", 100);'."\n".
682 ' function hidechilds(img) {'."\n".
683 ' id = img.id + ".0000";'."\n".
684 ' form_id = "mbx[" + img.id +"F]";'."\n".
685 ' if (document.all) { //IE, Opera7'."\n".
686 ' div = document.all[id];'."\n".
688 ' if (div.style.display == "none") {'."\n".
689 ' vTreeSrc = "../images/minus.png";'."\n".
690 ' style = "block";'."\n".
694 ' vTreeSrc = "../images/plus.png";'."\n".
695 ' style = "none";'."\n".
698 ' vTreeImg = img;'."\n".
699 ' vTreeDiv = div;'."\n".
700 ' if (typeof vTreeDiv.readyState != "undefined") //IE'."\n".
701 ' setTimeout("fTreeTimeout()",100);'."\n".
702 ' else //Non IE'."\n".
703 ' vTreeImg.src = vTreeSrc;'."\n".
704 ' div.style.display = style;'."\n".
705 ' document.all[form_id].value = value;'."\n".
708 ' else if (document.getElementById) { //Gecko'."\n".
709 ' div = document.getElementById(id);'."\n".
711 ' if (div.style.display == "none") {'."\n".
712 ' src = "../images/minus.png";'."\n".
713 ' style = "block";'."\n".
717 ' src = "../images/plus.png";'."\n".
718 ' style = "none";'."\n".
721 ' div.style.display = style;'."\n".
722 ' img.src = src;'."\n".
723 ' document.getElementById(form_id).value = value;'."\n".
727 ' function buttonover(el,on) {'."\n".
729 "// el.style.borderColor=\"$color[9]\";}\n".
730 " el.style.background=\"$color[0]\";}\n".
732 " el.style.background=\"$color[9]\";}\n".
734 ' function buttonclick(el,on) {'."\n".
736 ' el.style.border="groove";}'."\n".
738 ' el.style.border="ridge";}'."\n".
740 ' function hideframe(hide) {'."\n".
741 ' left_size = "' . $left_size . '";'."\n".
742 ' if (document.all) {'."\n".
743 ' masterf = window.parent.document.all["fs1"];'."\n".
744 ' leftf = window.parent.document.all["left"];'."\n".
745 ' leftcontent = document.all["leftframe"];'."\n".
746 ' leftbutton = document.all["showf"];'."\n".
747 ' } else if (document.getElementById) {'."\n".
748 ' masterf = window.parent.document.getElementById("fs1");'."\n".
749 ' leftf = window.parent.document.getElementById("left");'."\n".
750 ' leftcontent = document.getElementById("leftframe");'."\n".
751 ' leftbutton = document.getElementById("showf");'."\n".
753 ' return false;'."\n".
756 ' new_col = calc_col("20");'."\n".
757 ' masterf.cols = new_col;'."\n".
758 ' document.body.scrollLeft=0;'."\n".
759 ' document.body.style.overflow="hidden";'."\n".
760 ' leftcontent.style.display = "none";'."\n".
761 ' leftbutton.style.display="block";'."\n".
763 ' masterf.cols = calc_col(left_size);'."\n".
764 ' document.body.style.overflow="";'."\n".
765 ' leftbutton.style.display="none";'."\n".
766 ' leftcontent.style.display="block";'."\n".
769 ' function calc_col(c_w) {'."\n";
771 if ($location_of_bar == 'right') {
772 $xtra .= ' right=true;';
774 $xtra .= ' right=false;';
778 $xtra .= 'if (right) {'."\n".
779 " new_col = '*,'+c_w;"."\n".
781 " new_col = c_w+',*';"."\n".
783 ' return new_col;'."\n".
785 ' function resizeframe(direction) {'."\n".
786 ' if (document.all) {'."\n".
787 ' masterf = window.parent.document.all["fs1"];'."\n".
788 ' } else if (document.getElementById) {'."\n".
789 ' window.parent.document.getElementById("fs1");'."\n".
791 ' return false;'."\n".
794 if ($location_of_bar == 'right') {
795 $xtra .= ' colPat=/^\*,(\d+)$/;';
797 $xtra .= ' colPat=/^(\d+),.*$/;';
801 $xtra .= 'old_col = masterf.cols;'."\n".
802 ' colPat.exec(old_col);'."\n".
803 ' if (direction) {'."\n".
804 ' new_col_width = parseInt(RegExp.$1) + 25;'."\n".
806 ' if (parseInt(RegExp.$1) > 35) {'."\n".
807 ' new_col_width = parseInt(RegExp.$1) - 25;'."\n".
810 ' masterf.cols = calc_col(new_col_width);'."\n".
815 /* style definitions */
817 $xtra .= '<style type="text/css">'."\n".
820 ' margin: 0px 0px 0px 0px;'."\n".
821 ' padding: 5px 5px 5px 5px;'."\n".
824 ' border:outset;'."\n".
825 " border-color: $color[9];\n".
826 " background:$color[0];\n".
827 " color:$color[6];\n".
832 ' font-size:1.0em;'."\n".
833 ' margin-left:4px;'."\n".
834 ' margin-right:0px;'."\n".
836 ' a.mbx_link {'."\n".
837 ' text-decoration: none;'."\n".
838 " background-color: $color[0];\n".
839 ' display: inline;'."\n".
841 ' a:hover.mbx_link {'."\n".
842 " background-color: $color[9];\n".
844 ' a.mbx_link img {'."\n".
845 ' border-style: none;'."\n".
848 ' padding-left:5px;'."\n".
849 ' padding-right:0px;'."\n".
850 ' margin-left:4px;'."\n".
851 ' margin-right:0px;'."\n".
852 ' font-size:0.9em;'."\n".
855 ' margin-top:0px;'."\n".
856 ' margin-left:4px;'."\n".
857 ' margin-right:0px;'."\n".
858 ' padding-left:10px;'."\n".
859 ' padding-bottom:5px;'."\n".
860 ' border-left: solid;'."\n".
861 ' border-left-width:0.1em;'."\n".
862 " border-left-color:$color[9];\n".
863 ' border-bottom: solid;'."\n".
864 ' border-bottom-width:0.1em;'."\n".
865 " border-bottom-color:$color[9];\n".
866 ' display: block;'."\n".
868 ' .mailboxes {'."\n".
869 ' padding-bottom:3px;'."\n".
870 ' margin-right:4px;'."\n".
871 ' padding-right:4px;'."\n".
872 ' margin-left:4px;'."\n".
873 ' padding-left:4px;'."\n".
874 ' border: groove;'."\n".
875 ' border-width:0.1em;'."\n".
876 " border-color:$color[9];\n".
877 " background: $color[0];\n".
883 displayHtmlHeader( 'SquirrelMail', $xtra );
884 sqgetGlobalVar('auto_create_done',$auto_create_done,SQ_SESSION
);
885 /* If requested and not yet complete, attempt to autocreate folders. */
886 if ($auto_create_special && !isset($auto_create_done)) {
887 $autocreate = array($sent_folder, $trash_folder, $draft_folder);
888 foreach( $autocreate as $folder ) {
889 if (($folder != '') && ($folder != 'none')) {
890 if ( !sqimap_mailbox_exists($imapConnection, $folder)) {
891 sqimap_mailbox_create($imapConnection, $folder, '');
893 //if (!sqimap_mailbox_is_subscribed($imapConnection, $folder)) {
894 // check for subscription is useless and expensive just
895 // surpress the NO response
896 sqimap_subscribe($imapConnection, $folder, false);
901 /* Let the world know that autocreation is complete! Hurrah! */
902 $auto_create_done = TRUE;
903 sqsession_register($auto_create_done, 'auto_create_done');
906 if ($advanced_tree) {
908 ' onload="preload(\'../images/minus.png\',\'../images/plus.png\')"' .
909 " bgcolor=\"$color[3]\" text=\"$color[6]\" link=\"$color[6]\" vlink=\"$color[6]\" alink=\"$color[6]\">\n";
911 echo "\n<body bgcolor=\"$color[3]\" text=\"$color[6]\" link=\"$color[6]\" vlink=\"$color[6]\" alink=\"$color[6]\">\n";
914 do_hook('left_main_before');
915 if ($advanced_tree) {
916 /* nice future feature, needs layout !! volunteers? */
917 $right_pos = $left_size - 20;
918 /* 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>';
919 echo '<div id="showf" style="width=20;font-size:12;display:none;"><a href="javascript:hideframe(false)"><b>>></b></a></div>';
920 echo '<div id="incrf" style="width=20;font-size:12"><a href="javascript:resizeframe(true)"><b>></b></a></div>';
921 echo '<div id="decrf" style="width=20;font-size:12"><a href="javascript:resizeframe(false)"><b><</b></a></div></div>';
922 echo '<div id="leftframe"><br /><br />';*/
925 echo "\n\n" . html_tag( 'table', '', 'left', '', 'border="0" cellspacing="0" cellpadding="0" width="99%"' ) .
927 html_tag( 'td', '', 'left' ) .
928 html_tag( 'table', '', '', '', 'border="0" cellspacing="0" cellpadding="0" width="98%"' ) .
930 html_tag( 'td', '', 'center' ) .
931 '<font size="4"><b>'. _("Folders") . "</b><br /></font>\n\n";
933 if ($date_format != 6) {
934 /* First, display the clock. */
935 if ($hour_format == 1) {
937 if ($date_format == 4) {
941 if ($date_format == 4) {
948 switch( $date_format ) {
950 $clk = date('Y-m-d '.$hr. ' T', time());
953 $clk = date('m/d/y '.$hr, time());
956 $clk = date('d/m/y '.$hr, time());
960 $clk = date($hr, time());
963 $clk = getDayAbrv( date( 'w', time() ) ) . date( ', ' . $hr, time() );
965 $clk = str_replace(' ',' ',$clk);
967 echo '<small>' . str_replace(' ',' ',_("Last Refresh")) .
968 ":<br />$clk</small><br />";
971 /* Next, display the refresh button. */
972 echo '<div style="white-space: nowrap;"><small>[<a href="../src/left_main.php" target="left">'.
973 _("Check mail") . '</a>]</small></div></td></tr></table><br />';
975 /* Lastly, display the folder list. */
976 if ( $collapse_folders ) {
977 /* If directed, collapse or uncollapse a folder. */
979 setPref($data_dir, $username, 'collapse_folder_' . $fold, SM_BOX_COLLAPSED
);
980 } else if (isset($unfold)) {
981 setPref($data_dir, $username, 'collapse_folder_' . $unfold, SM_BOX_UNCOLLAPSED
);
985 /* Get unseen/total display prefs */
986 $unseen_type = getPref( $data_dir , $username , 'unseen_type' );
987 $unseen_notify = getPref( $data_dir , $username , 'unseen_notify' );
989 if (!isset($unseen_type) ||
empty($unseen_type)) {
990 if (isset($default_unseen_type) && !empty($default_unseen_type)) {
991 $unseen_type = $default_unseen_type;
997 if (!isset($unseen_notify) ||
empty($unseen_notify)) {
998 if (isset($default_unseen_notify) && !empty($default_unseen_notify)) {
999 $unseen_notify = $default_unseen_notify;
1005 if ($oldway) { /* normal behaviour SM */
1007 $boxes = sqimap_mailbox_list($imapConnection);
1008 /* Prepare do do out collapsedness and visibility computation. */
1010 $boxcount = count($boxes);
1012 /* Compute the collapsedness and visibility of each box. */
1014 while ($curbox < $boxcount) {
1015 $boxes[$curbox]['visible'] = TRUE;
1016 compute_folder_children($curbox, $boxcount);
1019 for ($i = 0; $i < count($boxes); $i++
) {
1020 if ( $boxes[$i]['visible'] ) {
1021 $mailbox = $boxes[$i]['formatted'];
1022 $mblevel = substr_count($boxes[$i]['unformatted'], $delimiter) +
1;
1024 /* Create the prefix for the folder name and link. */
1025 $prefix = str_repeat(' ',$mblevel);
1026 if (isset($collapse_folders) && $collapse_folders && $boxes[$i]['parent']) {
1027 $prefix = str_replace(' ',' ',substr($prefix,0,strlen($prefix)-2)).
1028 create_collapse_link($i) . ' ';
1030 $prefix = str_replace(' ',' ',$prefix);
1032 $line = "<nobr><tt>$prefix</tt>";
1034 /* Add the folder name and link. */
1035 if (! isset($color[15])) {
1036 $color[15] = $color[6];
1039 if (in_array('noselect', $boxes[$i]['flags'])) {
1040 if( isSpecialMailbox( $boxes[$i]['unformatted']) ) {
1041 $line .= "<font color=\"$color[11]\">";
1043 $line .= "<font color=\"$color[15]\">";
1045 if (ereg("^( *)([^ ]*)", $mailbox, $regs)) {
1046 $mailbox = str_replace(' ','',$mailbox);
1047 $line .= str_replace(' ', ' ', $mailbox);
1051 $line .= formatMailboxName($imapConnection, $boxes[$i]);
1054 /* Put the final touches on our folder line. */
1055 $line .= "</nobr><br />\n";
1057 /* Output the line for this folder. */
1061 } else { /* expiremental code */
1062 $boxes = sqimap_mailbox_tree($imapConnection);
1063 if (isset($advanced_tree) && $advanced_tree) {
1064 echo '<form name="collapse" action="left_main.php" method="post" ' .
1065 'enctype="multipart/form-data"'."\n";
1067 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 />';
1068 echo '<div id="mailboxes" class="mailboxes">'."\n\n";
1069 sqgetGlobalVar('mbx', $mbx, SQ_POST
);
1070 if (!isset($mbx)) $mbx=NULL;
1071 ListAdvancedBoxes($boxes, $mbx);
1074 echo '</form>'."\n";
1076 //sqimap_get_status_mbx_tree($imap_stream,$boxes)
1079 } /* if ($oldway) else ... */
1080 do_hook('left_main_after');
1081 sqimap_logout($imapConnection);