59177427 |
1 | <?php |
849bdf42 |
2 | /** |
3 | * options.php |
4 | * |
5 | * Copyright (c) 1999-2001 The SquirrelMail Development Team |
6 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
7 | * |
8 | * Displays the options page. Pulls from proper user preference files |
9 | * and config.php. Displays preferences as selected and other options. |
10 | * |
11 | * $Id$ |
12 | */ |
13 | |
14 | require_once('../src/validate.php'); |
15 | require_once('../functions/display_messages.php'); |
16 | require_once('../functions/imap.php'); |
17 | require_once('../functions/array.php'); |
88fa922a |
18 | |
849bdf42 |
19 | ereg ("(^.*/)[^/]+/[^/]+$", $PHP_SELF, $regs); |
20 | $base_uri = $regs[1]; |
d3cdb279 |
21 | |
849bdf42 |
22 | if (isset($language)) { |
23 | setcookie('squirrelmail_language', $language, time()+2592000, $base_uri); |
24 | $squirrelmail_language = $language; |
25 | } |
1e0628fb |
26 | |
849bdf42 |
27 | displayPageHeader($color, _("None")); |
f740c049 |
28 | |
c36ed9cf |
29 | ?> |
11307a4c |
30 | |
e9f8ea4e |
31 | <br> |
e7db48af |
32 | <table bgcolor="<?php echo $color[0] ?>" width="95%" align="center" cellpadding="2" cellspacing="0" border="0"> |
33 | <tr><td align="center"> |
849bdf42 |
34 | <b><?php echo _("Options") ?></b><br> |
e7db48af |
35 | |
36 | <table width="100%" border="0" cellpadding="5" cellspacing="0"> |
37 | <tr><td bgcolor="<?php echo $color[4] ?>" align="center"> |
c36ed9cf |
38 | |
6170c5b6 |
39 | <?php |
849bdf42 |
40 | if (isset($submit_personal)) { |
41 | /* Save personal information. */ |
42 | if (isset($full_name)) { |
43 | setPref($data_dir, $username, 'full_name', $full_name); |
44 | } |
45 | if (isset($email_address)) { |
46 | setPref($data_dir, $username, 'email_address', $email_address); |
47 | } |
48 | if (isset($reply_to)) { |
49 | setPref($data_dir, $username, 'reply_to', $reply_to); |
50 | } |
51 | setPref($data_dir, $username, 'reply_citation_style', $new_reply_citation_style); |
52 | setPref($data_dir, $username, 'reply_citation_start', $new_reply_citation_start); |
53 | setPref($data_dir, $username, 'reply_citation_end', $new_reply_citation_end); |
54 | if (! isset($usesignature)) |
55 | $usesignature = 0; |
56 | setPref($data_dir, $username, 'use_signature', $usesignature); |
57 | if (! isset($prefixsig)) { |
58 | $prefixsig = 0; |
59 | } |
60 | setPref($data_dir, $username, 'prefix_sig', $prefixsig); |
61 | if (isset($signature_edit)) { |
62 | setSig($data_dir, $username, $signature_edit); |
63 | } |
2848c630 |
64 | |
849bdf42 |
65 | do_hook('options_personal_save'); |
ef3c69f0 |
66 | |
849bdf42 |
67 | echo '<br><b>'._("Successfully saved personal information!").'</b><br>'; |
68 | } else if (isset($submit_display)) { |
69 | // Do checking to make sure $chosentheme is in the array |
70 | $in_ary = false; |
71 | for ($i=0; $i < count($theme); $i++) { |
72 | if ($theme[$i]['PATH'] == $chosentheme) { |
73 | $in_ary = true; |
74 | break; |
75 | } |
76 | } |
77 | if (! $in_ary) { |
78 | $chosentheme = ''; |
79 | } |
6b638171 |
80 | |
849bdf42 |
81 | /* Save display preferences. */ |
82 | setPref($data_dir, $username, 'chosen_theme', $chosentheme); |
83 | setPref($data_dir, $username, 'language', $language); |
84 | setPref($data_dir, $username, 'use_javascript_addr_book', $javascript_abook); |
85 | setPref($data_dir, $username, 'show_num', $shownum); |
86 | setPref($data_dir, $username, 'wrap_at', $wrapat); |
87 | setPref($data_dir, $username, 'editor_size', $editorsize); |
88 | setPref($data_dir, $username, 'left_refresh', $leftrefresh); |
89 | setPref($data_dir, $username, 'location_of_bar', $folder_new_location); |
90 | setPref($data_dir, $username, 'location_of_buttons', $button_new_location); |
91 | setPref($data_dir, $username, 'left_size', $leftsize); |
92 | |
93 | if (isset($altIndexColors) && $altIndexColors == 1) { |
94 | setPref($data_dir, $username, 'alt_index_colors', 1); |
95 | } else { |
96 | setPref($data_dir, $username, 'alt_index_colors', 0); |
97 | } |
98 | |
99 | setPref($data_dir, $username, 'show_html_default', ($showhtmldefault?1:0) ); |
100 | |
101 | if (isset($includeselfreplyall)) { |
102 | setPref($data_dir, $username, 'include_self_reply_all', 1); |
103 | } else { |
104 | removePref($data_dir, $username, 'include_self_reply_all'); |
105 | } |
106 | |
107 | if (isset($pageselectormax)) { |
108 | setPref($data_dir, $username, 'page_selector_max', $pageselectormax); |
109 | } else { |
110 | removePref($data_dir, $username, 'page_selector_max', 0 ); |
111 | } |
112 | |
113 | if (isset($pageselector)) { |
114 | removePref($data_dir, $username, 'page_selector'); |
115 | } else { |
116 | setPref($data_dir, $username, 'page_selector', 1); |
117 | } |
118 | |
119 | do_hook('options_display_save'); |
120 | |
121 | echo '<br><b>'._("Successfully saved display preferences!").'</b><br>'; |
122 | echo '<a href="../src/webmail.php?right_frame=options.php" target=_top>' . _("Refresh Page") . '</a><br>'; |
123 | } else if (isset($submit_folder)) { |
124 | /* Save folder preferences. */ |
125 | if ($trash != 'none') { |
126 | setPref($data_dir, $username, 'move_to_trash', true); |
127 | setPref($data_dir, $username, 'trash_folder', $trash); |
128 | } else { |
129 | setPref($data_dir, $username, 'move_to_trash', '0'); |
130 | setPref($data_dir, $username, 'trash_folder', 'none'); |
131 | } |
132 | if ($sent != 'none') { |
133 | setPref($data_dir, $username, 'move_to_sent', true); |
134 | setPref($data_dir, $username, 'sent_folder', $sent); |
135 | } else { |
136 | setPref($data_dir, $username, 'move_to_sent', '0'); |
137 | setPref($data_dir, $username, 'sent_folder', 'none'); |
138 | } |
139 | if ($draft != 'none') { |
140 | setPref($data_dir, $username, 'save_as_draft', true); |
141 | setPref($data_dir, $username, 'draft_folder', $draft); |
142 | } else { |
143 | setPref($data_dir, $username, 'save_as_draft', '0'); |
144 | setPref($data_dir, $username, 'draft_folder', 'none'); |
145 | } |
146 | if (isset($folderprefix)) { |
147 | setPref($data_dir, $username, 'folder_prefix', $folderprefix); |
148 | } else { |
149 | setPref($data_dir, $username, 'folder_prefix', ''); |
150 | } |
151 | setPref($data_dir, $username, 'unseen_notify', $unseennotify); |
152 | setPref($data_dir, $username, 'unseen_type', $unseentype); |
153 | if (isset($collapsefolders)) |
154 | setPref($data_dir, $username, 'collapse_folders', $collapsefolders); |
155 | else |
156 | removePref($data_dir, $username, 'collapse_folders'); |
157 | setPref($data_dir, $username, 'date_format', $dateformat); |
158 | setPref($data_dir, $username, 'hour_format', $hourformat); |
159 | do_hook('options_folders_save'); |
160 | echo '<br><b>'._("Successfully saved folder preferences!").'</b><br>'; |
161 | echo '<a href="../src/left_main.php" target=left>' . _("Refresh Folder List") . '</a><br>'; |
162 | } else { |
163 | do_hook('options_save'); |
164 | } |
165 | |
166 | /****************************************/ |
167 | /* Now build our array of option pages. */ |
168 | /****************************************/ |
169 | |
170 | /* Build a section for Personal Options. */ |
171 | $optionpages[] = array( |
172 | 'name' => _("Personal Information"), |
173 | 'url' => 'options_personal.php', |
174 | 'desc' => _("This contains personal information about yourself such as your name, your email address, etc."), |
175 | 'js' => false |
176 | ); |
177 | |
178 | /* Build a section for Display Options. */ |
179 | $optionpages[] = array( |
180 | 'name' => _("Display Preferences"), |
181 | 'url' => 'options_display.php', |
182 | 'desc' => _("You can change the way that SquirrelMail looks and displays information to you, such as the colors, the language, and other settings."), |
183 | 'js' => false |
184 | ); |
185 | |
186 | /* Build a section for Message Highlighting Options. */ |
187 | $optionpages[] = array( |
188 | 'name' =>_("Message Highlighting"), |
189 | 'url' => 'options_highlight.php', |
190 | 'desc' =>_("Based upon given criteria, incoming messages can have different background colors in the message list. This helps to easily distinguish who the messages are from, especially for mailing lists."), |
191 | 'js' => false |
192 | ); |
193 | |
194 | /* Build a section for Folder Options. */ |
195 | $optionpages[] = array( |
196 | 'name' => _("Folder Preferences"), |
197 | 'url' => 'options_folder.php', |
198 | 'desc' => _("These settings change the way your folders are displayed and manipulated."), |
199 | 'js' => false |
200 | ); |
201 | |
202 | /* Build a section for Index Order Options. */ |
203 | $optionpages[] = array( |
204 | 'name' => _("Index Order"), |
205 | 'url' => 'options_order.php', |
206 | 'desc' => _("The order of the message index can be rearanged and changed to contain the headers in any order you want."), |
207 | 'js' => false |
208 | ); |
209 | /* Build a section for plugins wanting to register an optionpage. */ |
210 | do_hook('options_register'); |
211 | |
212 | /*****************************************************/ |
213 | /* Let's sort Javascript Option Pages to the bottom. */ |
214 | /*****************************************************/ |
215 | foreach ($optionpages as $optpage) { |
216 | if ($optpage['js']) { |
217 | $js_optionpages[] = $optpage; |
218 | } else { |
219 | $nojs_optionpages[] = $optpage; |
220 | } |
221 | } |
222 | $optionpages = array_merge($nojs_optionpages, $js_optionpages); |
223 | |
224 | /********************************************/ |
225 | /* Now, print out each option page section. */ |
226 | /********************************************/ |
227 | $first_optpage = false; |
228 | foreach ($optionpages as $next_optpage) { |
229 | if ($first_optpage == false) { |
230 | $first_optpage = $next_optpage; |
231 | } else { |
232 | print_optionpages_row($first_optpage, $next_optpage); |
233 | $first_optpage = false; |
234 | } |
235 | } |
236 | |
237 | if ($first_optpage != false) { |
238 | print_optionpages_row($first_optpage); |
239 | } |
240 | |
241 | do_hook('options_link_and_description'); |
242 | |
c36ed9cf |
243 | ?> |
849bdf42 |
244 | </td></tr> |
245 | </table> |
246 | |
247 | </td></tr> |
248 | </table> |
249 | |
250 | </body></html> |
251 | |
252 | <?php |
253 | |
254 | /*******************************************************************/ |
255 | /* Please be warned. The code below this point sucks. This is just */ |
256 | /* my first implementation to make the option rows work for both */ |
257 | /* Javascript and non-Javascript option chunks. */ |
258 | /* */ |
259 | /* Please, someone make these better for me. All three functions */ |
260 | /* below REALLY do close to the same thing. */ |
261 | /* */ |
262 | /* This code would be GREATLY improved by a templating system. */ |
263 | /* Don't try to implement that now, however. That will come later. */ |
264 | /*******************************************************************/ |
265 | |
266 | /*******************************************************************/ |
267 | /* Actually, now that I think about it, don't do anything with */ |
268 | /* this code yet. There is ACTUALLY supposed to be a difference */ |
269 | /* between the three functions that write the option rows. I just */ |
270 | /* have not yet gotten to integrating that yet. */ |
271 | /*******************************************************************/ |
272 | |
273 | /** |
274 | * This function prints out an option page row. All it actually |
275 | * does is call the three functions below. |
276 | */ |
277 | function print_optionpages_row($leftopt, $rightopt = false) { |
278 | if ($rightopt == false) { |
279 | if ($leftopt['js']) { |
280 | print_optionpages_row_fulljs($leftopt); |
281 | } else { |
282 | print_optionpages_row_nojs($leftopt); |
283 | } |
284 | } else { |
285 | if ($leftopt['js']) { |
286 | if ($rightopt['js']) { |
287 | print_optionpages_row_fulljs($leftopt, $rightopt); |
288 | } else { |
289 | print_optionpages_row_partjs($leftopt, $rightopt); |
290 | } |
291 | } else { |
292 | print_optionpages_row_nojs($leftopt, $rightopt); |
293 | } |
294 | } |
295 | } |
11307a4c |
296 | |
849bdf42 |
297 | /** |
298 | * This function prints out an option page row: in which the left |
299 | * Left: options for functionality that do not require javascript |
300 | * Right: options for functionality that do not require javascript |
301 | */ |
302 | function print_optionpages_row_nojs($leftopt, $rightopt = false) { |
303 | global $color; |
304 | ?> |
305 | <table bgcolor="<?php echo $color[4] ?>" width="100%" cellpadding="0" cellspacing="5" border="0"> |
306 | <tr><td valign=top> |
db5910ac |
307 | <table width="100%" cellpadding="3" cellspacing="0" border="0"> |
c36ed9cf |
308 | <tr> |
849bdf42 |
309 | <td valign="top" bgcolor="<?php echo $color[9] ?>" width="50%"> |
310 | <a href="<?php echo $leftopt['url'] ?>"><?php echo $leftopt['name'] ?></a> |
311 | </td> |
312 | <td valign="top" bgcolor="<?php echo $color[4] ?>"> </td> |
313 | <?php if ($rightopt != false) { ?> |
314 | <td valign="top" bgcolor="<?php echo $color[9] ?>" width="50%"> |
315 | <a href="<?php echo $rightopt['url'] ?>"><?php echo $rightopt['name'] ?></a> |
c36ed9cf |
316 | </td> |
849bdf42 |
317 | <?php } else { ?> |
318 | <td valign="top" bgcolor="<?php echo $color[4] ?>" width="50%"> </td> |
319 | <?php } ?> |
c36ed9cf |
320 | </tr> |
321 | <tr> |
849bdf42 |
322 | <td valign="top" bgcolor="<?php echo $color[0] ?>"> |
323 | <?php echo $leftopt['desc'] ?> |
c36ed9cf |
324 | </td> |
849bdf42 |
325 | <td valign="top" bgcolor="<?php echo $color[4] ?>"> </td> |
326 | <?php if ($rightopt != false) { ?> |
327 | <td valign="top" bgcolor="<?php echo $color[0] ?>"> |
328 | <?php echo $rightopt['desc'] ?> |
c36ed9cf |
329 | </td> |
849bdf42 |
330 | <?php } else { ?> |
331 | <td valign="top" bgcolor="<?php echo $color[4] ?>"> </td> |
332 | <?php } ?> |
c36ed9cf |
333 | </tr> |
849bdf42 |
334 | </table> |
335 | </td></tr> |
336 | </table> |
337 | <?php |
338 | } |
339 | |
340 | /** |
341 | * This function prints out an option page row: in which the left |
342 | * Left: options for functionality that does not require javascript |
343 | * Right: options for functionality that are javascript only |
344 | */ |
345 | function print_optionpages_row_partjs($leftopt, $rightopt = false) { |
346 | global $color; |
347 | ?> |
348 | <table bgcolor="<?php echo $color[4] ?>" width="100%" cellpadding="0" cellspacing="5" border="0"> |
349 | <tr><td valign=top> |
db5910ac |
350 | <table width="100%" cellpadding="3" cellspacing="0" border="0"> |
8e265988 |
351 | <tr> |
849bdf42 |
352 | <td valign="top" bgcolor="<?php echo $color[9] ?>" width="50%"> |
353 | <a href="<?php echo $leftopt['url'] ?>"><?php echo $leftopt['name'] ?></a> |
354 | </td> |
355 | <td valign="top" bgcolor="<?php echo $color[4] ?>"> </td> |
356 | <?php if ($rightopt != false) { ?> |
357 | <td valign="top" bgcolor="<?php echo $color[9] ?>" width="50%"> |
358 | <a href="<?php echo $rightopt['url'] ?>"><?php echo $rightopt['name'] ?></a> |
8e265988 |
359 | </td> |
849bdf42 |
360 | <?php } else { ?> |
361 | <td valign="top" bgcolor="<?php echo $color[4] ?>" width="50%"> </td> |
362 | <?php } ?> |
8e265988 |
363 | </tr> |
364 | <tr> |
849bdf42 |
365 | <td valign="top" bgcolor="<?php echo $color[0] ?>"> |
366 | <?php echo $leftopt['desc'] ?> |
8e265988 |
367 | </td> |
849bdf42 |
368 | <td valign="top" bgcolor="<?php echo $color[4] ?>"> </td> |
369 | <?php if ($rightopt != false) { ?> |
370 | <td valign="top" bgcolor="<?php echo $color[0] ?>"> |
371 | <?php echo $rightopt['desc'] ?> |
c36ed9cf |
372 | </td> |
849bdf42 |
373 | <?php } else { ?> |
374 | <td valign="top" bgcolor="<?php echo $color[4] ?>"> </td> |
375 | <?php } ?> |
c36ed9cf |
376 | </tr> |
849bdf42 |
377 | </table> |
378 | </td></tr> |
379 | </table> |
380 | <?php |
381 | } |
382 | |
383 | /** |
384 | * This function prints out an option page row: in which the left |
385 | * Left: options for functionality that are javascript only |
386 | * Right: options for functionality that are javascript only |
387 | */ |
388 | function print_optionpages_row_fulljs($leftopt, $rightopt = false) { |
389 | global $color; |
390 | ?> |
391 | <table bgcolor="<?php echo $color[4] ?>" width="100%" cellpadding="0" cellspacing="5" border="0"> |
392 | <tr><td valign=top> |
db5910ac |
393 | <table width="100%" cellpadding="3" cellspacing="0" border="0"> |
c36ed9cf |
394 | <tr> |
849bdf42 |
395 | <td valign="top" bgcolor="<?php echo $color[9] ?>" width="50%"> |
396 | <a href="<?php echo $leftopt['url'] ?>"><?php echo $leftopt['name'] ?></a> |
c36ed9cf |
397 | </td> |
849bdf42 |
398 | <td valign="top" bgcolor="<?php echo $color[4] ?>"> </td> |
399 | <?php if ($rightopt != false) { ?> |
400 | <td valign="top" bgcolor="<?php echo $color[9] ?>" width="50%"> |
401 | <a href="<?php echo $rightopt['url'] ?>"><?php echo $rightopt['name'] ?></a> |
402 | </td> |
403 | <?php } else { ?> |
404 | <td valign="top" bgcolor="<?php echo $color[4] ?>" width="50%"> </td> |
405 | <?php } ?> |
c36ed9cf |
406 | </tr> |
407 | <tr> |
849bdf42 |
408 | <td valign="top" bgcolor="<?php echo $color[0] ?>"> |
409 | <?php echo $leftopt['desc'] ?> |
c36ed9cf |
410 | </td> |
849bdf42 |
411 | <td valign="top" bgcolor="<?php echo $color[4] ?>"> </td> |
412 | <?php if ($rightopt != false) { ?> |
413 | <td valign="top" bgcolor="<?php echo $color[0] ?>"> |
414 | <?php echo $rightopt['desc'] ?> |
415 | </td> |
416 | <?php } else { ?> |
417 | <td valign="top" bgcolor="<?php echo $color[4] ?>"> </td> |
418 | <?php } ?> |
419 | </tr> |
420 | </table> |
421 | </td></tr> |
e7db48af |
422 | </table> |
849bdf42 |
423 | <?php |
424 | } |
e7db48af |
425 | |
849bdf42 |
426 | ?> |