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