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