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