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> |
10f0ce72 |
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 | |
10f0ce72 |
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. */ |
bbcafebd |
42 | setPref($data_dir, $username, 'full_name', $new_full_name); |
43 | setPref($data_dir, $username, 'email_address', $new_email_address); |
44 | setPref($data_dir, $username, 'reply_to', $new_reply_to); |
849bdf42 |
45 | setPref($data_dir, $username, 'reply_citation_style', $new_reply_citation_style); |
46 | setPref($data_dir, $username, 'reply_citation_start', $new_reply_citation_start); |
47 | setPref($data_dir, $username, 'reply_citation_end', $new_reply_citation_end); |
bbcafebd |
48 | setPref($data_dir, $username, 'use_signature', $new_use_signature); |
49 | setPref($data_dir, $username, 'prefix_sig', $new_prefix_sig); |
50 | setSig($data_dir, $username, $new_signature_abs); |
2848c630 |
51 | |
849bdf42 |
52 | do_hook('options_personal_save'); |
ef3c69f0 |
53 | |
849bdf42 |
54 | echo '<br><b>'._("Successfully saved personal information!").'</b><br>'; |
55 | } else if (isset($submit_display)) { |
ce393174 |
56 | /* Do checking to make sure $new_theme is in the array. */ |
57 | $theme_in_array = false; |
849bdf42 |
58 | for ($i=0; $i < count($theme); $i++) { |
ce393174 |
59 | if ($theme[$i]['PATH'] == $new_chosen_theme) { |
60 | $theme_in_array = true; |
849bdf42 |
61 | break; |
62 | } |
63 | } |
ce393174 |
64 | if (!$theme_in_array) { |
65 | $new_chosen_theme = ''; |
849bdf42 |
66 | } |
6b638171 |
67 | |
849bdf42 |
68 | /* Save display preferences. */ |
ce393174 |
69 | setPref($data_dir, $username, 'chosen_theme', $new_chosen_theme); |
70 | setPref($data_dir, $username, 'language', $new_language); |
71 | setPref($data_dir, $username, 'use_javascript_addr_book', $new_use_javascript_addr_book); |
23d6bd09 |
72 | setPref($data_dir, $username, 'javascript_setting', $new_javascript_setting); |
a3ec3c91 |
73 | setPref($data_dir, $username, 'show_num', $new_show_num); |
74 | setPref($data_dir, $username, 'wrap_at', $new_wrap_at); |
75 | setPref($data_dir, $username, 'editor_size', $new_editor_size); |
a3ec3c91 |
76 | setPref($data_dir, $username, 'location_of_buttons', $new_location_of_buttons); |
fd87494d |
77 | setPref($data_dir, $username, 'alt_index_colors', $new_alt_index_colors); |
78 | setPref($data_dir, $username, 'show_html_default', $new_show_html_default); |
79 | setPref($data_dir, $username, 'include_self_reply_all', $new_include_self_reply_all); |
80 | setPref($data_dir, $username, 'page_selector', $new_page_selector); |
81 | setPref($data_dir, $username, 'page_selector_max', $new_page_selector_max); |
9ab0d96f |
82 | setPref($data_dir, $username, 'show_xmailer_default', $new_show_xmailer_default); |
7baf86a9 |
83 | setPref($data_dir, $username, 'attachment_common_show_images', $new_attachment_common_show_images); |
f226cba7 |
84 | setPref($data_dir, $username, 'pf_subtle_link', $new_pf_subtle_link); |
85 | setPref($data_dir, $username, 'pf_cleandisplay', $new_pf_cleandisplay); |
849bdf42 |
86 | |
a3ec3c91 |
87 | $js_autodetect_results = (isset($new_js_autodetect_results) ? $new_js_autodetect_results : SMPREF_JS_OFF); |
23d6bd09 |
88 | if ($new_javascript_setting == SMPREF_JS_AUTODETECT) { |
89 | if ($js_autodetect_results == SMPREF_JS_ON) { |
90 | setPref($data_dir, $username, 'javascript_on', SMPREF_JS_ON); |
91 | } else { |
92 | setPref($data_dir, $username, 'javascript_on', SMPREF_JS_OFF); |
93 | } |
94 | } else { |
95 | setPref($data_dir, $username, 'javascript_on', $new_javascript_setting); |
f226cba7 |
96 | } |
23d6bd09 |
97 | |
849bdf42 |
98 | do_hook('options_display_save'); |
99 | |
100 | echo '<br><b>'._("Successfully saved display preferences!").'</b><br>'; |
10f0ce72 |
101 | echo '<A HREF="../src/webmail.php?right_frame=options.php" target=_top>' . _("Refresh Page") . '</A><br>'; |
849bdf42 |
102 | } else if (isset($submit_folder)) { |
b5efadfa |
103 | /* Save trash folder preferences. */ |
104 | if ($new_trash_folder != SMPREF_NONE) { |
105 | setPref($data_dir, $username, 'move_to_trash', SMPREF_ON); |
106 | setPref($data_dir, $username, 'trash_folder', $new_trash_folder); |
849bdf42 |
107 | } else { |
b5efadfa |
108 | setPref($data_dir, $username, 'move_to_trash', SMPREF_OFF); |
109 | setPref($data_dir, $username, 'trash_folder', SMPREF_NONE); |
849bdf42 |
110 | } |
b5efadfa |
111 | |
112 | /* Save sent folder preferences. */ |
113 | if ($new_sent_folder != SMPREF_NONE) { |
114 | setPref($data_dir, $username, 'move_to_sent', SMPREF_ON); |
115 | setPref($data_dir, $username, 'sent_folder', $new_sent_folder); |
849bdf42 |
116 | } else { |
b5efadfa |
117 | setPref($data_dir, $username, 'move_to_sent', SMPREF_OFF); |
118 | setPref($data_dir, $username, 'sent_folder', SMPREF_NONE); |
849bdf42 |
119 | } |
b5efadfa |
120 | |
121 | /* Save draft folder preferences. */ |
122 | if ($new_draft_folder != SMPREF_NONE) { |
123 | setPref($data_dir, $username, 'save_as_draft', SMPREF_ON); |
124 | setPref($data_dir, $username, 'draft_folder', $new_draft_folder); |
849bdf42 |
125 | } else { |
b5efadfa |
126 | setPref($data_dir, $username, 'save_as_draft', SMPREF_OFF); |
127 | setPref($data_dir, $username, 'draft_folder', SMPREF_NONE); |
849bdf42 |
128 | } |
b5efadfa |
129 | |
130 | /* Save folder prefix preferences. */ |
849bdf42 |
131 | if (isset($folderprefix)) { |
132 | setPref($data_dir, $username, 'folder_prefix', $folderprefix); |
133 | } else { |
134 | setPref($data_dir, $username, 'folder_prefix', ''); |
135 | } |
a440e68f |
136 | |
137 | setPref($data_dir, $username, 'location_of_bar', $new_location_of_bar); |
138 | setPref($data_dir, $username, 'left_size', $new_left_size); |
139 | setPref($data_dir, $username, 'left_refresh', $new_left_refresh); |
140 | setPref($data_dir, $username, 'unseen_notify', $new_unseen_notify); |
141 | setPref($data_dir, $username, 'unseen_type', $new_unseen_type); |
142 | setPref($data_dir, $username, 'collapse_folders', $new_collapse_folders); |
143 | setPref($data_dir, $username, 'date_format', $new_date_format); |
144 | setPref($data_dir, $username, 'hour_format', $new_hour_format); |
145 | |
849bdf42 |
146 | do_hook('options_folders_save'); |
147 | echo '<br><b>'._("Successfully saved folder preferences!").'</b><br>'; |
10f0ce72 |
148 | echo '<A HREF="../src/left_main.php" target=left>' . _("Refresh Folder List") . '</A><br>'; |
849bdf42 |
149 | } else { |
150 | do_hook('options_save'); |
151 | } |
152 | |
153 | /****************************************/ |
154 | /* Now build our array of option pages. */ |
155 | /****************************************/ |
156 | |
157 | /* Build a section for Personal Options. */ |
158 | $optionpages[] = array( |
159 | 'name' => _("Personal Information"), |
160 | 'url' => 'options_personal.php', |
161 | 'desc' => _("This contains personal information about yourself such as your name, your email address, etc."), |
162 | 'js' => false |
163 | ); |
164 | |
165 | /* Build a section for Display Options. */ |
166 | $optionpages[] = array( |
167 | 'name' => _("Display Preferences"), |
168 | 'url' => 'options_display.php', |
169 | 'desc' => _("You can change the way that SquirrelMail looks and displays information to you, such as the colors, the language, and other settings."), |
170 | 'js' => false |
171 | ); |
172 | |
173 | /* Build a section for Message Highlighting Options. */ |
174 | $optionpages[] = array( |
175 | 'name' =>_("Message Highlighting"), |
176 | 'url' => 'options_highlight.php', |
177 | '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."), |
178 | 'js' => false |
179 | ); |
180 | |
181 | /* Build a section for Folder Options. */ |
182 | $optionpages[] = array( |
183 | 'name' => _("Folder Preferences"), |
184 | 'url' => 'options_folder.php', |
185 | 'desc' => _("These settings change the way your folders are displayed and manipulated."), |
186 | 'js' => false |
187 | ); |
188 | |
189 | /* Build a section for Index Order Options. */ |
190 | $optionpages[] = array( |
191 | 'name' => _("Index Order"), |
192 | 'url' => 'options_order.php', |
193 | 'desc' => _("The order of the message index can be rearanged and changed to contain the headers in any order you want."), |
194 | 'js' => false |
195 | ); |
196 | /* Build a section for plugins wanting to register an optionpage. */ |
197 | do_hook('options_register'); |
198 | |
199 | /*****************************************************/ |
200 | /* Let's sort Javascript Option Pages to the bottom. */ |
201 | /*****************************************************/ |
b3c9b2de |
202 | $js_optionpages = array(); |
203 | $reg_optionpages = array(); |
849bdf42 |
204 | foreach ($optionpages as $optpage) { |
23d6bd09 |
205 | if (!$optpage['js']) { |
206 | $reg_optionpages[] = $optpage; |
207 | } else if ($javascript_on == SMPREF_JS_ON) { |
849bdf42 |
208 | $js_optionpages[] = $optpage; |
849bdf42 |
209 | } |
210 | } |
23d6bd09 |
211 | $optionpages = array_merge($reg_optionpages, $js_optionpages); |
849bdf42 |
212 | |
213 | /********************************************/ |
214 | /* Now, print out each option page section. */ |
215 | /********************************************/ |
216 | $first_optpage = false; |
10f0ce72 |
217 | echo "<TABLE BGCOLOR=\"$color[4]\" WIDTH=\"100%\" CELLPADDING=0 CELLSPACING=\"5\" BORDER=\"0\">" . |
218 | '<TR><TD VALIGN="TOP">' . |
219 | "<TABLE BGCOLOR=\"$color[4]\" WIDTH=\"100%\" CELLPADDING=\"3\" CELLSPACING=\"0\" BORDER=\"0\">"; |
849bdf42 |
220 | foreach ($optionpages as $next_optpage) { |
221 | if ($first_optpage == false) { |
222 | $first_optpage = $next_optpage; |
223 | } else { |
224 | print_optionpages_row($first_optpage, $next_optpage); |
225 | $first_optpage = false; |
226 | } |
227 | } |
228 | |
229 | if ($first_optpage != false) { |
230 | print_optionpages_row($first_optpage); |
231 | } |
232 | |
10f0ce72 |
233 | echo '</TABLE>' . |
234 | '</TD></TR>' . |
235 | "</TABLE>\n"; |
dfec863e |
236 | |
849bdf42 |
237 | do_hook('options_link_and_description'); |
238 | |
c36ed9cf |
239 | ?> |
10f0ce72 |
240 | </TD></TR> |
241 | </TABLE> |
849bdf42 |
242 | |
10f0ce72 |
243 | </TD></TR> |
244 | </TABLE> |
849bdf42 |
245 | |
246 | </body></html> |
247 | |
248 | <?php |
249 | |
250 | /*******************************************************************/ |
251 | /* Please be warned. The code below this point sucks. This is just */ |
252 | /* my first implementation to make the option rows work for both */ |
253 | /* Javascript and non-Javascript option chunks. */ |
254 | /* */ |
255 | /* Please, someone make these better for me. All three functions */ |
256 | /* below REALLY do close to the same thing. */ |
257 | /* */ |
258 | /* This code would be GREATLY improved by a templating system. */ |
259 | /* Don't try to implement that now, however. That will come later. */ |
260 | /*******************************************************************/ |
261 | |
262 | /*******************************************************************/ |
263 | /* Actually, now that I think about it, don't do anything with */ |
264 | /* this code yet. There is ACTUALLY supposed to be a difference */ |
265 | /* between the three functions that write the option rows. I just */ |
266 | /* have not yet gotten to integrating that yet. */ |
267 | /*******************************************************************/ |
268 | |
269 | /** |
23d6bd09 |
270 | * This function prints out an option page row. |
849bdf42 |
271 | */ |
272 | function print_optionpages_row($leftopt, $rightopt = false) { |
849bdf42 |
273 | global $color; |
dfec863e |
274 | |
10f0ce72 |
275 | echo "<TABLE BGCOLOR=\"$color[4]\" WIDTH=\"100%\" CELLPADDING=0 CELLSPACING=5 BORDER=0>" . |
276 | '<TR><TD VALIGN="TOP">' . |
277 | '<TABLE WIDTH="100%" CELLPADDING="3" CELLSPACING="0" BORDER="0">' . |
278 | '<TR>' . |
279 | "<TD VALIGN=TOP BGCOLOR=\"$color[9]\" WIDTH=\"50%\">" . |
280 | '<A HREF="' . $leftopt['url'] . '">' . $leftopt['name'] . '</A>'. |
281 | '</TD>'. |
282 | "<TD VALIGN=TOP BGCOLOR=\"$color[4]\"> </TD>"; |
283 | if ($rightopt) { |
284 | echo "<TD VALIGN=top BGCOLOR=\"$color[9]\" WIDTH=\"50%\">" . |
285 | '<A HREF="' . $rightopt['url'] . '">' . $rightopt['name'] . '</A>' . |
286 | '</TD>'; |
56b52934 |
287 | } else { |
10f0ce72 |
288 | echo "<TD VALIGN=top BGCOLOR=\"$color[4]\" WIDTH=\"50%\"> </TD>"; |
56b52934 |
289 | } |
dfec863e |
290 | |
10f0ce72 |
291 | echo '</TR>' . |
292 | '<TR>' . |
293 | "<TD VALIGN=top BGCOLOR=\"$color[0]\">" . |
56b52934 |
294 | $leftopt['desc'] . |
10f0ce72 |
295 | '</TD>' . |
296 | "<TD VALIGN=top BGCOLOR=\"$color[4]\"> </TD>"; |
297 | if ($rightopt) { |
298 | echo "<TD VALIGN=top BGCOLOR=\"$color[0]\">" . |
56b52934 |
299 | $rightopt['desc'] . |
10f0ce72 |
300 | '</TD>'; |
301 | } else { |
302 | echo "<TD VALIGN=top BGCOLOR=\"$color[4]\"> </TD>"; |
56b52934 |
303 | } |
304 | |
10f0ce72 |
305 | echo '</TR>' . |
306 | '</TABLE>' . |
307 | '</TD></TR>' . |
308 | "</TABLE>\n"; |
849bdf42 |
309 | } |
e7db48af |
310 | |
a3ec3c91 |
311 | ?> |