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