since comments are not needed for @return
[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 }
127 if ($unseen > 0) {
128 $pre .= '<b>';
129 }
324ac3c5 130 $pre .= "<a href=\"right_main.php?PG_SHOWALL=0&amp;startMessage=1&amp;mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\">";
c435f076 131 $end .= '</a>';
ccc4580f 132 if ($unseen > 0) {
133 $end .= '</b>';
134 }
ccc4580f 135 if ($boxes->total > 0) {
e4c5976a 136 if ($unseen > 0) {
137 $pre .= '<b>';
138 }
324ac3c5 139 $pre .= "<a href=\"right_main.php?PG_SHOWALL=0&amp;startMessage=1&amp;mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\">";
e4c5976a 140 if ($unseen > 0) {
141 $end .= '</b>';
142 }
3170c448 143 /* Print unseen information. */
ccc4580f 144 if ($unseen_found) {
3170c448 145 $end .= "&nbsp;<small>$unseen_string</small>";
146 }
e4c5976a 147 }
3cbf882e 148 $end .= "\n\t<small>" .
dea5ef88 149 '&nbsp;&nbsp;[<a href="empty_trash.php">'._("Purge").'</a>]'.
150 '</small>';
ccc4580f 151 } else {
152 if (!$boxes->is_noselect) {
153 if ($unseen > 0) {
154 $pre .= '<b>';
155 }
324ac3c5 156 $pre .= "<a href=\"right_main.php?PG_SHOWALL=0&amp;startMessage=1&amp;mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\">";
c435f076 157 $end .= '</a>';
ccc4580f 158 if ($unseen > 0) {
159 $end .= '</b>';
160 }
e4c5976a 161 }
ccc4580f 162 /* Print unseen information. */
163 if ($unseen_found) {
164 $end .= "&nbsp;<small>$unseen_string</small>";
39027844 165 }
166
ccc4580f 167 }
168
169 $font = '';
170 $fontend = '';
a259636c 171 if ($use_special_folder_color && $boxes->is_special) {
ccc4580f 172 $font = "<font color=\"$color[11]\">";
173 $fontend = "</font>";
3cbf882e 174 } elseif ( $boxes->is_noselect ) {
175 $font = "<font color=\"$color[15]\">";
176 $fontend = '</font>';
ccc4580f 177 }
3cbf882e 178
8fc208f8 179 // let plugins fiddle with end of line
180 $end .= concat_hook_function('left_main_after_each_folder',
324ac3c5 181 array(isset($numMessages) ? $numMessages : '',
8fc208f8 182 $boxes->mailboxname_full, $imapConnection));
183
8ad1c1e8 184 $end .= '</span>';
ccc4580f 185
186 if (!$boxes->is_root) {
3cbf882e 187 echo "" . $pre .$font.
188 str_replace(
189 array(' ','<','>'),
190 array('&nbsp;','&lt;','&gt;'),
191 $boxes->mailboxname_sub) .
192 $fontend . $end. '<br />' . "\n";
ccc4580f 193 $j++;
194 }
195
196 if (!$collapse || $boxes->is_root) {
197 for ($i = 0; $i <count($boxes->mbxs); $i++) {
3cbf882e 198 ListBoxes($boxes->mbxs[$i],$j);
e4c5976a 199 }
f23f6a3a 200 }
201}
202
c8fa94cf 203function ListAdvancedBoxes ($boxes, $mbx, $j='ID.0000' ) {
ce68b76b 204 global $data_dir, $username, $color, $unseen_notify, $unseen_type,
134e4174 205 $move_to_trash, $trash_folder, $collapse_folders, $use_special_folder_color;
f23f6a3a 206
3cbf882e 207 if (empty($boxes)) {
ccc4580f 208 return;
3cbf882e 209 }
4bdcd5e0 210
f23f6a3a 211 /* use_folder_images only works if the images exist in ../images */
c8fa94cf 212 $use_folder_images = true;
f23f6a3a 213
214 $pre = '';
215 $end = '';
216 $collapse = false;
6c8fee24 217 $unseen_found = false;
218 $unseen = 0;
a6172cd5 219
a6172cd5 220 $mailbox = $boxes->mailboxname_full;
221 $mailboxURL = urlencode($mailbox);
f23f6a3a 222
ccc4580f 223 /* get unseen/total messages information */
6c8fee24 224 /* Only need to display info when option is set */
ccc4580f 225 if (isset($unseen_notify) && ($unseen_notify > 1) &&
226 (($boxes->unseen !== false) || ($boxes->total !== false))) {
6c8fee24 227
51ea258b 228 if ($boxes->unseen !== false)
6c8fee24 229 $unseen = $boxes->unseen;
6c8fee24 230
ccc4580f 231 /*
6c8fee24 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
6c8fee24 239 /* If users requests, display message count too */
ccc4580f 240 if (isset($unseen_type) && ($unseen_type == 2) && ($boxes->total !== false)) {
51ea258b 241 $unseen_string .= '/' . $boxes->total;
ccc4580f 242 }
6c8fee24 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 }
ccc4580f 254 }
6c8fee24 255 }
a6172cd5 256
257 /* If there are unseen message, bold the line. */
258 if ($unseen > 0) { $pre .= '<b>'; }
259
260 /* color special boxes */
a259636c 261 if ($use_special_folder_color && $boxes->is_special) {
4bdcd5e0 262 $pre .= "<font color=\"$color[11]\">";
a6172cd5 263 $end .= '</font>';
264 }
265
266 /* If there are unseen message, close bolding. */
267 if ($unseen > 0) { $end .= '</b>'; }
268
269 /* Print unseen information. */
ccc4580f 270 if ($unseen_found) {
271 $end .= "&nbsp;$unseen_string";
a6172cd5 272 }
273
274 if (($move_to_trash) && ($mailbox == $trash_folder)) {
324ac3c5 275 $pre = "<a class=\"mbx_link\" href=\"right_main.php?PG_SHOWALL=0&amp;startMessage=1&amp;mailbox=$mailboxURL\" target=\"right\">" . $pre;
4bdcd5e0 276 $end .= '</a>';
dea5ef88 277 $end .= "\n<small>\n" .
278 '&nbsp;&nbsp;[<a class="mbx_link" href="empty_trash.php">'._("Purge").'</a>]'.
279 '</small>';
a6172cd5 280 } else {
281 if (!$boxes->is_noselect) { /* \Noselect boxes can't be selected */
324ac3c5 282 $pre = "<a class=\"mbx_link\" href=\"right_main.php?PG_SHOWALL=0&amp;startMessage=1&amp;mailbox=$mailboxURL\" target=\"right\">" . $pre;
4bdcd5e0 283 $end .= '</a>';
a6172cd5 284 }
285 }
286
8fc208f8 287 // let plugins fiddle with end of line
288 global $imapConnection;
289 $end .= concat_hook_function('left_main_after_each_folder',
324ac3c5 290 array(isset($numMessages) ? $numMessages : '',
8fc208f8 291 $boxes->mailboxname_full, $imapConnection));
292
a6172cd5 293 if (!$boxes->is_root) {
294 if ($use_folder_images) {
ccc4580f 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 }
a6172cd5 312 if (!isset($boxes->mbxs[0])) {
313 echo ' ' . html_tag( 'div',
3cbf882e 314 '<tt>'. $pre . $folder_img . '</tt>' .
315 str_replace( array(' ','<','>'),
316 array('&nbsp;','&lt;','&gt;'),
317 $boxes->mailboxname_sub) .
318 $end,
3170c448 319 'left', '', 'class="mbx_sub" id="' .$j. '"' ) . "\n";
ccc4580f 320 } else {
a6172cd5 321 /* get collapse information */
3170c448 322 if ($collapse_folders) {
323 $form_entry = $j.'F';
324 if (isset($mbx) && isset($mbx[$form_entry])) {
325 $collapse = $mbx[$form_entry];
3cbf882e 326 setPref($data_dir, $username, 'collapse_folder_'.$boxes->mailboxname_full ,
327 $collapse ? SM_BOX_COLLAPSED : SM_BOX_UNCOLLAPSED);
ccc4580f 328 } else {
3170c448 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');
3cbf882e 333 $collapse_link = '<a href="javascript:void(0)">' .
334 " <img src=\"$img_src\" border=\"1\" id=$j onclick=\"hidechilds(this)\" style=\"cursor:hand\" /></a>";
ccc4580f 335 } else {
3170c448 336 $collapse_link='';
ccc4580f 337 }
338 echo ' ' . html_tag( 'div',
a6172cd5 339 $collapse_link . $pre . $folder_img . '&nbsp;'. $boxes->mailboxname_sub . $end ,
3170c448 340 'left', '', 'class="mbx_par" id="' .$j. 'P"' ) . "\n";
ccc4580f 341 echo ' <input type="hidden" name="mbx['.$j. 'F]" value="'.$collapse.'" id="mbx['.$j.'F]" />'."\n";
a6172cd5 342 }
343 }
a6172cd5 344
4bdcd5e0 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";
a6172cd5 348
3cbf882e 349 if ($j !='ID.0000') {
4bdcd5e0 350 $j = $j .'.0000';
3cbf882e 351 }
4bdcd5e0 352 for ($i = 0; $i <count($boxes->mbxs); $i++) {
353 $j++;
354 ListAdvancedBoxes($boxes->mbxs[$i],$mbx,$j);
f23f6a3a 355 }
3cbf882e 356 if (isset($boxes->mbxs[0]) && !$boxes->is_root) {
4bdcd5e0 357 echo '</div>'."\n\n";
3cbf882e 358 }
f23f6a3a 359}
360
361
362
95e93571 363
364/* -------------------- MAIN ------------------------ */
365
f38b7cf0 366/* get globals */
367sqgetGlobalVar('username', $username, SQ_SESSION);
368sqgetGlobalVar('key', $key, SQ_COOKIE);
369sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION);
370sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION);
a32985a5 371
f38b7cf0 372sqgetGlobalVar('fold', $fold, SQ_GET);
373sqgetGlobalVar('unfold', $unfold, SQ_GET);
374
375/* end globals */
95e93571 376
377// open a connection on the imap port (143)
3cbf882e 378// why hide the output?
379$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, true);
95e93571 380
f43c35f8 381/**
3cbf882e 382 * Using stristr since very old preferences may contain "None" and "none".
f43c35f8 383 */
3cbf882e 384if (!empty($left_refresh) &&
d68323ff 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".
dcc1cc82 388 "<meta http-equiv=\"REFRESH\" content=\"$left_refresh;URL=left_main.php\" />\n";
95e93571 389} else {
390 $xtra = '';
391}
392
f23f6a3a 393/**
3cbf882e 394 * $advanced_tree and is a boolean var which is default set to default
a6172cd5 395 * SM behaviour.
a6172cd5 396 * Setting $advanced tree to true causes SM to display a experimental
f23f6a3a 397 * mailbox-tree with dhtml behaviour.
a6172cd5 398 * It only works on browsers which supports css and javascript. The used
c72be5a6 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: ?
f23f6a3a 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.
a6172cd5 407 *
f23f6a3a 408 * Feel free to experiment with the code and report bugs and enhancements
a6172cd5 409 **/
f23f6a3a 410
78e5377d 411/* set this to true if you want to see a nicer mailboxtree */
3cbf882e 412if (empty($advanced_tree)) {
ccc4580f 413 $advanced_tree=false;
414}
f23f6a3a 415
416if ($advanced_tree) {
2b5e4e10 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";
f23f6a3a 526
599038d5 527 if ($location_of_bar == 'right') {
528 $xtra .= ' right=true;';
a6172cd5 529 } else {
599038d5 530 $xtra .= ' right=false;';
531 }
532 $xtra .= "\n";
a6172cd5 533
2b5e4e10 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";
a6172cd5 549
599038d5 550 if ($location_of_bar == 'right') {
551 $xtra .= ' colPat=/^\*,(\d+)$/;';
a6172cd5 552 } else {
599038d5 553 $xtra .= ' colPat=/^(\d+),.*$/;';
554 }
555 $xtra .= "\n";
a6172cd5 556
2b5e4e10 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";
f23f6a3a 570
571/* style definitions */
386e556f 572
2b5e4e10 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";
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
3cbf882e 685echo "\n\n" .
686 '<center><font size="4"><b>'. _("Folders") . "</b><br /></font>\n\n";
a6d2e0de 687
95e93571 688if ($date_format != 6) {
689 /* First, display the clock. */
690 if ($hour_format == 1) {
3208c2a5 691 $hr = 'H:i';
95e93571 692 if ($date_format == 4) {
693 $hr .= ':s';
a6d2e0de 694 }
95e93571 695 } else {
696 if ($date_format == 4) {
697 $hr = 'g:i:s a';
698 } else {
699 $hr = 'g:i a';
2d367c68 700 }
701 }
702
95e93571 703 switch( $date_format ) {
e4f5158a 704 case 0:
134e4174 705 $clk = date('Y-m-d '.$hr. ' T', time());
706 break;
95e93571 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:
67eb95d7 718 $clk = getDayAbrv( date( 'w', time() ) ) . date( ', ' . $hr, time() );
2d367c68 719 }
95e93571 720 $clk = str_replace(' ','&nbsp;',$clk);
721
b9f75857 722 echo '<small><span style="white-space: nowrap;">'
723 . str_replace(' ', '&nbsp;', _("Last Refresh"))
3cbf882e 724 . ":</span><br /><span style=\"white-space: nowrap;\">$clk</span></small><br />\n";
95e93571 725}
726
727/* Next, display the refresh button. */
c435f076 728echo '<div style="white-space: nowrap;"><small>[<a href="../src/left_main.php" target="left">'.
3cbf882e 729 _("Check mail") . "</a>]</small></div></center><br />\n\n";
95e93571 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
c5a52f46 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
3cbf882e 745if (empty($unseen_type)) {
746 if (!empty($default_unseen_type)) {
c5a52f46 747 $unseen_type = $default_unseen_type;
748 } else {
749 $unseen_type = 1;
750 }
751}
752
3cbf882e 753if (empty($unseen_notify)) {
754 if (!empty($default_unseen_notify)) {
c5a52f46 755 $unseen_notify = $default_unseen_notify;
756 } else {
757 $unseen_notify = 0;
758 }
759}
760
3cbf882e 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);
95e93571 776}
777
dcc1cc82 778do_hook('left_main_after');
779sqimap_logout($imapConnection);
780
39bfea8f 781?>
3208c2a5 782</body></html>