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