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