edc0b786cb5c9564629b581cc9847d6f56b2db30
[squirrelmail.git] / src / options.php
1 <?php
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');
18
19 ereg ("(^.*/)[^/]+/[^/]+$", $PHP_SELF, $regs);
20 $base_uri = $regs[1];
21
22 if (isset($language)) {
23 setcookie('squirrelmail_language', $language, time()+2592000, $base_uri);
24 $squirrelmail_language = $language;
25 }
26
27 displayPageHeader($color, _("None"));
28
29 ?>
30
31 <br>
32 <table bgcolor="<?php echo $color[0] ?>" width="95%" align="center" cellpadding="2" cellspacing="0" border="0">
33 <tr><td align="center">
34 <b><?php echo _("Options") ?></b><br>
35
36 <table width="100%" border="0" cellpadding="5" cellspacing="0">
37 <tr><td bgcolor="<?php echo $color[4] ?>" align="center">
38
39 <?php
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 }
64
65 do_hook('options_personal_save');
66
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 }
80
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, 'javascript_setting', $new_javascript_setting);
86 setPref($data_dir, $username, 'show_num', $shownum);
87 setPref($data_dir, $username, 'wrap_at', $wrapat);
88 setPref($data_dir, $username, 'editor_size', $editorsize);
89 setPref($data_dir, $username, 'left_refresh', $leftrefresh);
90 setPref($data_dir, $username, 'location_of_bar', $folder_new_location);
91 setPref($data_dir, $username, 'location_of_buttons', $button_new_location);
92 setPref($data_dir, $username, 'left_size', $leftsize);
93
94 if (isset($altIndexColors) && $altIndexColors == 1) {
95 setPref($data_dir, $username, 'alt_index_colors', 1);
96 } else {
97 setPref($data_dir, $username, 'alt_index_colors', 0);
98 }
99
100 setPref($data_dir, $username, 'show_html_default', ($showhtmldefault?1:0) );
101
102 if (isset($includeselfreplyall)) {
103 setPref($data_dir, $username, 'include_self_reply_all', 1);
104 } else {
105 removePref($data_dir, $username, 'include_self_reply_all');
106 }
107
108 if (isset($pageselectormax)) {
109 setPref($data_dir, $username, 'page_selector_max', $pageselectormax);
110 } else {
111 removePref($data_dir, $username, 'page_selector_max', 0 );
112 }
113
114 if (isset($pageselector)) {
115 removePref($data_dir, $username, 'page_selector');
116 } else {
117 setPref($data_dir, $username, 'page_selector', 1);
118 }
119
120 $js_autodetect_results = (isset($js_autodetect_results) ? $js_autodetect_results : SMPREF_JS_OFF);
121 if ($new_javascript_setting == SMPREF_JS_AUTODETECT) {
122 if ($js_autodetect_results == SMPREF_JS_ON) {
123 setPref($data_dir, $username, 'javascript_on', SMPREF_JS_ON);
124 } else {
125 setPref($data_dir, $username, 'javascript_on', SMPREF_JS_OFF);
126 }
127 } else {
128 setPref($data_dir, $username, 'javascript_on', $new_javascript_setting);
129 }
130
131 do_hook('options_display_save');
132
133 echo '<br><b>'._("Successfully saved display preferences!").'</b><br>';
134 echo '<a href="../src/webmail.php?right_frame=options.php" target=_top>' . _("Refresh Page") . '</a><br>';
135 } else if (isset($submit_folder)) {
136 /* Save folder preferences. */
137 if ($trash != 'none') {
138 setPref($data_dir, $username, 'move_to_trash', true);
139 setPref($data_dir, $username, 'trash_folder', $trash);
140 } else {
141 setPref($data_dir, $username, 'move_to_trash', '0');
142 setPref($data_dir, $username, 'trash_folder', 'none');
143 }
144 if ($sent != 'none') {
145 setPref($data_dir, $username, 'move_to_sent', true);
146 setPref($data_dir, $username, 'sent_folder', $sent);
147 } else {
148 setPref($data_dir, $username, 'move_to_sent', '0');
149 setPref($data_dir, $username, 'sent_folder', 'none');
150 }
151 if ($draft != 'none') {
152 setPref($data_dir, $username, 'save_as_draft', true);
153 setPref($data_dir, $username, 'draft_folder', $draft);
154 } else {
155 setPref($data_dir, $username, 'save_as_draft', '0');
156 setPref($data_dir, $username, 'draft_folder', 'none');
157 }
158 if (isset($folderprefix)) {
159 setPref($data_dir, $username, 'folder_prefix', $folderprefix);
160 } else {
161 setPref($data_dir, $username, 'folder_prefix', '');
162 }
163 setPref($data_dir, $username, 'unseen_notify', $unseennotify);
164 setPref($data_dir, $username, 'unseen_type', $unseentype);
165 if (isset($collapsefolders))
166 setPref($data_dir, $username, 'collapse_folders', $collapsefolders);
167 else
168 removePref($data_dir, $username, 'collapse_folders');
169 setPref($data_dir, $username, 'date_format', $dateformat);
170 setPref($data_dir, $username, 'hour_format', $hourformat);
171 do_hook('options_folders_save');
172 echo '<br><b>'._("Successfully saved folder preferences!").'</b><br>';
173 echo '<a href="../src/left_main.php" target=left>' . _("Refresh Folder List") . '</a><br>';
174 } else {
175 do_hook('options_save');
176 }
177
178 /****************************************/
179 /* Now build our array of option pages. */
180 /****************************************/
181
182 /* Build a section for Personal Options. */
183 $optionpages[] = array(
184 'name' => _("Personal Information"),
185 'url' => 'options_personal.php',
186 'desc' => _("This contains personal information about yourself such as your name, your email address, etc."),
187 'js' => false
188 );
189
190 /* Build a section for Display Options. */
191 $optionpages[] = array(
192 'name' => _("Display Preferences"),
193 'url' => 'options_display.php',
194 'desc' => _("You can change the way that SquirrelMail looks and displays information to you, such as the colors, the language, and other settings."),
195 'js' => false
196 );
197
198 /* Build a section for Message Highlighting Options. */
199 $optionpages[] = array(
200 'name' =>_("Message Highlighting"),
201 'url' => 'options_highlight.php',
202 '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."),
203 'js' => false
204 );
205
206 /* Build a section for Folder Options. */
207 $optionpages[] = array(
208 'name' => _("Folder Preferences"),
209 'url' => 'options_folder.php',
210 'desc' => _("These settings change the way your folders are displayed and manipulated."),
211 'js' => false
212 );
213
214 /* Build a section for Index Order Options. */
215 $optionpages[] = array(
216 'name' => _("Index Order"),
217 'url' => 'options_order.php',
218 'desc' => _("The order of the message index can be rearanged and changed to contain the headers in any order you want."),
219 'js' => false
220 );
221 /* Build a section for plugins wanting to register an optionpage. */
222 do_hook('options_register');
223
224 /*****************************************************/
225 /* Let's sort Javascript Option Pages to the bottom. */
226 /*****************************************************/
227 foreach ($optionpages as $optpage) {
228 if (!$optpage['js']) {
229 $reg_optionpages[] = $optpage;
230 } else if ($javascript_on == SMPREF_JS_ON) {
231 $js_optionpages[] = $optpage;
232 }
233 }
234 $optionpages = array_merge($reg_optionpages, $js_optionpages);
235
236 /********************************************/
237 /* Now, print out each option page section. */
238 /********************************************/
239 $first_optpage = false;
240 foreach ($optionpages as $next_optpage) {
241 if ($first_optpage == false) {
242 $first_optpage = $next_optpage;
243 } else {
244 print_optionpages_row($first_optpage, $next_optpage);
245 $first_optpage = false;
246 }
247 }
248
249 if ($first_optpage != false) {
250 print_optionpages_row($first_optpage);
251 }
252
253 do_hook('options_link_and_description');
254
255 ?>
256 </td></tr>
257 </table>
258
259 </td></tr>
260 </table>
261
262 </body></html>
263
264 <?php
265
266 /*******************************************************************/
267 /* Please be warned. The code below this point sucks. This is just */
268 /* my first implementation to make the option rows work for both */
269 /* Javascript and non-Javascript option chunks. */
270 /* */
271 /* Please, someone make these better for me. All three functions */
272 /* below REALLY do close to the same thing. */
273 /* */
274 /* This code would be GREATLY improved by a templating system. */
275 /* Don't try to implement that now, however. That will come later. */
276 /*******************************************************************/
277
278 /*******************************************************************/
279 /* Actually, now that I think about it, don't do anything with */
280 /* this code yet. There is ACTUALLY supposed to be a difference */
281 /* between the three functions that write the option rows. I just */
282 /* have not yet gotten to integrating that yet. */
283 /*******************************************************************/
284
285 /**
286 * This function prints out an option page row.
287 */
288 function print_optionpages_row($leftopt, $rightopt = false) {
289 global $color;
290 ?>
291 <table bgcolor="<?php echo $color[4] ?>" width="100%" cellpadding="0" cellspacing="5" border="0">
292 <tr><td valign=top>
293 <table width="100%" cellpadding="3" cellspacing="0" border="0">
294 <tr>
295 <td valign="top" bgcolor="<?php echo $color[9] ?>" width="50%">
296 <a href="<?php echo $leftopt['url'] ?>"><?php echo $leftopt['name'] ?></a>
297 </td>
298 <td valign="top" bgcolor="<?php echo $color[4] ?>">&nbsp;</td>
299 <?php if ($rightopt != false) { ?>
300 <td valign="top" bgcolor="<?php echo $color[9] ?>" width="50%">
301 <a href="<?php echo $rightopt['url'] ?>"><?php echo $rightopt['name'] ?></a>
302 </td>
303 <?php } else { ?>
304 <td valign="top" bgcolor="<?php echo $color[4] ?>" width="50%">&nbsp;</td>
305 <?php } ?>
306 </tr>
307 <tr>
308 <td valign="top" bgcolor="<?php echo $color[0] ?>">
309 <?php echo $leftopt['desc'] ?>
310 </td>
311 <td valign="top" bgcolor="<?php echo $color[4] ?>">&nbsp;</td>
312 <?php if ($rightopt != false) { ?>
313 <td valign="top" bgcolor="<?php echo $color[0] ?>">
314 <?php echo $rightopt['desc'] ?>
315 </td>
316 <?php } else { ?>
317 <td valign="top" bgcolor="<?php echo $color[4] ?>">&nbsp;</td>
318 <?php } ?>
319 </tr>
320 </table>
321 </td></tr>
322 </table>
323 <?php
324 }
325
326 ?>