making sure that new configuration vars are parsed and configuration arrays
[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 *
47ccfad4 9 * @copyright &copy; 1999-2006 The SquirrelMail Project Team
4b4abf93 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. */
5c4ff7bf 22include_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
81132de8 83 $unseen_string = "<span class=\"highlight\">($unseen_string)</span>";
ccc4580f 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 }
5c4ff7bf 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
81132de8 160 $span = '';
161 $spanend = '';
a259636c 162 if ($use_special_folder_color && $boxes->is_special) {
81132de8 163 $span = "<span class=\"leftspecial\">";
164 $spanend = "</span>";
3cbf882e 165 } elseif ( $boxes->is_noselect ) {
81132de8 166 $span = "<span class=\"leftnoselect\">";
167 $spanend = '</span>';
ccc4580f 168 }
f8a1ed5a 169
81132de8 170
8fc208f8 171 // let plugins fiddle with end of line
172 $end .= concat_hook_function('left_main_after_each_folder',
324ac3c5 173 array(isset($numMessages) ? $numMessages : '',
8fc208f8 174 $boxes->mailboxname_full, $imapConnection));
175
8ad1c1e8 176 $end .= '</span>';
ccc4580f 177
178 if (!$boxes->is_root) {
81132de8 179 echo "" . $span . $pre .
f8a1ed5a 180 str_replace(
3cbf882e 181 array(' ','<','>'),
182 array('&nbsp;','&lt;','&gt;'),
183 $boxes->mailboxname_sub) .
81132de8 184 $end. $spanend .'<br />' . "\n";
ccc4580f 185 $j++;
186 }
187
188 if (!$collapse || $boxes->is_root) {
189 for ($i = 0; $i <count($boxes->mbxs); $i++) {
3cbf882e 190 ListBoxes($boxes->mbxs[$i],$j);
e4c5976a 191 }
f23f6a3a 192 }
193}
194
c8fa94cf 195function ListAdvancedBoxes ($boxes, $mbx, $j='ID.0000' ) {
ce68b76b 196 global $data_dir, $username, $color, $unseen_notify, $unseen_type,
134e4174 197 $move_to_trash, $trash_folder, $collapse_folders, $use_special_folder_color;
f23f6a3a 198
3cbf882e 199 if (empty($boxes)) {
ccc4580f 200 return;
3cbf882e 201 }
4bdcd5e0 202
f23f6a3a 203 /* use_folder_images only works if the images exist in ../images */
c8fa94cf 204 $use_folder_images = true;
f23f6a3a 205
206 $pre = '';
207 $end = '';
208 $collapse = false;
6c8fee24 209 $unseen_found = false;
210 $unseen = 0;
a6172cd5 211
a6172cd5 212 $mailbox = $boxes->mailboxname_full;
213 $mailboxURL = urlencode($mailbox);
f23f6a3a 214
ccc4580f 215 /* get unseen/total messages information */
6c8fee24 216 /* Only need to display info when option is set */
ccc4580f 217 if (isset($unseen_notify) && ($unseen_notify > 1) &&
218 (($boxes->unseen !== false) || ($boxes->total !== false))) {
6c8fee24 219
51ea258b 220 if ($boxes->unseen !== false)
6c8fee24 221 $unseen = $boxes->unseen;
6c8fee24 222
ccc4580f 223 /*
6c8fee24 224 Should only display unseen info if the folder is inbox
225 or you set the option for all folders
226 */
227
228 if ((strtolower($mailbox) == 'inbox') || ($unseen_notify == 3)) {
229 $unseen_string = $unseen;
230
6c8fee24 231 /* If users requests, display message count too */
ccc4580f 232 if (isset($unseen_type) && ($unseen_type == 2) && ($boxes->total !== false)) {
51ea258b 233 $unseen_string .= '/' . $boxes->total;
ccc4580f 234 }
6c8fee24 235
81132de8 236 $unseen_string = "<span class=\"highlight\">($unseen_string)</span>";
6c8fee24 237
238 /*
239 Finally allow the script to display the values by setting a boolean.
240 This can only occur if the unseen count is great than 0 (if you have
241 unseen count only), or you have the message count too.
242 */
243 if (($unseen > 0) || (isset($unseen_type) && ($unseen_type ==2))) {
244 $unseen_found = true;
245 }
ccc4580f 246 }
6c8fee24 247 }
a6172cd5 248
249 /* If there are unseen message, bold the line. */
250 if ($unseen > 0) { $pre .= '<b>'; }
251
252 /* color special boxes */
a259636c 253 if ($use_special_folder_color && $boxes->is_special) {
254773f5 254 $pre .= "<span class=\"leftspecial\">";
81132de8 255 $end .= '</span>';
a6172cd5 256 }
257
258 /* If there are unseen message, close bolding. */
259 if ($unseen > 0) { $end .= '</b>'; }
260
261 /* Print unseen information. */
ccc4580f 262 if ($unseen_found) {
263 $end .= "&nbsp;$unseen_string";
a6172cd5 264 }
265
266 if (($move_to_trash) && ($mailbox == $trash_folder)) {
324ac3c5 267 $pre = "<a class=\"mbx_link\" href=\"right_main.php?PG_SHOWALL=0&amp;startMessage=1&amp;mailbox=$mailboxURL\" target=\"right\">" . $pre;
4bdcd5e0 268 $end .= '</a>';
dea5ef88 269 $end .= "\n<small>\n" .
270 '&nbsp;&nbsp;[<a class="mbx_link" href="empty_trash.php">'._("Purge").'</a>]'.
271 '</small>';
a6172cd5 272 } else {
273 if (!$boxes->is_noselect) { /* \Noselect boxes can't be selected */
324ac3c5 274 $pre = "<a class=\"mbx_link\" href=\"right_main.php?PG_SHOWALL=0&amp;startMessage=1&amp;mailbox=$mailboxURL\" target=\"right\">" . $pre;
4bdcd5e0 275 $end .= '</a>';
a6172cd5 276 }
277 }
278
8fc208f8 279 // let plugins fiddle with end of line
280 global $imapConnection;
281 $end .= concat_hook_function('left_main_after_each_folder',
324ac3c5 282 array(isset($numMessages) ? $numMessages : '',
8fc208f8 283 $boxes->mailboxname_full, $imapConnection));
284
a6172cd5 285 if (!$boxes->is_root) {
286 if ($use_folder_images) {
ccc4580f 287 if ($boxes->is_inbox) {
288 $folder_img = '../images/inbox.png';
289 } else if ($boxes->is_sent) {
290 $folder_img = '../images/senti.png';
291 } else if ($boxes->is_trash) {
292 $folder_img = '../images/delitem.png';
293 } else if ($boxes->is_draft) {
294 $folder_img = '../images/draft.png';
295 } else if ($boxes->is_noinferiors) {
296 $folder_img = '../images/folder_noinf.png';
297 } else {
298 $folder_img = '../images/folder.png';
299 }
0bcd11eb 300 $folder_img = '&nbsp;<img src="'.$folder_img.'" height="15" />&nbsp;';
ccc4580f 301 } else {
302 $folder_img = '';
303 }
a6172cd5 304 if (!isset($boxes->mbxs[0])) {
305 echo ' ' . html_tag( 'div',
0bcd11eb 306 $pre . $folder_img .
3cbf882e 307 str_replace( array(' ','<','>'),
308 array('&nbsp;','&lt;','&gt;'),
309 $boxes->mailboxname_sub) .
310 $end,
3170c448 311 'left', '', 'class="mbx_sub" id="' .$j. '"' ) . "\n";
ccc4580f 312 } else {
a6172cd5 313 /* get collapse information */
3170c448 314 if ($collapse_folders) {
315 $form_entry = $j.'F';
316 if (isset($mbx) && isset($mbx[$form_entry])) {
317 $collapse = $mbx[$form_entry];
3cbf882e 318 setPref($data_dir, $username, 'collapse_folder_'.$boxes->mailboxname_full ,
319 $collapse ? SM_BOX_COLLAPSED : SM_BOX_UNCOLLAPSED);
ccc4580f 320 } else {
3170c448 321 $collapse = getPref($data_dir, $username, 'collapse_folder_' . $mailbox);
322 $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED : $collapse);
323 }
324 $img_src = ($collapse ? '../images/plus.png' : '../images/minus.png');
3cbf882e 325 $collapse_link = '<a href="javascript:void(0)">' .
326 " <img src=\"$img_src\" border=\"1\" id=$j onclick=\"hidechilds(this)\" style=\"cursor:hand\" /></a>";
ccc4580f 327 } else {
3170c448 328 $collapse_link='';
ccc4580f 329 }
330 echo ' ' . html_tag( 'div',
a6172cd5 331 $collapse_link . $pre . $folder_img . '&nbsp;'. $boxes->mailboxname_sub . $end ,
3170c448 332 'left', '', 'class="mbx_par" id="' .$j. 'P"' ) . "\n";
ccc4580f 333 echo ' <input type="hidden" name="mbx['.$j. 'F]" value="'.$collapse.'" id="mbx['.$j.'F]" />'."\n";
a6172cd5 334 }
335 }
a6172cd5 336
4bdcd5e0 337 $visible = ($collapse ? ' style="display:none"' : ' style="display:block"');
338 if (isset($boxes->mbxs[0]) && !$boxes->is_root) /* mailbox contains childs */
339 echo html_tag( 'div', '', 'left', '', 'class="par_area" id='.$j.'.0000 '. $visible ) . "\n";
a6172cd5 340
3cbf882e 341 if ($j !='ID.0000') {
4bdcd5e0 342 $j = $j .'.0000';
3cbf882e 343 }
4bdcd5e0 344 for ($i = 0; $i <count($boxes->mbxs); $i++) {
345 $j++;
346 ListAdvancedBoxes($boxes->mbxs[$i],$mbx,$j);
f23f6a3a 347 }
3cbf882e 348 if (isset($boxes->mbxs[0]) && !$boxes->is_root) {
4bdcd5e0 349 echo '</div>'."\n\n";
3cbf882e 350 }
f23f6a3a 351}
352
353
354
95e93571 355
356/* -------------------- MAIN ------------------------ */
357
f38b7cf0 358/* get globals */
359sqgetGlobalVar('username', $username, SQ_SESSION);
360sqgetGlobalVar('key', $key, SQ_COOKIE);
361sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION);
362sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION);
a32985a5 363
f38b7cf0 364sqgetGlobalVar('fold', $fold, SQ_GET);
365sqgetGlobalVar('unfold', $unfold, SQ_GET);
366
367/* end globals */
95e93571 368
369// open a connection on the imap port (143)
3cbf882e 370// why hide the output?
371$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, true);
95e93571 372
f43c35f8 373/**
3cbf882e 374 * Using stristr since very old preferences may contain "None" and "none".
f43c35f8 375 */
3cbf882e 376if (!empty($left_refresh) &&
d68323ff 377 !stristr($left_refresh, 'none')){
378 $xtra = "\n<meta http-equiv=\"Expires\" content=\"Thu, 01 Dec 1994 16:00:00 GMT\" />\n" .
379 "<meta http-equiv=\"Pragma\" content=\"no-cache\" />\n".
dcc1cc82 380 "<meta http-equiv=\"REFRESH\" content=\"$left_refresh;URL=left_main.php\" />\n";
95e93571 381} else {
382 $xtra = '';
383}
384
f23f6a3a 385/**
3cbf882e 386 * $advanced_tree and is a boolean var which is default set to default
a6172cd5 387 * SM behaviour.
a6172cd5 388 * Setting $advanced tree to true causes SM to display a experimental
f23f6a3a 389 * mailbox-tree with dhtml behaviour.
a6172cd5 390 * It only works on browsers which supports css and javascript. The used
c72be5a6 391 * javascript is experimental and doesn't support all browsers.
392 * It has been tested on IE6 an Konquerer 3.0.0-2.
393 * It is now tested and working on: (please test and update this list)
394 * Windows: IE 5.5 SP2, IE 6 SP1, Gecko based (Mozilla, Firebird) and Opera7
395 * XWindow: ?
396 * Mac: ?
f23f6a3a 397 * In the function ListAdvancedBoxes there is another var $use_folder_images.
398 * setting this to true is only usefull if the images exists in ../images.
a6172cd5 399 *
f23f6a3a 400 * Feel free to experiment with the code and report bugs and enhancements
a6172cd5 401 **/
f23f6a3a 402
78e5377d 403/* set this to true if you want to see a nicer mailboxtree */
3cbf882e 404if (empty($advanced_tree)) {
ccc4580f 405 $advanced_tree=false;
406}
f23f6a3a 407
408if ($advanced_tree) {
0bcd11eb 409$xtra .= <<<HEREDOC
410<script language="Javascript" type="text/javascript">
411<!--
412 function preload() {
413 if (document.images) {
414 var treeImages = new Array;
415 var arguments = preload.arguments;
416 for (var i = 0; i<arguments.length; i++) {
417 treeImages[i] = new Image();
418 treeImages[i].src = arguments[i];
419 }
420 }
421 }
422 var vTreeImg;
423 var vTreeDiv;
424 var vTreeSrc;
425 function fTreeTimeout() {
426 if (vTreeDiv.readyState == "complete")
427 vTreeImg.src = vTreeSrc;
428 else
429 setTimeout("fTreeTimeout()", 100);
430 }
431 function hidechilds(img) {
432 id = img.id + ".0000";
433 form_id = "mbx[" + img.id +"F]";
434 if (document.all) { //IE, Opera7
435 div = document.all[id];
436 if (div) {
437 if (div.style.display == "none") {
438 vTreeSrc = "../images/minus.png";
439 style = "block";
440 value = 0;
441 }
442 else {
443 vTreeSrc = "../images/plus.png";
444 style = "none";
445 value = 1;
446 }
447 vTreeImg = img;
448 vTreeDiv = div;
449 if (typeof vTreeDiv.readyState != "undefined") //IE
450 setTimeout("fTreeTimeout()",100);
451 else //Non IE
452 vTreeImg.src = vTreeSrc;
453 div.style.display = style;
454 document.all[form_id].value = value;
455 }
456 }
457 else if (document.getElementById) { //Gecko
458 div = document.getElementById(id);
459 if (div) {
460 if (div.style.display == "none") {
461 src = "../images/minus.png";
462 style = "block";
463 value = 0;
464 }
465 else {
466 src = "../images/plus.png";
467 style = "none";
468 value = 1;
469 }
470 div.style.display = style;
471 img.src = src;
472 document.getElementById(form_id).value = value;
473 }
474 }
475 }
476 function buttonover(el,on) {
477 if (!on) {
478 el.style.background="$color[0]";}
479 else {
480 el.style.background="$color[9]";}
481 }
482 function buttonclick(el,on) {
483 if (!on) {
484 el.style.border="groove";}
485 else {
486 el.style.border="ridge";}
487 }
488 function hideframe(hide) {
489 left_size = "$left_size";
490 if (document.all) {
491 masterf = window.parent.document.all["fs1"];
492 leftf = window.parent.document.all["left"];
493 leftcontent = document.all["leftframe"];
494 leftbutton = document.all["showf"];
495 } else if (document.getElementById) {
496 masterf = window.parent.document.getElementById("fs1");
497 leftf = window.parent.document.getElementById("left");
498 leftcontent = document.getElementById("leftframe");
499 leftbutton = document.getElementById("showf");
500 } else {
501 return false;
502 }
503 if(hide) {
504 new_col = calc_col("20");
505 masterf.cols = new_col;
506 document.body.scrollLeft=0;
507 document.body.style.overflow="hidden";
508 leftcontent.style.display = "none";
509 leftbutton.style.display="block";
510 } else {
511 masterf.cols = calc_col(left_size);
512 document.body.style.overflow="";
513 leftbutton.style.display="none";
514 leftcontent.style.display="block";
515 }
516 }
517 function calc_col(c_w) {
518HEREDOC;
599038d5 519 if ($location_of_bar == 'right') {
520 $xtra .= ' right=true;';
a6172cd5 521 } else {
599038d5 522 $xtra .= ' right=false;';
523 }
0bcd11eb 524$xtra .= <<<HEREDOC
525 if (right) {
526 new_col = '*,'+c_w;
527 } else {
528 new_col = c_w+',*';
529 }
530 return new_col;
531 }
532 function resizeframe(direction) {
533 if (document.all) {
534 masterf = window.parent.document.all["fs1"];
535 } else if (document.getElementById) {
536 window.parent.document.getElementById("fs1");
537 } else {
538 return false;
539 }
540HEREDOC;
599038d5 541 if ($location_of_bar == 'right') {
542 $xtra .= ' colPat=/^\*,(\d+)$/;';
a6172cd5 543 } else {
599038d5 544 $xtra .= ' colPat=/^(\d+),.*$/;';
545 }
0bcd11eb 546$xtra .= <<<HEREDOC
547 old_col = masterf.cols;
548 colPat.exec(old_col);
549 if (direction) {
550 new_col_width = parseInt(RegExp.$1) + 25;
551 } else {
552 if (parseInt(RegExp.$1) > 35) {
553 new_col_width = parseInt(RegExp.$1) - 25;
554 }
555 }
556 masterf.cols = calc_col(new_col_width);
557 }
558//-->
559</script>
560
561HEREDOC;
f23f6a3a 562
563/* style definitions */
386e556f 564
0bcd11eb 565$xtra .= <<<HEREDOC
566<style type="text/css">
567<!--
568 body {
569 margin: 0px 0px 0px 0px;
570 padding: 5px 5px 5px 5px;
571 }
572 img {
573 vertical-align: middle;
574 }
575 .button {
576 border:outset;
577 border-color: $color[9];
578 background:$color[0];
579 color:$color[6];
580 width:99%;
581 heigth:99%;
582 }
583 .mbx_par {
584 font-size:1.0em;
585 margin-left:4px;
586 margin-right:0px;
587 white-space: nowrap;
588 }
589 a.mbx_link {
590 text-decoration: none;
591 background-color: $color[0];
592 display: inline;
593 }
594 a:hover.mbx_link {
595 background-color: $color[9];
596 }
597 a.mbx_link img {
598 border-style: none;
599 }
600 .mbx_sub {
601 padding-left:5px;
602 padding-right:0px;
603 margin-left:4px;
604 margin-right:0px;
605 font-size:0.9em;
606 white-space: nowrap;
607 }
608 .par_area {
609 margin-top:0px;
610 margin-left:4px;
611 margin-right:0px;
612 padding-left:10px;
613 padding-bottom:5px;
614 border-left: solid;
615 border-left-width:0.1em;
616 border-left-color:$color[9];
617 border-bottom: solid;
618 border-bottom-width:0.1em;
619 border-bottom-color:$color[9];
620 display: block;
621 }
622 .mailboxes {
623 padding-bottom:3px;
624 margin-right:4px;
625 padding-right:4px;
626 margin-left:4px;
627 padding-left:4px;
628 border: groove;
629 border-width:0.1em;
630 border-color:$color[9];
631 background: $color[0];
632 font-size: smaller;
633 }
634-->
635</style>
636
637HEREDOC;
f23f6a3a 638}
639
a462b928 640// get mailbox list and cache it
641$mailboxes=sqimap_get_mailboxes($imapConnection,false,$show_only_subscribed_folders);
642
dcc1cc82 643displayHtmlHeader( 'SquirrelMail', $xtra );
a462b928 644
852abae7 645sqgetGlobalVar('auto_create_done',$auto_create_done,SQ_SESSION);
95e93571 646/* If requested and not yet complete, attempt to autocreate folders. */
647if ($auto_create_special && !isset($auto_create_done)) {
a3439b27 648 $autocreate = array($sent_folder, $trash_folder, $draft_folder);
95e93571 649 foreach( $autocreate as $folder ) {
a3439b27 650 if (($folder != '') && ($folder != 'none')) {
a462b928 651 // use $mailboxes array for checking if mailbox exists
652 if ( !sqimap_mailbox_exists($imapConnection, $folder, $mailboxes)) {
95e93571 653 sqimap_mailbox_create($imapConnection, $folder, '');
852abae7 654 } else {
7b1f03c9 655 // check for subscription is useless and expensive, just
656 // surpress the NO response. Unless we're on Mecury, which
657 // will just subscribe a folder again if it's already
658 // subscribed.
659 if ( strtolower($imap_server_type) != 'mercury32' ||
660 !sqimap_mailbox_is_subscribed($imapConnection, $folder) ) {
661 sqimap_subscribe($imapConnection, $folder, false);
662 }
2d367c68 663 }
ebf18afa 664 }
2d367c68 665 }
a6d2e0de 666
95e93571 667 /* Let the world know that autocreation is complete! Hurrah! */
90de1755 668 $auto_create_done = TRUE;
a32985a5 669 sqsession_register($auto_create_done, 'auto_create_done');
95e93571 670}
dcc1cc82 671
134e4174 672if ($advanced_tree) {
673 echo "\n<body" .
674 ' onload="preload(\'../images/minus.png\',\'../images/plus.png\')"' .
81132de8 675 " class=\"leftmain\">\n<div class=\"leftmain\">\n";
134e4174 676} else {
81132de8 677 echo "\n<body class=\"leftmain\">\n<div class=\"leftmain\">\n";
134e4174 678}
dcc1cc82 679
680do_hook('left_main_before');
681if ($advanced_tree) {
682 /* nice future feature, needs layout !! volunteers? */
683 $right_pos = $left_size - 20;
39bfea8f 684/* 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>';
685 echo '<div id="showf" style="width=20;font-size:12;display:none;"><a href="javascript:hideframe(false)"><b>&gt;&gt;</b></a></div>';
686 echo '<div id="incrf" style="width=20;font-size:12"><a href="javascript:resizeframe(true)"><b>&gt;</b></a></div>';
687 echo '<div id="decrf" style="width=20;font-size:12"><a href="javascript:resizeframe(false)"><b>&lt;</b></a></div></div>';
688 echo '<div id="leftframe"><br /><br />';*/
599038d5 689}
dcc1cc82 690
ba4c6392 691echo "\n\n" . html_tag( 'table', '', 'left', '', 'border="0" cellspacing="0" cellpadding="0" width="99%"' ) .
692 html_tag( 'tr' ) .
693 html_tag( 'td', '', 'left' ) .
694 html_tag( 'table', '', '', '', 'border="0" cellspacing="0" cellpadding="0"' ) .
695 html_tag( 'tr' ) .
696 html_tag( 'td', '', 'center' ) .
697 '<font size="4"><b>'. _("Folders") . "</b><br /></font>\n\n";
a6d2e0de 698
95e93571 699if ($date_format != 6) {
700 /* First, display the clock. */
701 if ($hour_format == 1) {
3208c2a5 702 $hr = 'H:i';
95e93571 703 if ($date_format == 4) {
704 $hr .= ':s';
a6d2e0de 705 }
95e93571 706 } else {
707 if ($date_format == 4) {
708 $hr = 'g:i:s a';
709 } else {
710 $hr = 'g:i a';
2d367c68 711 }
712 }
713
95e93571 714 switch( $date_format ) {
e4f5158a 715 case 0:
134e4174 716 $clk = date('Y-m-d '.$hr. ' T', time());
717 break;
95e93571 718 case 1:
719 $clk = date('m/d/y '.$hr, time());
720 break;
721 case 2:
722 $clk = date('d/m/y '.$hr, time());
723 break;
724 case 4:
725 case 5:
726 $clk = date($hr, time());
727 break;
728 default:
67eb95d7 729 $clk = getDayAbrv( date( 'w', time() ) ) . date( ', ' . $hr, time() );
2d367c68 730 }
95e93571 731 $clk = str_replace(' ','&nbsp;',$clk);
732
f8a1ed5a 733 echo '<small><span style="white-space: nowrap;">'
734 . str_replace(' ', '&nbsp;', _("Last Refresh"))
3cbf882e 735 . ":</span><br /><span style=\"white-space: nowrap;\">$clk</span></small><br />\n";
95e93571 736}
737
738/* Next, display the refresh button. */
c435f076 739echo '<div style="white-space: nowrap;"><small>[<a href="../src/left_main.php" target="left">'.
ba4c6392 740 _("Check mail") . "</a>]</small></div></td></tr></table><br />\n\n";
95e93571 741
742/* Lastly, display the folder list. */
a1a39832 743
95e93571 744if ( $collapse_folders ) {
745 /* If directed, collapse or uncollapse a folder. */
746 if (isset($fold)) {
747 setPref($data_dir, $username, 'collapse_folder_' . $fold, SM_BOX_COLLAPSED);
748 } else if (isset($unfold)) {
749 setPref($data_dir, $username, 'collapse_folder_' . $unfold, SM_BOX_UNCOLLAPSED);
750 }
751}
752
c5a52f46 753/* Get unseen/total display prefs */
754$unseen_type = getPref( $data_dir , $username , 'unseen_type' );
755$unseen_notify = getPref( $data_dir , $username , 'unseen_notify' );
756
3cbf882e 757if (empty($unseen_type)) {
758 if (!empty($default_unseen_type)) {
c5a52f46 759 $unseen_type = $default_unseen_type;
760 } else {
761 $unseen_type = 1;
762 }
763}
764
3cbf882e 765if (empty($unseen_notify)) {
766 if (!empty($default_unseen_notify)) {
c5a52f46 767 $unseen_notify = $default_unseen_notify;
768 } else {
769 $unseen_notify = 0;
770 }
771}
a462b928 772/**
773 * pass $mailboxes now instead of $imapconnection - sqimap_get_mailboxes() has been separated from
774 * sqimap_mailbox_tree() so that the cached mailbox list can be used elsewhere in left_main and beyond
775 */
776$boxes = sqimap_mailbox_tree($imapConnection,$mailboxes,$show_only_subscribed_folders);
c5a52f46 777
3cbf882e 778if (isset($advanced_tree) && $advanced_tree) {
779 echo '<form name="collapse" action="left_main.php" method="post" ' .
0bcd11eb 780 'enctype="multipart/form-data">'."\n";
3cbf882e 781 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 />';
782 echo '<div id="mailboxes" class="mailboxes">'."\n\n";
783 sqgetGlobalVar('mbx', $mbx, SQ_POST);
784 if (!isset($mbx)) $mbx=NULL;
785 ListAdvancedBoxes($boxes, $mbx);
786 echo '</div>';
3cbf882e 787 echo '</form>'."\n";
788} else {
789 ListBoxes($boxes);
95e93571 790}
791
dcc1cc82 792do_hook('left_main_after');
793sqimap_logout($imapConnection);
794
39bfea8f 795?>
ba4c6392 796</td></tr></table>
5c4ff7bf 797</div>
798<?php
799$oTemplate->display('footer.tpl');
800?>