c36ed9cf |
1 | <?php |
e7db48af |
2 | |
35586184 |
3 | /** |
4 | * options_display.php |
5 | * |
76911253 |
6 | * Copyright (c) 1999-2003 The SquirrelMail Project Team |
35586184 |
7 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
8 | * |
9 | * Displays all optinos about display preferences |
10 | * |
11 | * $Id$ |
2b646597 |
12 | * @package squirrelmail |
35586184 |
13 | */ |
cbe5423b |
14 | |
2b646597 |
15 | /** Define the group constants for the display options page. */ |
cbe5423b |
16 | define('SMOPT_GRP_GENERAL', 0); |
17 | define('SMOPT_GRP_MAILBOX', 1); |
18 | define('SMOPT_GRP_MESSAGE', 2); |
19 | |
20 | /* Define the optpage load function for the display options page. */ |
21 | function load_optpage_data_display() { |
ec2c91a1 |
22 | global $theme, $language, $languages, $js_autodetect_results, |
46dfa56e |
23 | $compose_new_win, $default_use_mdn, $squirrelmail_language, $allow_thread_sort, |
39d3ec89 |
24 | $optmode, $show_alternative_names, $available_languages; |
a3ec3c91 |
25 | |
ce393174 |
26 | /* Build a simple array into which we will build options. */ |
bbcafebd |
27 | $optgrps = array(); |
28 | $optvals = array(); |
a3ec3c91 |
29 | |
bbcafebd |
30 | /******************************************************/ |
31 | /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */ |
32 | /******************************************************/ |
bbcafebd |
33 | |
34 | /*** Load the General Options into the array ***/ |
35 | $optgrps[SMOPT_GRP_GENERAL] = _("General Display Options"); |
36 | $optvals[SMOPT_GRP_GENERAL] = array(); |
37 | |
38 | /* Load the theme option. */ |
ce393174 |
39 | $theme_values = array(); |
40 | foreach ($theme as $theme_key => $theme_attributes) { |
be278741 |
41 | $theme_values[$theme_attributes['NAME']] = $theme_attributes['PATH']; |
ce393174 |
42 | } |
be278741 |
43 | ksort($theme_values); |
44 | $theme_values = array_flip($theme_values); |
bbcafebd |
45 | $optvals[SMOPT_GRP_GENERAL][] = array( |
ce393174 |
46 | 'name' => 'chosen_theme', |
47 | 'caption' => _("Theme"), |
48 | 'type' => SMOPT_TYPE_STRLIST, |
49 | 'refresh' => SMOPT_REFRESH_ALL, |
cbe5423b |
50 | 'posvals' => $theme_values, |
51 | 'save' => 'save_option_theme' |
ce393174 |
52 | ); |
8f1ba72b |
53 | |
54 | $css_values = array( 'none' => _("Default" ) ); |
dcd6f144 |
55 | $handle=opendir('../themes/css/'); |
56 | while ($file = readdir($handle) ) { |
57 | if ( substr( $file, -4 ) == '.css' ) { |
58 | $css_values[$file] = substr( $file, 0, strlen( $file ) - 4 ); |
8f1ba72b |
59 | } |
dcd6f144 |
60 | } |
61 | closedir($handle); |
8f1ba72b |
62 | |
54078578 |
63 | if ( count( $css_values ) > 1 ) { |
e2cdae1f |
64 | |
65 | $optvals[SMOPT_GRP_GENERAL][] = array( |
66 | 'name' => 'custom_css', |
67 | 'caption' => _("Custom Stylesheet"), |
68 | 'type' => SMOPT_TYPE_STRLIST, |
69 | 'refresh' => SMOPT_REFRESH_ALL, |
70 | 'posvals' => $css_values |
71 | ); |
72 | |
73 | } |
39d3ec89 |
74 | |
75 | // config.php can be unupdated. |
76 | if (! isset($available_languages) || $available_languages=="" ) { |
77 | $available_languages="ALL"; } |
8f1ba72b |
78 | |
e557fdb0 |
79 | $language_values = array(); |
39d3ec89 |
80 | if ( strtoupper($available_languages)=='ALL') { |
81 | foreach ($languages as $lang_key => $lang_attributes) { |
82 | if (isset($lang_attributes['NAME'])) { |
83 | $language_values[$lang_key] = $lang_attributes['NAME']; |
84 | if ( isset($show_alternative_names) && |
85 | $show_alternative_names && |
86 | isset($lang_attributes['ALTNAME']) ) { |
87 | $language_values[$lang_key] .= " / " . $lang_attributes['ALTNAME']; |
88 | } |
89 | } |
90 | } |
91 | } else if (strtoupper($available_languages)!='NONE') { |
92 | // admin can set list of available languages in config |
93 | $available_languages_array=explode (" ",$available_languages); |
94 | foreach ($available_languages_array as $lang_key ) { |
95 | if (isset($languages[$lang_key]['NAME'])) { |
96 | $language_values[$lang_key] = $languages[$lang_key]['NAME']; |
97 | if ( isset($show_alternative_names) && |
98 | $show_alternative_names && |
99 | isset($languages[$lang_key]['ALTNAME']) ) { |
100 | $language_values[$lang_key] .= " / " . $languages[$lang_key]['ALTNAME']; |
101 | } |
102 | } |
103 | } |
ce393174 |
104 | } |
e557fdb0 |
105 | asort($language_values); |
8405d0a4 |
106 | $language_values = |
107 | array_merge(array('' => _("Default")), $language_values); |
ec2c91a1 |
108 | $language = $squirrelmail_language; |
39d3ec89 |
109 | if (strtoupper($available_languages)!='NONE') { |
110 | // if set to 'none', interface will use only default language |
111 | $optvals[SMOPT_GRP_GENERAL][] = array( |
112 | 'name' => 'language', |
113 | 'caption' => _("Language"), |
114 | 'type' => SMOPT_TYPE_STRLIST, |
115 | 'refresh' => SMOPT_REFRESH_ALL, |
116 | 'posvals' => $language_values |
117 | ); |
118 | } |
ce393174 |
119 | |
a3ec3c91 |
120 | /* Set values for the "use javascript" option. */ |
bbcafebd |
121 | $optvals[SMOPT_GRP_GENERAL][] = array( |
a3ec3c91 |
122 | 'name' => 'javascript_setting', |
ce393174 |
123 | 'caption' => _("Use Javascript"), |
a3ec3c91 |
124 | 'type' => SMOPT_TYPE_STRLIST, |
125 | 'refresh' => SMOPT_REFRESH_ALL, |
126 | 'posvals' => array(SMPREF_JS_AUTODETECT => _("Autodetect"), |
127 | SMPREF_JS_ON => _("Always"), |
128 | SMPREF_JS_OFF => _("Never")) |
129 | ); |
130 | |
46dfa56e |
131 | |
132 | if ($optmode != 'submit') |
133 | $onLoadScript = 'document.forms[0].new_js_autodetect_results.value = \'' . SMPREF_JS_ON . '\''; |
134 | else |
135 | $onLoadScript = ''; |
136 | |
bbcafebd |
137 | $optvals[SMOPT_GRP_GENERAL][] = array( |
a3ec3c91 |
138 | 'name' => 'js_autodetect_results', |
139 | 'caption' => '', |
140 | 'type' => SMOPT_TYPE_HIDDEN, |
cbe5423b |
141 | 'refresh' => SMOPT_REFRESH_NONE, |
5826affb |
142 | //'post_script' => $js_autodetect_script, |
cbe5423b |
143 | 'save' => 'save_option_javascript_autodetect' |
a3ec3c91 |
144 | ); |
145 | |
bbcafebd |
146 | /*** Load the General Options into the array ***/ |
147 | $optgrps[SMOPT_GRP_MAILBOX] = _("Mailbox Display Options"); |
148 | $optvals[SMOPT_GRP_MAILBOX] = array(); |
149 | |
150 | $optvals[SMOPT_GRP_MAILBOX][] = array( |
a3ec3c91 |
151 | 'name' => 'show_num', |
152 | 'caption' => _("Number of Messages to Index"), |
153 | 'type' => SMOPT_TYPE_INTEGER, |
bbcafebd |
154 | 'refresh' => SMOPT_REFRESH_NONE, |
155 | 'size' => SMOPT_SIZE_TINY |
a3ec3c91 |
156 | ); |
157 | |
bbcafebd |
158 | $optvals[SMOPT_GRP_MAILBOX][] = array( |
a440e68f |
159 | 'name' => 'alt_index_colors', |
160 | 'caption' => _("Enable Alternating Row Colors"), |
161 | 'type' => SMOPT_TYPE_BOOLEAN, |
162 | 'refresh' => SMOPT_REFRESH_NONE |
163 | ); |
164 | |
bbcafebd |
165 | $optvals[SMOPT_GRP_MAILBOX][] = array( |
a440e68f |
166 | 'name' => 'page_selector', |
167 | 'caption' => _("Enable Page Selector"), |
168 | 'type' => SMOPT_TYPE_BOOLEAN, |
169 | 'refresh' => SMOPT_REFRESH_NONE |
170 | ); |
171 | |
bbcafebd |
172 | $optvals[SMOPT_GRP_MAILBOX][] = array( |
a440e68f |
173 | 'name' => 'page_selector_max', |
174 | 'caption' => _("Maximum Number of Pages to Show"), |
175 | 'type' => SMOPT_TYPE_INTEGER, |
bbcafebd |
176 | 'refresh' => SMOPT_REFRESH_NONE, |
177 | 'size' => SMOPT_SIZE_TINY |
a440e68f |
178 | ); |
179 | |
3e3b60e3 |
180 | $optvals[SMOPT_GRP_MAILBOX][] = array( |
181 | 'name' => 'show_full_date', |
182 | 'caption' => _("Always Show Full Date"), |
183 | 'type' => SMOPT_TYPE_BOOLEAN, |
184 | 'refresh' => SMOPT_REFRESH_NONE |
185 | ); |
186 | |
459e3347 |
187 | $optvals[SMOPT_GRP_MAILBOX][] = array( |
188 | 'name' => 'truncate_sender', |
189 | 'caption' => _("Length of From/To Field (0 for full)"), |
190 | 'type' => SMOPT_TYPE_INTEGER, |
191 | 'refresh' => SMOPT_REFRESH_NONE, |
192 | 'size' => SMOPT_SIZE_TINY |
193 | ); |
194 | |
3fc1a95f |
195 | $optvals[SMOPT_GRP_MAILBOX][] = array( |
196 | 'name' => 'truncate_subject', |
197 | 'caption' => _("Length of Subject Field (0 for full)"), |
198 | 'type' => SMOPT_TYPE_INTEGER, |
199 | 'refresh' => SMOPT_REFRESH_NONE, |
200 | 'size' => SMOPT_SIZE_TINY |
201 | ); |
202 | |
1ae2832e |
203 | $optvals[SMOPT_GRP_MAILBOX][] = array( |
204 | 'name' => 'show_recipient_instead', |
205 | 'caption' => _("Show recipient name if the message is from your default identity"), |
206 | 'type' => SMOPT_TYPE_BOOLEAN, |
207 | 'refresh' => SMOPT_REFRESH_NONE, |
208 | 'size' => SMOPT_SIZE_TINY |
209 | ); |
210 | |
459e3347 |
211 | |
bbcafebd |
212 | /*** Load the General Options into the array ***/ |
213 | $optgrps[SMOPT_GRP_MESSAGE] = _("Message Display and Composition"); |
214 | $optvals[SMOPT_GRP_MESSAGE] = array(); |
215 | |
216 | $optvals[SMOPT_GRP_MESSAGE][] = array( |
a3ec3c91 |
217 | 'name' => 'wrap_at', |
218 | 'caption' => _("Wrap Incoming Text At"), |
219 | 'type' => SMOPT_TYPE_INTEGER, |
bbcafebd |
220 | 'refresh' => SMOPT_REFRESH_NONE, |
221 | 'size' => SMOPT_SIZE_TINY |
a3ec3c91 |
222 | ); |
223 | |
bbcafebd |
224 | $optvals[SMOPT_GRP_MESSAGE][] = array( |
a3ec3c91 |
225 | 'name' => 'editor_size', |
226 | 'caption' => _("Size of Editor Window"), |
227 | 'type' => SMOPT_TYPE_INTEGER, |
bbcafebd |
228 | 'refresh' => SMOPT_REFRESH_NONE, |
229 | 'size' => SMOPT_SIZE_TINY |
a3ec3c91 |
230 | ); |
231 | |
bbcafebd |
232 | $optvals[SMOPT_GRP_MESSAGE][] = array( |
a3ec3c91 |
233 | 'name' => 'location_of_buttons', |
ce393174 |
234 | 'caption' => _("Location of Buttons when Composing"), |
a3ec3c91 |
235 | 'type' => SMOPT_TYPE_STRLIST, |
236 | 'refresh' => SMOPT_REFRESH_NONE, |
ce393174 |
237 | 'posvals' => array(SMPREF_LOC_TOP => _("Before headers"), |
238 | SMPREF_LOC_BETWEEN => _("Between headers and message body"), |
239 | SMPREF_LOC_BOTTOM => _("After message body")) |
a3ec3c91 |
240 | ); |
241 | |
07687736 |
242 | |
bbcafebd |
243 | $optvals[SMOPT_GRP_MESSAGE][] = array( |
a440e68f |
244 | 'name' => 'use_javascript_addr_book', |
245 | 'caption' => _("Addressbook Display Format"), |
ce393174 |
246 | 'type' => SMOPT_TYPE_STRLIST, |
a440e68f |
247 | 'refresh' => SMOPT_REFRESH_NONE, |
248 | 'posvals' => array('1' => _("Javascript"), |
249 | '0' => _("HTML")) |
fd87494d |
250 | ); |
251 | |
bbcafebd |
252 | $optvals[SMOPT_GRP_MESSAGE][] = array( |
fd87494d |
253 | 'name' => 'show_html_default', |
254 | 'caption' => _("Show HTML Version by Default"), |
255 | 'type' => SMOPT_TYPE_BOOLEAN, |
256 | 'refresh' => SMOPT_REFRESH_NONE |
257 | ); |
258 | |
bbcafebd |
259 | $optvals[SMOPT_GRP_MESSAGE][] = array( |
6206f6c4 |
260 | 'name' => 'enable_forward_as_attachment', |
261 | 'caption' => _("Enable Forward as Attachment"), |
fd87494d |
262 | 'type' => SMOPT_TYPE_BOOLEAN, |
263 | 'refresh' => SMOPT_REFRESH_NONE |
264 | ); |
265 | |
bbcafebd |
266 | $optvals[SMOPT_GRP_MESSAGE][] = array( |
a0bc3274 |
267 | 'name' => 'forward_cc', |
6206f6c4 |
268 | 'caption' => _("Include CCs when Forwarding Messages"), |
269 | 'type' => SMOPT_TYPE_BOOLEAN, |
270 | 'refresh' => SMOPT_REFRESH_NONE |
271 | ); |
272 | |
273 | $optvals[SMOPT_GRP_MESSAGE][] = array( |
274 | 'name' => 'include_self_reply_all', |
275 | 'caption' => _("Include Me in CC when I Reply All"), |
a0bc3274 |
276 | 'type' => SMOPT_TYPE_BOOLEAN, |
277 | 'refresh' => SMOPT_REFRESH_NONE |
278 | ); |
279 | |
280 | $optvals[SMOPT_GRP_MESSAGE][] = array( |
9ab0d96f |
281 | 'name' => 'show_xmailer_default', |
a440e68f |
282 | 'caption' => _("Enable Mailer Display"), |
9ab0d96f |
283 | 'type' => SMOPT_TYPE_BOOLEAN, |
284 | 'refresh' => SMOPT_REFRESH_NONE |
285 | ); |
286 | |
7baf86a9 |
287 | $optvals[SMOPT_GRP_MESSAGE][] = array( |
288 | 'name' => 'attachment_common_show_images', |
10f0ce72 |
289 | 'caption' => _("Display Attached Images with Message"), |
7baf86a9 |
290 | 'type' => SMOPT_TYPE_BOOLEAN, |
291 | 'refresh' => SMOPT_REFRESH_NONE |
292 | ); |
293 | |
f226cba7 |
294 | $optvals[SMOPT_GRP_MESSAGE][] = array( |
f226cba7 |
295 | 'name' => 'pf_cleandisplay', |
10f0ce72 |
296 | 'caption' => _("Enable Printer Friendly Clean Display"), |
f226cba7 |
297 | 'type' => SMOPT_TYPE_BOOLEAN, |
298 | 'refresh' => SMOPT_REFRESH_NONE |
299 | ); |
07687736 |
300 | |
57257333 |
301 | if ($default_use_mdn) { |
302 | $optvals[SMOPT_GRP_MESSAGE][] = array( |
303 | 'name' => 'mdn_user_support', |
6206f6c4 |
304 | 'caption' => _("Enable Mail Delivery Notification"), |
57257333 |
305 | 'type' => SMOPT_TYPE_BOOLEAN, |
306 | 'refresh' => SMOPT_REFRESH_NONE |
307 | ); |
308 | } |
07687736 |
309 | |
9c3e6cd4 |
310 | $optvals[SMOPT_GRP_MESSAGE][] = array( |
311 | 'name' => 'compose_new_win', |
6206f6c4 |
312 | 'caption' => _("Compose Messages in New Window"), |
9c3e6cd4 |
313 | 'type' => SMOPT_TYPE_BOOLEAN, |
314 | 'refresh' => SMOPT_REFRESH_ALL |
315 | ); |
07687736 |
316 | |
317 | $optvals[SMOPT_GRP_MESSAGE][] = array( |
318 | 'name' => 'compose_width', |
6206f6c4 |
319 | 'caption' => _("Width of Compose Window"), |
07687736 |
320 | 'type' => SMOPT_TYPE_INTEGER, |
321 | 'refresh' => SMOPT_REFRESH_ALL, |
322 | 'size' => SMOPT_SIZE_TINY |
323 | ); |
324 | |
325 | $optvals[SMOPT_GRP_MESSAGE][] = array( |
326 | 'name' => 'compose_height', |
6206f6c4 |
327 | 'caption' => _("Height of Compose Window"), |
07687736 |
328 | 'type' => SMOPT_TYPE_INTEGER, |
329 | 'refresh' => SMOPT_REFRESH_ALL, |
330 | 'size' => SMOPT_SIZE_TINY |
331 | ); |
332 | |
3b17e952 |
333 | $optvals[SMOPT_GRP_MESSAGE][] = array( |
334 | 'name' => 'sig_first', |
6206f6c4 |
335 | 'caption' => _("Append Signature before Reply/Forward Text"), |
3b17e952 |
336 | 'type' => SMOPT_TYPE_BOOLEAN, |
337 | 'refresh' => SMOPT_REFRESH_NONE |
338 | ); |
07687736 |
339 | |
df9fdeb9 |
340 | $optvals[SMOPT_GRP_MESSAGE][] = array( |
9f2f6126 |
341 | 'name' => 'reply_focus', |
342 | 'caption' => _("Cursor Position when Replying"), |
343 | 'type' => SMOPT_TYPE_STRLIST, |
344 | 'refresh' => SMOPT_REFRESH_NONE, |
345 | 'posvals' => array('' => _("To: field"), |
346 | 'focus' => _("Focus in body"), |
347 | 'select' => _("Select body")) |
348 | ); |
349 | |
350 | $optvals[SMOPT_GRP_MESSAGE][] = array( |
4ee86d70 |
351 | 'name' => 'strip_sigs', |
352 | 'caption' => _("Strip signature when replying"), |
353 | 'type' => SMOPT_TYPE_BOOLEAN, |
354 | 'refresh' => SMOPT_REFRESH_NONE |
355 | ); |
356 | |
357 | $optvals[SMOPT_GRP_MESSAGE][] = array( |
df9fdeb9 |
358 | 'name' => 'internal_date_sort', |
6206f6c4 |
359 | 'caption' => _("Enable Sort by of Receive Date"), |
df9fdeb9 |
360 | 'type' => SMOPT_TYPE_BOOLEAN, |
361 | 'refresh' => SMOPT_REFRESH_ALL |
362 | ); |
794d59c0 |
363 | if ($allow_thread_sort == TRUE) { |
7c612fdd |
364 | $optvals[SMOPT_GRP_MESSAGE][] = array( |
365 | 'name' => 'sort_by_ref', |
6206f6c4 |
366 | 'caption' => _("Enable Thread Sort by References Header"), |
7c612fdd |
367 | 'type' => SMOPT_TYPE_BOOLEAN, |
368 | 'refresh' => SMOPT_REFRESH_ALL |
369 | ); |
370 | } |
cbe5423b |
371 | /* Assemble all this together and return it as our result. */ |
372 | $result = array( |
373 | 'grps' => $optgrps, |
5826affb |
374 | 'vals' => $optvals, |
375 | 'xtra' => $onLoadScript |
cbe5423b |
376 | ); |
377 | return ($result); |
378 | } |
a3ec3c91 |
379 | |
cbe5423b |
380 | /******************************************************************/ |
381 | /** Define any specialized save functions for this option page. ***/ |
382 | /******************************************************************/ |
f1e6f580 |
383 | |
cbe5423b |
384 | function save_option_theme($option) { |
385 | global $theme; |
e7db48af |
386 | |
cbe5423b |
387 | /* Do checking to make sure $new_theme is in the array. */ |
388 | $theme_in_array = false; |
389 | for ($i = 0; $i < count($theme); ++$i) { |
390 | if ($theme[$i]['PATH'] == $option->new_value) { |
391 | $theme_in_array = true; |
392 | break; |
393 | } |
394 | } |
395 | |
396 | if (!$theme_in_array) { |
397 | $option->new_value = ''; |
398 | } |
e7db48af |
399 | |
cbe5423b |
400 | /* Save the option like normal. */ |
401 | save_option($option); |
402 | } |
e7db48af |
403 | |
cbe5423b |
404 | function save_option_javascript_autodetect($option) { |
405 | global $data_dir, $username, $new_javascript_setting; |
23d6bd09 |
406 | |
cbe5423b |
407 | /* Set javascript either on or off. */ |
408 | if ($new_javascript_setting == SMPREF_JS_AUTODETECT) { |
409 | if ($option->new_value == SMPREF_JS_ON) { |
410 | setPref($data_dir, $username, 'javascript_on', SMPREF_JS_ON); |
411 | } else { |
412 | setPref($data_dir, $username, 'javascript_on', SMPREF_JS_OFF); |
413 | } |
414 | } else { |
415 | setPref($data_dir, $username, 'javascript_on', $new_javascript_setting); |
416 | } |
417 | } |
418 | |
419 | ?> |