since comments are not needed for @return
[squirrelmail.git] / src / left_main.php
... / ...
CommitLineData
1<?php
2
3/**
4 * left_main.php
5 *
6 * Copyright (c) 1999-2005 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
9 * This is the code for the left bar. The left bar shows the folders
10 * available, and has cookie information.
11 *
12 * @version $Id$
13 * @package squirrelmail
14 */
15
16/**
17 * Path for SquirrelMail required files.
18 * @ignore
19 */
20define('SM_PATH','../');
21
22/* SquirrelMail required files. */
23require_once(SM_PATH . 'include/validate.php');
24require_once(SM_PATH . 'functions/imap.php');
25require_once(SM_PATH . 'functions/plugin.php');
26require_once(SM_PATH . 'functions/page_header.php');
27require_once(SM_PATH . 'functions/html.php');
28require_once(SM_PATH . 'functions/date.php');
29
30/* These constants are used for folder stuff. */
31define('SM_BOX_UNCOLLAPSED', 0);
32define('SM_BOX_COLLAPSED', 1);
33
34/* --------------------- FUNCTIONS ------------------------- */
35
36
37/**
38 * Recursive function to output a tree of folders.
39 * It is called on a list of boxes and iterates over that tree.
40 *
41 * @since 1.3.0
42 */
43function ListBoxes ($boxes, $j=0 ) {
44 global $data_dir, $username, $color, $unseen_notify, $unseen_type,
45 $move_to_trash, $trash_folder, $collapse_folders, $imapConnection,
46 $use_icons, $icon_theme, $use_special_folder_color;
47
48 // stop condition
49 if (empty($boxes)) {
50 return;
51 }
52
53 $pre = '<span style="white-space: nowrap;">';
54 $end = '';
55 $collapse = false;
56 $unseen_found = false;
57 $unseen = 0;
58
59 $mailbox = $boxes->mailboxname_full;
60 $leader = '<tt>';
61 $leader .= str_repeat('&nbsp;&nbsp;',$j);
62 $mailboxURL = urlencode($mailbox);
63
64 /* get unseen/total messages information */
65 /* Only need to display info when option is set */
66 if (isset($unseen_notify) && ($unseen_notify > 1) &&
67 (($boxes->unseen !== false) || ($boxes->total !== false))) {
68
69 if ($boxes->unseen !== false)
70 $unseen = $boxes->unseen;
71
72 /*
73 Should only display unseen info if the folder is inbox
74 or you set the option for all folders
75 */
76
77 if ((strtolower($mailbox) == 'inbox') || ($unseen_notify == 3)) {
78 $unseen_string = $unseen;
79
80 /* If users requests, display message count too */
81 if (isset($unseen_type) && ($unseen_type == 2) && ($boxes->total !== false)) {
82 $unseen_string .= '/' . $boxes->total;
83 }
84
85 $unseen_string = "<font color=\"$color[11]\">($unseen_string)</font>";
86
87 /*
88 Finally allow the script to display the values by setting a boolean.
89 This can only occur if the unseen count is great than 0 (if you have
90 unseen count only), or you have the message count too.
91 */
92 if (($unseen > 0) || (isset($unseen_type) && ($unseen_type ==2))) {
93 $unseen_found = true;
94 }
95 }
96 }
97
98 if (isset($boxes->mbxs[0]) && $collapse_folders) {
99 $collapse = getPref($data_dir, $username, 'collapse_folder_' . $mailbox);
100 $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED : $collapse);
101
102 $link = '<a target="left" style="text-decoration:none" ' .'href="left_main.php?';
103 if ($collapse) {
104 if ($use_icons && $icon_theme != 'none') {
105 $link .= "unfold=$mailboxURL\">$leader<img src=\"" . SM_PATH . 'images/plus.png" border="0" height="7" width="7" />&nbsp;</tt>';
106 } else {
107 $link .= "unfold=$mailboxURL\">$leader+&nbsp;</tt>";
108 }
109 } else {
110 if ($use_icons && $icon_theme != 'none') {
111 $link .= "fold=$mailboxURL\">$leader<img src=\"" . SM_PATH . 'images/minus.png" border="0" height="7" width="7" />&nbsp;</tt>';
112 } else {
113 $link .= "fold=$mailboxURL\">$leader-&nbsp;</tt>";
114 }
115 }
116 $link .= '</a>';
117 $pre .= $link;
118 } else {
119 $pre.= $leader . '&nbsp;&nbsp;</tt>';
120 }
121
122 /* If there are unseen message, bold the line. */
123 if (($move_to_trash) && ($mailbox == $trash_folder)) {
124 if (! isset($boxes->total)) {
125 $boxes->total = sqimap_status_messages($imapConnection, $mailbox);
126 }
127 if ($unseen > 0) {
128 $pre .= '<b>';
129 }
130 $pre .= "<a href=\"right_main.php?PG_SHOWALL=0&amp;startMessage=1&amp;mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\">";
131 $end .= '</a>';
132 if ($unseen > 0) {
133 $end .= '</b>';
134 }
135 if ($boxes->total > 0) {
136 if ($unseen > 0) {
137 $pre .= '<b>';
138 }
139 $pre .= "<a href=\"right_main.php?PG_SHOWALL=0&amp;startMessage=1&amp;mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\">";
140 if ($unseen > 0) {
141 $end .= '</b>';
142 }
143 /* Print unseen information. */
144 if ($unseen_found) {
145 $end .= "&nbsp;<small>$unseen_string</small>";
146 }
147 }
148 $end .= "\n\t<small>" .
149 '&nbsp;&nbsp;[<a href="empty_trash.php">'._("Purge").'</a>]'.
150 '</small>';
151 } else {
152 if (!$boxes->is_noselect) {
153 if ($unseen > 0) {
154 $pre .= '<b>';
155 }
156 $pre .= "<a href=\"right_main.php?PG_SHOWALL=0&amp;startMessage=1&amp;mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\">";
157 $end .= '</a>';
158 if ($unseen > 0) {
159 $end .= '</b>';
160 }
161 }
162 /* Print unseen information. */
163 if ($unseen_found) {
164 $end .= "&nbsp;<small>$unseen_string</small>";
165 }
166
167 }
168
169 $font = '';
170 $fontend = '';
171 if ($use_special_folder_color && $boxes->is_special) {
172 $font = "<font color=\"$color[11]\">";
173 $fontend = "</font>";
174 } elseif ( $boxes->is_noselect ) {
175 $font = "<font color=\"$color[15]\">";
176 $fontend = '</font>';
177 }
178
179 // let plugins fiddle with end of line
180 $end .= concat_hook_function('left_main_after_each_folder',
181 array(isset($numMessages) ? $numMessages : '',
182 $boxes->mailboxname_full, $imapConnection));
183
184 $end .= '</span>';
185
186 if (!$boxes->is_root) {
187 echo "" . $pre .$font.
188 str_replace(
189 array(' ','<','>'),
190 array('&nbsp;','&lt;','&gt;'),
191 $boxes->mailboxname_sub) .
192 $fontend . $end. '<br />' . "\n";
193 $j++;
194 }
195
196 if (!$collapse || $boxes->is_root) {
197 for ($i = 0; $i <count($boxes->mbxs); $i++) {
198 ListBoxes($boxes->mbxs[$i],$j);
199 }
200 }
201}
202
203function ListAdvancedBoxes ($boxes, $mbx, $j='ID.0000' ) {
204 global $data_dir, $username, $color, $unseen_notify, $unseen_type,
205 $move_to_trash, $trash_folder, $collapse_folders, $use_special_folder_color;
206
207 if (empty($boxes)) {
208 return;
209 }
210
211 /* use_folder_images only works if the images exist in ../images */
212 $use_folder_images = true;
213
214 $pre = '';
215 $end = '';
216 $collapse = false;
217 $unseen_found = false;
218 $unseen = 0;
219
220 $mailbox = $boxes->mailboxname_full;
221 $mailboxURL = urlencode($mailbox);
222
223 /* get unseen/total messages information */
224 /* Only need to display info when option is set */
225 if (isset($unseen_notify) && ($unseen_notify > 1) &&
226 (($boxes->unseen !== false) || ($boxes->total !== false))) {
227
228 if ($boxes->unseen !== false)
229 $unseen = $boxes->unseen;
230
231 /*
232 Should only display unseen info if the folder is inbox
233 or you set the option for all folders
234 */
235
236 if ((strtolower($mailbox) == 'inbox') || ($unseen_notify == 3)) {
237 $unseen_string = $unseen;
238
239 /* If users requests, display message count too */
240 if (isset($unseen_type) && ($unseen_type == 2) && ($boxes->total !== false)) {
241 $unseen_string .= '/' . $boxes->total;
242 }
243
244 $unseen_string = "<font color=\"$color[11]\">($unseen_string)</font>";
245
246 /*
247 Finally allow the script to display the values by setting a boolean.
248 This can only occur if the unseen count is great than 0 (if you have
249 unseen count only), or you have the message count too.
250 */
251 if (($unseen > 0) || (isset($unseen_type) && ($unseen_type ==2))) {
252 $unseen_found = true;
253 }
254 }
255 }
256
257 /* If there are unseen message, bold the line. */
258 if ($unseen > 0) { $pre .= '<b>'; }
259
260 /* color special boxes */
261 if ($use_special_folder_color && $boxes->is_special) {
262 $pre .= "<font color=\"$color[11]\">";
263 $end .= '</font>';
264 }
265
266 /* If there are unseen message, close bolding. */
267 if ($unseen > 0) { $end .= '</b>'; }
268
269 /* Print unseen information. */
270 if ($unseen_found) {
271 $end .= "&nbsp;$unseen_string";
272 }
273
274 if (($move_to_trash) && ($mailbox == $trash_folder)) {
275 $pre = "<a class=\"mbx_link\" href=\"right_main.php?PG_SHOWALL=0&amp;startMessage=1&amp;mailbox=$mailboxURL\" target=\"right\">" . $pre;
276 $end .= '</a>';
277 $end .= "\n<small>\n" .
278 '&nbsp;&nbsp;[<a class="mbx_link" href="empty_trash.php">'._("Purge").'</a>]'.
279 '</small>';
280 } else {
281 if (!$boxes->is_noselect) { /* \Noselect boxes can't be selected */
282 $pre = "<a class=\"mbx_link\" href=\"right_main.php?PG_SHOWALL=0&amp;startMessage=1&amp;mailbox=$mailboxURL\" target=\"right\">" . $pre;
283 $end .= '</a>';
284 }
285 }
286
287 // let plugins fiddle with end of line
288 global $imapConnection;
289 $end .= concat_hook_function('left_main_after_each_folder',
290 array(isset($numMessages) ? $numMessages : '',
291 $boxes->mailboxname_full, $imapConnection));
292
293 if (!$boxes->is_root) {
294 if ($use_folder_images) {
295 if ($boxes->is_inbox) {
296 $folder_img = '../images/inbox.png';
297 } else if ($boxes->is_sent) {
298 $folder_img = '../images/senti.png';
299 } else if ($boxes->is_trash) {
300 $folder_img = '../images/delitem.png';
301 } else if ($boxes->is_draft) {
302 $folder_img = '../images/draft.png';
303 } else if ($boxes->is_noinferiors) {
304 $folder_img = '../images/folder_noinf.png';
305 } else {
306 $folder_img = '../images/folder.png';
307 }
308 $folder_img = '&nbsp;<img src="'.$folder_img.'" height="15" valign="center" />&nbsp;';
309 } else {
310 $folder_img = '';
311 }
312 if (!isset($boxes->mbxs[0])) {
313 echo ' ' . html_tag( 'div',
314 '<tt>'. $pre . $folder_img . '</tt>' .
315 str_replace( array(' ','<','>'),
316 array('&nbsp;','&lt;','&gt;'),
317 $boxes->mailboxname_sub) .
318 $end,
319 'left', '', 'class="mbx_sub" id="' .$j. '"' ) . "\n";
320 } else {
321 /* get collapse information */
322 if ($collapse_folders) {
323 $form_entry = $j.'F';
324 if (isset($mbx) && isset($mbx[$form_entry])) {
325 $collapse = $mbx[$form_entry];
326 setPref($data_dir, $username, 'collapse_folder_'.$boxes->mailboxname_full ,
327 $collapse ? SM_BOX_COLLAPSED : SM_BOX_UNCOLLAPSED);
328 } else {
329 $collapse = getPref($data_dir, $username, 'collapse_folder_' . $mailbox);
330 $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED : $collapse);
331 }
332 $img_src = ($collapse ? '../images/plus.png' : '../images/minus.png');
333 $collapse_link = '<a href="javascript:void(0)">' .
334 " <img src=\"$img_src\" border=\"1\" id=$j onclick=\"hidechilds(this)\" style=\"cursor:hand\" /></a>";
335 } else {
336 $collapse_link='';
337 }
338 echo ' ' . html_tag( 'div',
339 $collapse_link . $pre . $folder_img . '&nbsp;'. $boxes->mailboxname_sub . $end ,
340 'left', '', 'class="mbx_par" id="' .$j. 'P"' ) . "\n";
341 echo ' <input type="hidden" name="mbx['.$j. 'F]" value="'.$collapse.'" id="mbx['.$j.'F]" />'."\n";
342 }
343 }
344
345 $visible = ($collapse ? ' style="display:none"' : ' style="display:block"');
346 if (isset($boxes->mbxs[0]) && !$boxes->is_root) /* mailbox contains childs */
347 echo html_tag( 'div', '', 'left', '', 'class="par_area" id='.$j.'.0000 '. $visible ) . "\n";
348
349 if ($j !='ID.0000') {
350 $j = $j .'.0000';
351 }
352 for ($i = 0; $i <count($boxes->mbxs); $i++) {
353 $j++;
354 ListAdvancedBoxes($boxes->mbxs[$i],$mbx,$j);
355 }
356 if (isset($boxes->mbxs[0]) && !$boxes->is_root) {
357 echo '</div>'."\n\n";
358 }
359}
360
361
362
363
364/* -------------------- MAIN ------------------------ */
365
366/* get globals */
367sqgetGlobalVar('username', $username, SQ_SESSION);
368sqgetGlobalVar('key', $key, SQ_COOKIE);
369sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION);
370sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION);
371
372sqgetGlobalVar('fold', $fold, SQ_GET);
373sqgetGlobalVar('unfold', $unfold, SQ_GET);
374
375/* end globals */
376
377// open a connection on the imap port (143)
378// why hide the output?
379$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, true);
380
381/**
382 * Using stristr since very old preferences may contain "None" and "none".
383 */
384if (!empty($left_refresh) &&
385 !stristr($left_refresh, 'none')){
386 $xtra = "\n<meta http-equiv=\"Expires\" content=\"Thu, 01 Dec 1994 16:00:00 GMT\" />\n" .
387 "<meta http-equiv=\"Pragma\" content=\"no-cache\" />\n".
388 "<meta http-equiv=\"REFRESH\" content=\"$left_refresh;URL=left_main.php\" />\n";
389} else {
390 $xtra = '';
391}
392
393/**
394 * $advanced_tree and is a boolean var which is default set to default
395 * SM behaviour.
396 * Setting $advanced tree to true causes SM to display a experimental
397 * mailbox-tree with dhtml behaviour.
398 * It only works on browsers which supports css and javascript. The used
399 * javascript is experimental and doesn't support all browsers.
400 * It has been tested on IE6 an Konquerer 3.0.0-2.
401 * It is now tested and working on: (please test and update this list)
402 * Windows: IE 5.5 SP2, IE 6 SP1, Gecko based (Mozilla, Firebird) and Opera7
403 * XWindow: ?
404 * Mac: ?
405 * In the function ListAdvancedBoxes there is another var $use_folder_images.
406 * setting this to true is only usefull if the images exists in ../images.
407 *
408 * Feel free to experiment with the code and report bugs and enhancements
409 **/
410
411/* set this to true if you want to see a nicer mailboxtree */
412if (empty($advanced_tree)) {
413 $advanced_tree=false;
414}
415
416if ($advanced_tree) {
417$xtra .= '<script language="Javascript" type="text/javascript">'."\n".
418'<!--'."\n".
419' function preload() {'."\n".
420' if (document.images) {'."\n".
421' var treeImages = new Array;'."\n".
422' var arguments = preload.arguments;'."\n".
423' for (var i = 0; i<arguments.length; i++) {'."\n".
424' treeImages[i] = new Image();'."\n".
425' treeImages[i].src = arguments[i];'."\n".
426' }'."\n".
427' }'."\n".
428' }'."\n".
429'var vTreeImg;'."\n".
430'var vTreeDiv;'."\n".
431'var vTreeSrc;'."\n".
432' function fTreeTimeout() {'."\n".
433' if (vTreeDiv.readyState == "complete")'."\n".
434' vTreeImg.src = vTreeSrc;'."\n".
435' else'."\n".
436' setTimeout("fTreeTimeout()", 100);'."\n".
437' }'."\n".
438' function hidechilds(img) {'."\n".
439' id = img.id + ".0000";'."\n".
440' form_id = "mbx[" + img.id +"F]";'."\n".
441' if (document.all) { //IE, Opera7'."\n".
442' div = document.all[id];'."\n".
443' if (div) {'."\n".
444' if (div.style.display == "none") {'."\n".
445' vTreeSrc = "../images/minus.png";'."\n".
446' style = "block";'."\n".
447' value = 0;'."\n".
448' }'."\n".
449' else {'."\n".
450' vTreeSrc = "../images/plus.png";'."\n".
451' style = "none";'."\n".
452' value = 1;'."\n".
453' }'."\n".
454' vTreeImg = img;'."\n".
455' vTreeDiv = div;'."\n".
456' if (typeof vTreeDiv.readyState != "undefined") //IE'."\n".
457' setTimeout("fTreeTimeout()",100);'."\n".
458' else //Non IE'."\n".
459' vTreeImg.src = vTreeSrc;'."\n".
460' div.style.display = style;'."\n".
461' document.all[form_id].value = value;'."\n".
462' }'."\n".
463' }'."\n".
464' else if (document.getElementById) { //Gecko'."\n".
465' div = document.getElementById(id);'."\n".
466' if (div) {'."\n".
467' if (div.style.display == "none") {'."\n".
468' src = "../images/minus.png";'."\n".
469' style = "block";'."\n".
470' value = 0;'."\n".
471' }'."\n".
472' else {'."\n".
473' src = "../images/plus.png";'."\n".
474' style = "none";'."\n".
475' value = 1;'."\n".
476' }'."\n".
477' div.style.display = style;'."\n".
478' img.src = src;'."\n".
479' document.getElementById(form_id).value = value;'."\n".
480' }'."\n".
481' }'."\n".
482' }'."\n".
483' function buttonover(el,on) {'."\n".
484' if (!on) {'."\n".
485"// el.style.borderColor=\"$color[9]\";}\n".
486" el.style.background=\"$color[0]\";}\n".
487' else {'."\n".
488" el.style.background=\"$color[9]\";}\n".
489' }'."\n".
490' function buttonclick(el,on) {'."\n".
491' if (!on) {'."\n".
492' el.style.border="groove";}'."\n".
493' else {'."\n".
494' el.style.border="ridge";}'."\n".
495' }'."\n".
496' function hideframe(hide) {'."\n".
497' left_size = "' . $left_size . '";'."\n".
498' if (document.all) {'."\n".
499' masterf = window.parent.document.all["fs1"];'."\n".
500' leftf = window.parent.document.all["left"];'."\n".
501' leftcontent = document.all["leftframe"];'."\n".
502' leftbutton = document.all["showf"];'."\n".
503' } else if (document.getElementById) {'."\n".
504' masterf = window.parent.document.getElementById("fs1");'."\n".
505' leftf = window.parent.document.getElementById("left");'."\n".
506' leftcontent = document.getElementById("leftframe");'."\n".
507' leftbutton = document.getElementById("showf");'."\n".
508' } else {'."\n".
509' return false;'."\n".
510' }'."\n".
511' if(hide) {'."\n".
512' new_col = calc_col("20");'."\n".
513' masterf.cols = new_col;'."\n".
514' document.body.scrollLeft=0;'."\n".
515' document.body.style.overflow="hidden";'."\n".
516' leftcontent.style.display = "none";'."\n".
517' leftbutton.style.display="block";'."\n".
518' } else {'."\n".
519' masterf.cols = calc_col(left_size);'."\n".
520' document.body.style.overflow="";'."\n".
521' leftbutton.style.display="none";'."\n".
522' leftcontent.style.display="block";'."\n".
523' }'."\n".
524' }'."\n".
525' function calc_col(c_w) {'."\n";
526
527 if ($location_of_bar == 'right') {
528 $xtra .= ' right=true;';
529 } else {
530 $xtra .= ' right=false;';
531 }
532 $xtra .= "\n";
533
534$xtra .= 'if (right) {'."\n".
535" new_col = '*,'+c_w;"."\n".
536' } else {'."\n".
537" new_col = c_w+',*';"."\n".
538' }'."\n".
539' return new_col;'."\n".
540' }'."\n".
541' function resizeframe(direction) {'."\n".
542' if (document.all) {'."\n".
543' masterf = window.parent.document.all["fs1"];'."\n".
544' } else if (document.getElementById) {'."\n".
545' window.parent.document.getElementById("fs1");'."\n".
546' } else {'."\n".
547' return false;'."\n".
548' }'."\n";
549
550 if ($location_of_bar == 'right') {
551 $xtra .= ' colPat=/^\*,(\d+)$/;';
552 } else {
553 $xtra .= ' colPat=/^(\d+),.*$/;';
554 }
555 $xtra .= "\n";
556
557$xtra .= 'old_col = masterf.cols;'."\n".
558' colPat.exec(old_col);'."\n".
559' if (direction) {'."\n".
560' new_col_width = parseInt(RegExp.$1) + 25;'."\n".
561' } else {'."\n".
562' if (parseInt(RegExp.$1) > 35) {'."\n".
563' new_col_width = parseInt(RegExp.$1) - 25;'."\n".
564' }'."\n".
565' }'."\n".
566' masterf.cols = calc_col(new_col_width);'."\n".
567' }'."\n".
568'//-->'."\n".
569'</script>'."\n";
570
571/* style definitions */
572
573$xtra .= '<style type="text/css">'."\n".
574'<!--'."\n".
575' body {'."\n".
576' margin: 0px 0px 0px 0px;'."\n".
577' padding: 5px 5px 5px 5px;'."\n".
578' }'."\n".
579' .button {'."\n".
580' border:outset;'."\n".
581" border-color: $color[9];\n".
582" background:$color[0];\n".
583" color:$color[6];\n".
584' width:99%;'."\n".
585' heigth:99%;'."\n".
586' }'."\n".
587' .mbx_par {'."\n".
588' font-size:1.0em;'."\n".
589' margin-left:4px;'."\n".
590' margin-right:0px;'."\n".
591' }'."\n".
592' a.mbx_link {'."\n".
593' text-decoration: none;'."\n".
594" background-color: $color[0];\n".
595' display: inline;'."\n".
596' }'."\n".
597' a:hover.mbx_link {'."\n".
598" background-color: $color[9];\n".
599' }'."\n".
600' a.mbx_link img {'."\n".
601' border-style: none;'."\n".
602' }'."\n".
603' .mbx_sub {'."\n".
604' padding-left:5px;'."\n".
605' padding-right:0px;'."\n".
606' margin-left:4px;'."\n".
607' margin-right:0px;'."\n".
608' font-size:0.9em;'."\n".
609' }'."\n".
610' .par_area {'."\n".
611' margin-top:0px;'."\n".
612' margin-left:4px;'."\n".
613' margin-right:0px;'."\n".
614' padding-left:10px;'."\n".
615' padding-bottom:5px;'."\n".
616' border-left: solid;'."\n".
617' border-left-width:0.1em;'."\n".
618" border-left-color:$color[9];\n".
619' border-bottom: solid;'."\n".
620' border-bottom-width:0.1em;'."\n".
621" border-bottom-color:$color[9];\n".
622' display: block;'."\n".
623' }'."\n".
624' .mailboxes {'."\n".
625' padding-bottom:3px;'."\n".
626' margin-right:4px;'."\n".
627' padding-right:4px;'."\n".
628' margin-left:4px;'."\n".
629' padding-left:4px;'."\n".
630' border: groove;'."\n".
631' border-width:0.1em;'."\n".
632" border-color:$color[9];\n".
633" background: $color[0];\n".
634' }'."\n".
635'-->'."\n".
636'</style>'."\n";
637}
638
639displayHtmlHeader( 'SquirrelMail', $xtra );
640sqgetGlobalVar('auto_create_done',$auto_create_done,SQ_SESSION);
641/* If requested and not yet complete, attempt to autocreate folders. */
642if ($auto_create_special && !isset($auto_create_done)) {
643 $autocreate = array($sent_folder, $trash_folder, $draft_folder);
644 foreach( $autocreate as $folder ) {
645 if (($folder != '') && ($folder != 'none')) {
646 if ( !sqimap_mailbox_exists($imapConnection, $folder)) {
647 sqimap_mailbox_create($imapConnection, $folder, '');
648 } else {
649 // check for subscription is useless and expensive, just
650 // surpress the NO response. Unless we're on Mecury, which
651 // will just subscribe a folder again if it's already
652 // subscribed.
653 if ( strtolower($imap_server_type) != 'mercury32' ||
654 !sqimap_mailbox_is_subscribed($imapConnection, $folder) ) {
655 sqimap_subscribe($imapConnection, $folder, false);
656 }
657 }
658 }
659 }
660
661 /* Let the world know that autocreation is complete! Hurrah! */
662 $auto_create_done = TRUE;
663 sqsession_register($auto_create_done, 'auto_create_done');
664}
665
666if ($advanced_tree) {
667 echo "\n<body" .
668 ' onload="preload(\'../images/minus.png\',\'../images/plus.png\')"' .
669 " bgcolor=\"$color[3]\" text=\"$color[6]\" link=\"$color[6]\" vlink=\"$color[6]\" alink=\"$color[6]\">\n";
670} else {
671 echo "\n<body bgcolor=\"$color[3]\" text=\"$color[6]\" link=\"$color[6]\" vlink=\"$color[6]\" alink=\"$color[6]\">\n";
672}
673
674do_hook('left_main_before');
675if ($advanced_tree) {
676 /* nice future feature, needs layout !! volunteers? */
677 $right_pos = $left_size - 20;
678/* 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>&lt;&lt;</b></a></div>';
679 echo '<div id="showf" style="width=20;font-size:12;display:none;"><a href="javascript:hideframe(false)"><b>&gt;&gt;</b></a></div>';
680 echo '<div id="incrf" style="width=20;font-size:12"><a href="javascript:resizeframe(true)"><b>&gt;</b></a></div>';
681 echo '<div id="decrf" style="width=20;font-size:12"><a href="javascript:resizeframe(false)"><b>&lt;</b></a></div></div>';
682 echo '<div id="leftframe"><br /><br />';*/
683}
684
685echo "\n\n" .
686 '<center><font size="4"><b>'. _("Folders") . "</b><br /></font>\n\n";
687
688if ($date_format != 6) {
689 /* First, display the clock. */
690 if ($hour_format == 1) {
691 $hr = 'H:i';
692 if ($date_format == 4) {
693 $hr .= ':s';
694 }
695 } else {
696 if ($date_format == 4) {
697 $hr = 'g:i:s a';
698 } else {
699 $hr = 'g:i a';
700 }
701 }
702
703 switch( $date_format ) {
704 case 0:
705 $clk = date('Y-m-d '.$hr. ' T', time());
706 break;
707 case 1:
708 $clk = date('m/d/y '.$hr, time());
709 break;
710 case 2:
711 $clk = date('d/m/y '.$hr, time());
712 break;
713 case 4:
714 case 5:
715 $clk = date($hr, time());
716 break;
717 default:
718 $clk = getDayAbrv( date( 'w', time() ) ) . date( ', ' . $hr, time() );
719 }
720 $clk = str_replace(' ','&nbsp;',$clk);
721
722 echo '<small><span style="white-space: nowrap;">'
723 . str_replace(' ', '&nbsp;', _("Last Refresh"))
724 . ":</span><br /><span style=\"white-space: nowrap;\">$clk</span></small><br />\n";
725}
726
727/* Next, display the refresh button. */
728echo '<div style="white-space: nowrap;"><small>[<a href="../src/left_main.php" target="left">'.
729 _("Check mail") . "</a>]</small></div></center><br />\n\n";
730
731/* Lastly, display the folder list. */
732if ( $collapse_folders ) {
733 /* If directed, collapse or uncollapse a folder. */
734 if (isset($fold)) {
735 setPref($data_dir, $username, 'collapse_folder_' . $fold, SM_BOX_COLLAPSED);
736 } else if (isset($unfold)) {
737 setPref($data_dir, $username, 'collapse_folder_' . $unfold, SM_BOX_UNCOLLAPSED);
738 }
739}
740
741/* Get unseen/total display prefs */
742$unseen_type = getPref( $data_dir , $username , 'unseen_type' );
743$unseen_notify = getPref( $data_dir , $username , 'unseen_notify' );
744
745if (empty($unseen_type)) {
746 if (!empty($default_unseen_type)) {
747 $unseen_type = $default_unseen_type;
748 } else {
749 $unseen_type = 1;
750 }
751}
752
753if (empty($unseen_notify)) {
754 if (!empty($default_unseen_notify)) {
755 $unseen_notify = $default_unseen_notify;
756 } else {
757 $unseen_notify = 0;
758 }
759}
760
761$boxes = sqimap_mailbox_tree($imapConnection);
762if (isset($advanced_tree) && $advanced_tree) {
763 echo '<form name="collapse" action="left_main.php" method="post" ' .
764 'enctype="multipart/form-data"'."\n";
765 echo '<small>';
766 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 />';
767 echo '<div id="mailboxes" class="mailboxes">'."\n\n";
768 sqgetGlobalVar('mbx', $mbx, SQ_POST);
769 if (!isset($mbx)) $mbx=NULL;
770 ListAdvancedBoxes($boxes, $mbx);
771 echo '</div>';
772 echo '</small>';
773 echo '</form>'."\n";
774} else {
775 ListBoxes($boxes);
776}
777
778do_hook('left_main_after');
779sqimap_logout($imapConnection);
780
781?>
782</body></html>