htmlspecialvars bodystructure
[squirrelmail.git] / src / left_main.php
CommitLineData
59177427 1<?php
895905c0 2
35586184 3/**
4 * left_main.php
5 *
15e6162e 6 * Copyright (c) 1999-2002 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 *
12 * $Id$
1c52ba77 13 */
35586184 14
15require_once('../src/validate.php');
16require_once('../functions/array.php');
17require_once('../functions/imap.php');
18require_once('../functions/plugin.php');
19require_once('../functions/page_header.php');
3fde693b 20require_once('../functions/html.php');
142499d4 21
95e93571 22/* These constants are used for folder stuff. */
23define('SM_BOX_UNCOLLAPSED', 0);
24define('SM_BOX_COLLAPSED', 1);
a6d2e0de 25
2d367c68 26/* --------------------- FUNCTIONS ------------------------- */
525b7ae6 27
95e93571 28function formatMailboxName($imapConnection, $box_array) {
1c52ba77 29
90de1755 30 global $folder_prefix, $trash_folder, $sent_folder,
31 $color, $move_to_sent, $move_to_trash,
32 $unseen_notify, $unseen_type, $collapse_folders,
33 $draft_folder, $save_as_draft,
34 $use_special_folder_color;
94f3a73b 35
95e93571 36 $real_box = $box_array['unformatted'];
37 $mailbox = str_replace('&nbsp;','',$box_array['formatted']);
38 $mailboxURL = urlencode($real_box);
21c3249f 39
95e93571 40 /* Strip down the mailbox name. */
41 if (ereg("^( *)([^ ]*)$", $mailbox, $regs)) {
42 $mailbox = $regs[2];
43 }
94f3a73b 44
95e93571 45 $unseen = 0;
46
47 if (($unseen_notify == 2 && $real_box == 'INBOX') ||
48 $unseen_notify == 3) {
49 $unseen = sqimap_unseen_messages($imapConnection, $real_box);
50 if ($unseen_type == 1 && $unseen > 0) {
51 $unseen_string = "($unseen)";
90de1755 52 $unseen_found = TRUE;
95e93571 53 } else if ($unseen_type == 2) {
54 $numMessages = sqimap_get_num_messages($imapConnection, $real_box);
55 $unseen_string = "<font color=\"$color[11]\">($unseen/$numMessages)</font>";
90de1755 56 $unseen_found = TRUE;
94f3a73b 57 }
95e93571 58 }
94f3a73b 59
1c52ba77 60 $special_color = ($use_special_folder_color && isSpecialMailbox( $real_box ) );
f7b1b3b1 61
95e93571 62 /* Start off with a blank line. */
63 $line = '';
235a65d5 64
95e93571 65 /* If there are unseen message, bold the line. */
66 if ($unseen > 0) { $line .= '<B>'; }
a6d2e0de 67
95e93571 68 /* Crate the link for this folder. */
3fde693b 69 $line .= "<a href=\"right_main.php?PG_SHOWALL=0&amp;sort=0&amp;startMessage=1&amp;mailbox=$mailboxURL\" TARGET=\"right\" STYLE=\"text-decoration:none\">";
1c52ba77 70 if ($special_color) {
3fde693b 71 $line .= "<font color=\"$color[11]\">";
1c52ba77 72 }
a551489c 73 if ( $mailbox == 'INBOX' ) {
74 $line .= _("INBOX");
75 } else {
76 $line .= str_replace(' ','&nbsp;',$mailbox);
77 }
90de1755 78 if ($special_color == TRUE)
3fde693b 79 $line .= '</font>';
80 $line .= '</a>';
a6d2e0de 81
95e93571 82 /* If there are unseen message, close bolding. */
83 if ($unseen > 0) { $line .= "</B>"; }
2d367c68 84
95e93571 85 /* Print unseen information. */
86 if (isset($unseen_found) && $unseen_found) {
87 $line .= "&nbsp;<SMALL>$unseen_string</SMALL>";
2016e645 88 }
89
1c52ba77 90 if (($move_to_trash) && ($real_box == $trash_folder)) {
95e93571 91 if (! isset($numMessages)) {
92 $numMessages = sqimap_get_num_messages($imapConnection, $real_box);
a6d2e0de 93 }
a6d2e0de 94
95e93571 95 if ($numMessages > 0) {
96 $urlMailbox = urlencode($real_box);
97 $line .= "\n<small>\n" .
eb3b5319 98 "&nbsp;&nbsp;(<A HREF=\"empty_trash.php\" style=\"text-decoration:none\">"._("purge")."</A>)" .
7fb54066 99 "</small>";
a6d2e0de 100 }
101 }
a6d2e0de 102
95e93571 103 /* Return the final product. */
104 return ($line);
105}
a6d2e0de 106
95e93571 107/**
108 * Recursive function that computes the collapsed status and parent
109 * (or not parent) status of this box, and the visiblity and collapsed
110 * status and parent (or not parent) status for all children boxes.
111 */
112function compute_folder_children(&$parbox, $boxcount) {
113 global $boxes, $data_dir, $username, $collapse_folders;
114 $nextbox = $parbox + 1;
115
116 /* Retreive the name for the parent box. */
117 $parbox_name = $boxes[$parbox]['unformatted'];
118
119 /* 'Initialize' this parent box to childless. */
1c52ba77 120 $boxes[$parbox]['parent'] = FALSE;
95e93571 121
122 /* Compute the collapse status for this box. */
123 if( isset($collapse_folders) && $collapse_folders ) {
124 $collapse = getPref($data_dir, $username, 'collapse_folder_' . $parbox_name);
125 $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED : $collapse);
126 } else {
127 $collapse = SM_BOX_UNCOLLAPSED;
a6d2e0de 128 }
95e93571 129 $boxes[$parbox]['collapse'] = $collapse;
2d367c68 130
95e93571 131 /* Otherwise, get the name of the next box. */
1c52ba77 132 if (isset($boxes[$nextbox]['unformatted'])) {
95e93571 133 $nextbox_name = $boxes[$nextbox]['unformatted'];
1c52ba77 134 } else {
95e93571 135 $nextbox_name = '';
1c52ba77 136 }
a6d2e0de 137
95e93571 138 /* Compute any children boxes for this box. */
139 while (($nextbox < $boxcount) &&
140 (is_parent_box($boxes[$nextbox]['unformatted'], $parbox_name))) {
a6d2e0de 141
95e93571 142 /* Note that this 'parent' box has at least one child. */
1c52ba77 143 $boxes[$parbox]['parent'] = TRUE;
a6d2e0de 144
95e93571 145 /* Compute the visiblity of this box. */
1c52ba77 146 $boxes[$nextbox]['visible'] = ($boxes[$parbox]['visible'] &&
147 ($boxes[$parbox]['collapse'] != SM_BOX_COLLAPSED));
a6d2e0de 148
95e93571 149 /* Compute the visibility of any child boxes. */
150 compute_folder_children($nextbox, $boxcount);
151 }
2d367c68 152
95e93571 153 /* Set the parent box to the current next box. */
154 $parbox = $nextbox;
155}
2d367c68 156
95e93571 157/**
158 * Create the link for a parent folder that will allow that
159 * parent folder to either be collapsed or expaned, as is
160 * currently appropriate.
161 */
162function create_collapse_link($boxnum) {
163 global $boxes;
164 $mailbox = urlencode($boxes[$boxnum]['unformatted']);
165
166 /* Create the link for this collapse link. */
90de1755 167 $link = '<a target="left" style="text-decoration:none" ' .
168 'href="left_main.php?';
95e93571 169 if ($boxes[$boxnum]['collapse'] == SM_BOX_COLLAPSED) {
170 $link .= "unfold=$mailbox\">+";
2d367c68 171 } else {
95e93571 172 $link .= "fold=$mailbox\">-";
2d367c68 173 }
95e93571 174 $link .= '</a>';
2d367c68 175
95e93571 176 /* Return the finished product. */
177 return ($link);
178}
179
180/**
181 * This simple function checks if a box is another box's parent.
182 */
183function is_parent_box($curbox_name, $parbox_name) {
184 global $delimiter;
185
186 /* Extract the name of the parent of the current box. */
187 $curparts = explode($delimiter, $curbox_name);
188 $curname = array_pop($curparts);
189 $actual_parname = implode($delimiter, $curparts);
190 $actual_parname = substr($actual_parname,0,strlen($parbox_name));
191
192 /* Compare the actual with the given parent name. */
193 return ($parbox_name == $actual_parname);
194}
195
f23f6a3a 196function listBoxes ($boxes, $j=0 ) {
197 global $data_dir, $username, $startmessage, $color, $unseen_notify, $unseen_type,
198 $move_to_trash, $trash_folder, $collapse_folders;
199 $pre = '';
200 $end = '';
201 $collapse = false;
202 if ($boxes) {
203 $mailbox = $boxes->mailboxname_full;
204 $leader = '';
205 for ($k = 0; $k < $j; $k++) {
206 $leader.= '&nbsp&nbsp&nbsp';
207 }
208 $mailboxURL = urlencode($mailbox);
209
210 /* get unseen/total messages information */
211 if ($boxes->unseen) {
212 $unseen = $boxes->unseen;
213 $unseen_string = "($unseen)";
214 if ($unseen>0) $unseen_found = TRUE;
215 if ($boxes->total) {
216 $numMessages = $boxes->total;
217 $unseen_string = "<font color=\"$color[11]\">($unseen/$numMessages)</font>";
218 }
219 } else $unseen = 0;
220
221
222
223 if (isset($boxes->mbxs[0]) && $collapse_folders) {
224 $collapse = getPref($data_dir, $username, 'collapse_folder_' . $mailbox);
225 $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED : $collapse);
226
227 $link = '<a target="left" style="text-decoration:none" ' .'href="left_main.php?';
228 if ($collapse) {
229 $link .= "unfold=$mailboxURL\">$leader +&nbsp";
230 } else {
231 $link .= "fold=$mailboxURL\">$leader -&nbsp";
232 }
233 $link .= '</a>';
234 $pre .= $link;
235 } else {
236 $pre.= $leader . '&nbsp&nbsp&nbsp';
237 }
238
239
240 /* If there are unseen message, bold the line. */
241 if ($unseen > 0) { $pre .= '<B>'; }
242
243 if (($move_to_trash) && ($mailbox == $trash_folder)) {
244 if (! isset($numMessages)) {
245 $numMessages = sqimap_get_num_messages($imapConnection, $mailbox);
246 }
247
248 if ($numMessages > 0) {
249 $urlMailbox = urlencode($mailbox);
250 $pre .= "\n<small>\n" .
251 "&nbsp;&nbsp;(<A HREF=\"empty_trash.php\" style=\"text-decoration:none\">"._("purge")."</A>)" .
252 "</small>";
253 }
254 } else {
255 if (!$boxes->is_noselect) {
256 $pre .= "<A HREF=\"right_main.php?PG_SHOWALL=0&amp;sort=0&amp;startMessage=1&amp;mailbox=$mailboxURL\" TARGET=\"right\" STYLE=\"text-decoration:none\">";
257 $end .= '</a>';
258 }
259 }
260
261 /* If there are unseen message, close bolding. */
262 if ($unseen > 0) { $end .= "</B>"; }
263
264 /* Print unseen information. */
265 if (isset($unseen_found) && $unseen_found) {
266 $end .= "&nbsp;<SMALL>$unseen_string</SMALL>";
267 }
268
269 $font = '';
270 $fontend = '';
271 if ($boxes->is_special) {
272 $font = "<FONT COLOR=\"$color[11]\">";
273 $fontend = "</FONT>";
274 }
275
276 if (!$boxes->is_root) {
277 echo "" . $pre .$font. $boxes->mailboxname_sub .$fontend . $end. '<br>';
278 $j++;
279 }
280 if (!$collapse || $boxes->is_root) {
281 for ($i = 0; $i <count($boxes->mbxs); $i++) {
282 listBoxes($boxes->mbxs[$i],$j);
283 }
284 }
285
286 }
287}
288
289function ListAdvancedBoxes ($boxes, $mbx, $j='ID.0' ) {
290 global $data_dir, $username, $startmessage, $color, $unseen_notify, $unseen_type,
291 $move_to_trash, $trash_folder, $collapse_folders;
292
293 /* use_folder_images only works if the images exist in ../images */
294 $use_folder_images = false;
295
296 $pre = '';
297 $end = '';
298 $collapse = false;
299
300 if ($boxes) {
301 $mailbox = $boxes->mailboxname_full;
302 $mailboxURL = urlencode($mailbox);
303
304 /* get unseen/total messages information */
305 if ($boxes->unseen) {
306 $unseen = $boxes->unseen;
307 $unseen_string = "($unseen)";
308 if ($unseen>0) $unseen_found = TRUE;
309 if ($boxes->total) {
310 $numMessages = $boxes->total;
311 $unseen_string = "<font color=\"$color[11]\">($unseen/$numMessages)</font>";
312 }
313 } else $unseen = 0;
314
315
316 /* If there are unseen message, bold the line. */
317 if ($unseen > 0) { $pre .= '<B>'; }
318
319 if (($move_to_trash) && ($mailbox == $trash_folder)) {
320 if (! isset($numMessages)) {
321 $numMessages = $boxes->total;
322 }
323 if ($numMessages > 0) {
324 $urlMailbox = urlencode($mailbox);
325 $pre .= "\n<small>\n" .
326 "&nbsp;&nbsp;(<A HREF=\"empty_trash.php\" style=\"text-decoration:none\">"._("purge")."</A>)" .
327 "</small>";
328 }
329 } else {
330 if (!$boxes->is_noselect) { /* \Noselect boxes can't be selected */
331 $pre .= "<A HREF=\"right_main.php?PG_SHOWALL=0&amp;sort=0&amp;startMessage=1&amp;mailbox=$mailboxURL\" TARGET=\"right\" STYLE=\"text-decoration:none\">";
332 $end .= '</a>';
333 }
334 }
335
336 /* If there are unseen message, close bolding. */
337 if ($unseen > 0) { $end .= "</B>"; }
338
339 /* Print unseen information. */
340 if (isset($unseen_found) && $unseen_found) {
341 $end .= "&nbsp;<SMALL>$unseen_string</SMALL>";
342 }
343
344 $font = '';
345 $fontend = '';
346
347 /* color special boxes */
348 if ($boxes->is_special) {
349 $font = "<FONT COLOR=\"$color[11]\">";
350 $fontend = "</FONT>";
351 }
352 if (!$boxes->is_root) {
353 if ($use_folder_images) {
354 if ($boxes->is_inbox) {
355 $folder_img = '../images/inbox.gif';
356 } else if ($boxes->is_sent) {
357 $folder_img = '../images/senti.gif';
358 } else if ($boxes->is_trash) {
359 $folder_img = '../images/delitem.gif';
360 } else if ($boxes->is_draft) {
361 $folder_img = '../images/draft.gif';
362 } else $folder_img = '../images/folder.gif';
363 $folder_img = '&nbsp<img src="'.$folder_img.'" heigth="15" valign="center">&nbsp';
364 } else $folder_img = '';
365 if (!isset($boxes->mbxs[0])) {
3fde693b 366 echo ' ' . html_tag( 'div',
367 $folder_img .$pre .$font. $boxes->mailboxname_sub .$fontend . $end ,
368 'left', '', 'class="mbx_sub" id="' .$j. '" onmouseover="changerowcolor(this,true)" onmouseout="changerowcolor(this,false)"' )
369 . "\n";
f23f6a3a 370 } else {
371 /* get collapse information */
372 if ($collapse_folders) {
373 $link = '<a target="left" style="text-decoration:none" ' .'href="left_main.php?';
374 $form_entry = $j.'F';
375 if (isset($mbx) && isset($mbx[$form_entry])) {
376 $collapse = $mbx[$form_entry];
377 if ($collapse) {
378 setPref($data_dir, $username, 'collapse_folder_'.$boxes->mailboxname_full , SM_BOX_COLLAPSED);
379 } else {
380 setPref($data_dir, $username, 'collapse_folder_'.$boxes->mailboxname_full , SM_BOX_UNCOLLAPSED);
381 }
382 } else {
383 $collapse = getPref($data_dir, $username, 'collapse_folder_' . $mailbox);
384 $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED : $collapse);
385 }
386 if ($collapse) {
599038d5 387 $link = '<a href="javascript:void(0)">'." <img src=\"../images/plus.gif\" border=\"1\" id=$j onclick=\"hidechilds(this)\"></A>";
f23f6a3a 388 } else {
599038d5 389 $link = '<a href="javascript:void(0)">'."<img src=\"../images/minus.gif\" border=\"1\" id=$j onclick=\"hidechilds(this)\"></a>";
f23f6a3a 390 }
391 $collapse_link = $link;
392 } else $collapse_link='';
3fde693b 393 echo ' ' . html_tag( 'div',
394 $collapse_link . $folder_img .$pre. $font. '&nbsp '. $boxes->mailboxname_sub .$fontend . $end ,
395 'left', '', 'class="mbx_par" id="' .$j. 'P" onmouseover="changerowcolor(this,true)" onmouseout="changerowcolor(this,false)"' )
396 . "\n";
386e556f 397 echo ' <INPUT TYPE="hidden" name=mbx['.$j. 'F] value="'.$collapse.'" id=mbx['.$j.'F>'."\n";
f23f6a3a 398 }
399 }
400 if ($collapse) {
401 $visible = ' STYLE="display:none;"';
402 } else {
386e556f 403 $visible = ' STYLE="display:block;"';
f23f6a3a 404 }
405
406 if (isset($boxes->mbxs[0]) && !$boxes->is_root) /* mailbox contains childs */
3fde693b 407 echo html_tag( 'div', '', 'left', '', 'class="par_area" id='.$j.'.0 '. $visible ) . "\n";
408
f23f6a3a 409 if ($j !='ID.0') {
410 $j = $j .'.0';
411 }
412 for ($i = 0; $i <count($boxes->mbxs); $i++) {
413 $j++;
414 listAdvancedBoxes($boxes->mbxs[$i],$mbx,$j);
415 }
416 if (isset($boxes->mbxs[0]) && !$boxes->is_root ) echo '</div>'."\n\n";
417 }
418}
419
420
421
95e93571 422
423/* -------------------- MAIN ------------------------ */
424
599038d5 425global $delimiter, $default_folder_prefix, $left_size;
95e93571 426
427// open a connection on the imap port (143)
428$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 10); // the 10 is to hide the output
429
f43c35f8 430/**
431 * Using stristr since older preferences may contain "None" and "none".
432 */
433if (isset($left_refresh) && ($left_refresh != '') &&
434 !stristr($left_refresh, "none")){
95e93571 435 $xtra = "\n<META HTTP-EQUIV=\"Expires\" CONTENT=\"Thu, 01 Dec 1994 16:00:00 GMT\">\n" .
436 "<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">\n".
437 "<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"$left_refresh;URL=left_main.php\">\n";
438} else {
439 $xtra = '';
440}
441
f23f6a3a 442/**
443 * $advanced_tree and $oldway are boolean vars which are default set to default
444 * SM behaviour.
445 * Setting $oldway to false causes left_main.php to use the new experimental
446 * way of getting the mailbox-tree.
447 * Setting $advanced tree to true causes SM to display a experimental
448 * mailbox-tree with dhtml behaviour.
449 * It only works on browsers which supports css and javascript. The used
450 * javascript is experimental and doesn't support all browsers. It is tested on
451 * IE6 an Konquerer 3.0.0-2.
452 * In the function ListAdvancedBoxes there is another var $use_folder_images.
453 * setting this to true is only usefull if the images exists in ../images.
454 *
455 * Feel free to experiment with the code and report bugs and enhancements
456 * to marc@its-projects.nl
457 **/
458
459$advanced_tree = false; /* set this to true if you want to see a nicer mailboxtree */
460$oldway = true; /* default SM behaviour */
461
462if ($advanced_tree) {
463$xtra .= <<<ECHO
599038d5 464<script language="Javascript" TYPE="text/javascript">
f23f6a3a 465
599038d5 466<!--
f23f6a3a 467
468 function hidechilds(el) {
469 id = el.id +".0";
470 form_id = "mbx[" + el.id +"F]";
471 if (document.all) {
472 ele = document.all[id];
599038d5 473 if (ele) {
474 if(ele.style.display == "none") {
475 ele.style.display = "block";
476 ele.style.visibility = "visible"
477 document.all[el.id].src="../images/minus.gif";
478 document.all[form_id].value=0;
479 } else {
480 ele.style.display = "none";
481 ele.style.visibility = "hidden"
482 document.all[el.id].src="../images/plus.gif";
483 document.all[form_id].value=1;
484 }
f23f6a3a 485 }
486 } else if (document.getElementById) {
487 id = el.id+".0";
488 ele = document.getElementById(id);
489 img_ele = document.getElementById(el.id);
599038d5 490 if (ele) {
491 if(ele.style.display == "none") {
492 ele.style.display = "block";
493 ele.style.visibility = "visible"
494 img_ele.src="../images/minus.gif";
495 document.getElementById(form_id).value=0;
496 } else {
497 ele.style.display = "none";
498 ele.style.visibility = "hidden"
499 img_ele.src="../images/plus.gif";
500 document.getElementById(form_id).value=1;
501 }
502 }
f23f6a3a 503 }
504 }
505
506 function preload() {
507 if (!document.images) return;
508 var ar = new Array();
509 var arguments = preload.arguments;
510 for (var i = 0; i<arguments.length; i++) {
511 ar[i] = new Image();
512 ar[i].src = arguments[i];
513 }
514 }
515
516 function changerowcolor(el,on) {
517 id = el.id;
599038d5 518ECHO;
519$xtra.= "\nvar color1 = \"$color[0]\";\n".
520 "var color2 = \"$color[9]\";\n";
521$xtra .= <<<ECHO
f23f6a3a 522 if (document.all) {
599038d5 523 if(!on) {
524 document.all[id].style.background = color1;
525 } else {
526 document.all[id].style.background = color2;
527 }
528 } else if (document.getElementById) {
529 if (!on) {
530 document.getElementById(id).style.background=color1;
531 } else {
532 document.getElementById(id).style.background=color2;
533
534 }
f23f6a3a 535 }
536 }
537
538 function buttonover(el,on) {
539 if (!on) {
540 el.style.borderColor="blue";}
541 else {
542 el.style.borderColor="orange";}
543 }
544
545 function buttonclick(el,on) {
546 if (!on) {
547 el.style.border="groove"}
548 else {
549 el.style.border="ridge";}
550 }
599038d5 551
552 function hideframe(hide) {
553
554ECHO;
555$xtra .= " left_size = \"$left_size\";\n";
556$xtra .= <<<ECHO
557 if (document.all) {
558 masterf = window.parent.document.all["fs1"];
559 leftf = window.parent.document.all["left"];
560 leftcontent = document.all["leftframe"];
561 leftbutton = document.all["showf"];
562 } else if (document.getElementById) {
563 masterf = window.parent.document.getElementById("fs1");
564 leftf = window.parent.document.getElementById("left");
386e556f 565 leftcontent = document.getElementById("leftframe");
566 leftbutton = document.getElementById("showf");
599038d5 567 } else {
568 return false;
569 }
570 if(hide) {
571 new_col = calc_col("20");
572 masterf.cols = new_col;
573 document.body.scrollLeft=0;
574 document.body.style.overflow='hidden';
575 leftcontent.style.display = 'none';
576 leftbutton.style.display='block';
577 } else {
578 masterf.cols = calc_col(left_size);
579 document.body.style.overflow='';
580 leftbutton.style.display='none';
581 leftcontent.style.display='block';
582
583 }
584 }
585
586 function calc_col(c_w) {
587
588ECHO;
589 if ($location_of_bar == 'right') {
590 $xtra .= ' right=true;';
591 } else {
592 $xtra .= ' right=false;';
593 }
594 $xtra .= "\n";
595$xtra .= <<<ECHO
596 if (right) {
597 new_col = '*,'+c_w;
598 } else {
599 new_col = c_w+',*';
600 }
601 return new_col;
602 }
603
604 function resizeframe(direction) {
605 if (document.all) {
606 masterf = window.parent.document.all["fs1"];
607 } else if (document.getElementById) {
608 window.parent.document.getElementById("fs1");
609 } else {
610 return false;
611 }
612
613ECHO;
614 if ($location_of_bar == 'right') {
615 $xtra .= ' colPat=/^\*,(\d+)$/;';
616 } else {
617 $xtra .= ' colPat=/^(\d+),.*$/;';
618 }
619 $xtra .= "\n";
620
621$xtra .= <<<ECHO
622 old_col = masterf.cols;
623 colPat.exec(old_col);
624
625 if (direction) {
626 new_col_width = parseInt(RegExp.$1) + 25;
627
628 } else {
629 if (parseInt(RegExp.$1) > 35) {
630 new_col_width = parseInt(RegExp.$1) - 25;
631 }
632 }
633 masterf.cols = calc_col(new_col_width);
634 }
635
636//-->
f23f6a3a 637
638</script>
639
640ECHO;
641
642/* style definitions */
386e556f 643
f23f6a3a 644$xtra .= <<<ECHO
645
646<STYLE>
647<!--
599038d5 648 body {
649 margin: 0px 0px 0px 0px;
650 padding: 5px 5px 5px 5px;
651 }
f23f6a3a 652 .button {
653 border:outset;
654 border-color:blue;
599038d5 655 background:white;
f23f6a3a 656 width:99%;
657 heigth:99%;
658 }
659
660 .mbx_par {
f23f6a3a 661 font-size:0.8em;
599038d5 662 margin-left:4px;
663 margin-right:0px;
664
f23f6a3a 665 }
666
667 .mbx_sub {
599038d5 668 voice-family: "\"}\"";
669 voice-family: inherit;
f23f6a3a 670 padding-left:5px;
599038d5 671 padding-right:0px;
f23f6a3a 672 margin-left:4px;
599038d5 673 margin-right:0px;
f23f6a3a 674 font-size:0.7em;
675 }
676
677 .par_area {
599038d5 678 margin-top:0px;
679 margin-left:4px;
680 margin-right:0px;
f23f6a3a 681 padding-left:10px;
599038d5 682 padding-bottom:5px;
f23f6a3a 683 border-left: solid;
684 border-left-width:0.1em;
685 border-left-color:blue;
686 border-bottom: solid;
687 border-bottom-width:0.1em;
688 border-bottom-color:blue;
599038d5 689 display:block;
f23f6a3a 690 }
691
692 .mailboxes {
f23f6a3a 693 padding-bottom:3px;
599038d5 694 margin-right:4px;
695 padding-right:4px;
696 margin-left:4px;
697 padding-left:4px;
f23f6a3a 698 border: groove;
699 border-width:0.1em;
700 border-color:green;
599038d5 701
702ECHO;
703$xtra .= " background:$color[0];";
704$xtra .= <<<ECHO
f23f6a3a 705 }
706
707-->
708
709</STYLE>
710
711ECHO;
712
713}
714
715
716
717
95e93571 718displayHtmlHeader( 'SquirrelMail', $xtra );
719
720/* If requested and not yet complete, attempt to autocreate folders. */
721if ($auto_create_special && !isset($auto_create_done)) {
a3439b27 722 $autocreate = array($sent_folder, $trash_folder, $draft_folder);
95e93571 723 foreach( $autocreate as $folder ) {
a3439b27 724 if (($folder != '') && ($folder != 'none')) {
95e93571 725 if ( !sqimap_mailbox_exists($imapConnection, $folder)) {
726 sqimap_mailbox_create($imapConnection, $folder, '');
a3439b27 727 } else if (!sqimap_mailbox_is_subscribed($imapConnection, $folder)) {
95e93571 728 sqimap_subscribe($imapConnection, $folder);
2d367c68 729 }
ebf18afa 730 }
2d367c68 731 }
a6d2e0de 732
95e93571 733 /* Let the world know that autocreation is complete! Hurrah! */
90de1755 734 $auto_create_done = TRUE;
95e93571 735 session_register('auto_create_done');
736}
a6d2e0de 737
95e93571 738echo "\n<BODY BGCOLOR=\"$color[3]\" TEXT=\"$color[6]\" LINK=\"$color[6]\" VLINK=\"$color[6]\" ALINK=\"$color[6]\">\n";
a6d2e0de 739
95e93571 740do_hook('left_main_before');
599038d5 741if ($advanced_tree) {
742 /* nice future feature, needs layout !! volunteers? */
743 $right_pos = $left_size - 20;
744 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><<</b></a></div>';
745 echo '<div ID="showf" style="width=20;font-size:12;display:none;"><A HREF="javascript:hideframe(false)"><b>>></b></a></div>';
746 echo '<div ID="incrf" style="width=20;font-size:12"><A HREF="javascript:resizeframe(true)"><b>></b></a></div>';
747 echo '<div ID="decrf" style="width=20;font-size:12"><A HREF="javascript:resizeframe(false)"><b><</b></a></div></div>';
748 echo '<div ID="leftframe"><br><br>';
749}
2d367c68 750
3fde693b 751echo "\n\n" . html_tag( 'table', '', '', '', 'border="0" cellspacing="0" cellpadding="0" width="100%"' ) .
752 html_tag( 'tr' ) .
753 html_tag( 'td', '', 'left' ) .
754 '<center><font size="4"><b>'. _("Folders") . "</b><br></font>\n\n";
a6d2e0de 755
95e93571 756if ($date_format != 6) {
757 /* First, display the clock. */
758 if ($hour_format == 1) {
759 $hr = 'G:i';
760 if ($date_format == 4) {
761 $hr .= ':s';
a6d2e0de 762 }
95e93571 763 } else {
764 if ($date_format == 4) {
765 $hr = 'g:i:s a';
766 } else {
767 $hr = 'g:i a';
2d367c68 768 }
769 }
770
95e93571 771 switch( $date_format ) {
772 case 1:
773 $clk = date('m/d/y '.$hr, time());
774 break;
775 case 2:
776 $clk = date('d/m/y '.$hr, time());
777 break;
778 case 4:
779 case 5:
780 $clk = date($hr, time());
781 break;
782 default:
fc6f062a 783 $clk = substr( getDayName( date( 'w', time() ) ), 0, 3 ) . date( ', ' . $hr, time() );
2d367c68 784 }
95e93571 785 $clk = str_replace(' ','&nbsp;',$clk);
786
3fde693b 787 echo '<center><small>' . str_replace(' ','&nbsp;',_("Last Refresh")) .
788 ": $clk</small></center>";
95e93571 789}
790
791/* Next, display the refresh button. */
3fde693b 792echo '<small>(<a href="../src/left_main.php" target="left">'.
793 _("refresh folder list") . '</a>)</small></center><br>';
95e93571 794
795/* Lastly, display the folder list. */
796if ( $collapse_folders ) {
797 /* If directed, collapse or uncollapse a folder. */
798 if (isset($fold)) {
799 setPref($data_dir, $username, 'collapse_folder_' . $fold, SM_BOX_COLLAPSED);
800 } else if (isset($unfold)) {
801 setPref($data_dir, $username, 'collapse_folder_' . $unfold, SM_BOX_UNCOLLAPSED);
802 }
803}
804
f23f6a3a 805if ($oldway) { /* normal behaviour SM */
806
807$boxes = sqimap_mailbox_list($imapConnection);
95e93571 808/* Prepare do do out collapsedness and visibility computation. */
809$curbox = 0;
810$boxcount = count($boxes);
811
812/* Compute the collapsedness and visibility of each box. */
90de1755 813
95e93571 814while ($curbox < $boxcount) {
815 $boxes[$curbox]['visible'] = TRUE;
816 compute_folder_children($curbox, $boxcount);
817}
818
90de1755 819
1c52ba77 820for ($i = 0; $i < count($boxes); $i++) {
95e93571 821 if ( $boxes[$i]['visible'] ) {
822 $mailbox = $boxes[$i]['formatted'];
823 $mblevel = substr_count($boxes[$i]['unformatted'], $delimiter) + 1;
824
825 /* Create the prefix for the folder name and link. */
826 $prefix = str_repeat(' ',$mblevel);
827 if (isset($collapse_folders) && $collapse_folders && $boxes[$i]['parent']) {
828 $prefix = str_replace(' ','&nbsp;',substr($prefix,0,strlen($prefix)-2)).
829 create_collapse_link($i) . '&nbsp;';
830 } else {
831 $prefix = str_replace(' ','&nbsp;',$prefix);
832 }
833 $line = "<NOBR><TT>$prefix</TT>";
834
835 /* Add the folder name and link. */
1c52ba77 836 if (! isset($color[15])) {
05611cba 837 $color[15] = $color[6];
1c52ba77 838 }
90de1755 839
95e93571 840 if (in_array('noselect', $boxes[$i]['flags'])) {
1c52ba77 841 if( isSpecialMailbox( $boxes[$i]['unformatted']) ) {
842 $line .= "<FONT COLOR=\"$color[11]\">";
843 } else {
844 $line .= "<FONT COLOR=\"$color[15]\">";
845 }
95e93571 846 if (ereg("^( *)([^ ]*)", $mailbox, $regs)) {
847 $mailbox = str_replace('&nbsp;','',$mailbox);
848 $line .= str_replace(' ', '&nbsp;', $mailbox);
2d367c68 849 }
95e93571 850 $line .= '</FONT>';
851 } else {
852 $line .= formatMailboxName($imapConnection, $boxes[$i]);
853 }
2d367c68 854
95e93571 855 /* Put the final touches on our folder line. */
856 $line .= "</NOBR><BR>\n";
2d367c68 857
95e93571 858 /* Output the line for this folder. */
859 echo $line;
2d367c68 860 }
95e93571 861}
f23f6a3a 862} else { /* expiremental code */
863 $boxes = sqimap_mailbox_tree($imapConnection);
864 if (isset($advanced_tree) && $advanced_tree) {
865 echo '<FORM name=collapse action="left_main.php" METHOD=POST' .
866 'ENCTYPE="multipart/form-data"'."\n";
867 echo '<small><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>';
868 echo '<DIV ID=mailboxes CLASS=mailboxes>'."\n\n";
869 if (!isset($mbx)) $mbx=NULL;
870 ListAdvancedBoxes($boxes, $mbx);
871 echo '</div></small>'."\n";
872 echo '</FORM>'."\n";
873 } else {
874 ListBoxes($boxes);
875 }
876} /* if ($oldway) else ... */
95e93571 877do_hook('left_main_after');
76b684a5 878sqimap_logout($imapConnection);
2d367c68 879
3fde693b 880echo '</td></tr></table>' . "\n".
881 "</div></body></html>\n";
2d367c68 882
7fb54066 883?>