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