using hide_sm_attributions instead of hide_sm_attributes
[squirrelmail.git] / include / options / display.php
CommitLineData
c36ed9cf 1<?php
e7db48af 2
35586184 3/**
4 * options_display.php
5 *
35586184 6 * Displays all optinos about display preferences
7 *
47ccfad4 8 * @copyright &copy; 1999-2006 The SquirrelMail Project Team
4b4abf93 9 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
763b63fe 10 * @version $Id$
2b646597 11 * @package squirrelmail
35586184 12 */
cbe5423b 13
2b646597 14/** Define the group constants for the display options page. */
cbe5423b 15define('SMOPT_GRP_GENERAL', 0);
16define('SMOPT_GRP_MAILBOX', 1);
17define('SMOPT_GRP_MESSAGE', 2);
18
6395c46d 19// load icon themes if in use
20global $use_icons;
21if ($use_icons) {
22 global $icon_themes;
23 $dirName = SM_PATH . 'images/themes';
4f7a5870 24 if (is_readable($dirName) && is_dir($dirName)) {
25 $d = dir($dirName);
26 while($dir = $d->read()) {
27 if ($dir != "." && $dir != "..") {
28 if (is_dir($dirName."/".$dir) && file_exists("$dirName/$dir/theme.php"))
29 include("$dirName/$dir/theme.php");
30 }
6395c46d 31 }
32 }
33}
34
a144f6b8 35global $use_iframe;
36if (! isset($use_iframe)) $use_iframe=false;
37
48af4b64 38/**
39 * This function builds an array with all the information about
40 * the options available to the user, and returns it. The options
41 * are grouped by the groups in which they are displayed.
42 * For each option, the following information is stored:
43 * - name: the internal (variable) name
44 * - caption: the description of the option in the UI
45 * - type: one of SMOPT_TYPE_*
46 * - refresh: one of SMOPT_REFRESH_*
47 * - size: one of SMOPT_SIZE_*
48 * - save: the name of a function to call when saving this option
49 * @return array all option information
50 */
cbe5423b 51function load_optpage_data_display() {
299d1d03 52 global $theme, $fontsets, $language, $languages,$aTemplateSet,
ce68b76b 53 $default_use_mdn, $squirrelmail_language, $allow_thread_sort,
299d1d03 54 $show_alternative_names, $use_icons, $use_iframe, $sTplDir;
a3ec3c91 55
ce393174 56 /* Build a simple array into which we will build options. */
bbcafebd 57 $optgrps = array();
58 $optvals = array();
a3ec3c91 59
bbcafebd 60 /******************************************************/
61 /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */
62 /******************************************************/
bbcafebd 63
64 /*** Load the General Options into the array ***/
65 $optgrps[SMOPT_GRP_GENERAL] = _("General Display Options");
66 $optvals[SMOPT_GRP_GENERAL] = array();
67
299d1d03 68 /* load the template set option */
69 $templateset_values = array();
70
71 foreach ($aTemplateSet as $sKey => $aTemplateSetAttributes) {
72 $templateset_values[$aTemplateSetAttributes['NAME']] = $aTemplateSetAttributes['PATH'];
73 }
74 ksort($templateset_values);
75 $templateset_values = array_flip($templateset_values);
76 $optvals[SMOPT_GRP_GENERAL][] = array(
77 'name' => 'sTplDir',
78 'caption' => _("Template"),
79 'type' => SMOPT_TYPE_STRLIST,
80 'refresh' => SMOPT_REFRESH_ALL,
81 'posvals' => $templateset_values,
82 'save' => 'save_option_template'
83 );
84
85
bbcafebd 86 /* Load the theme option. */
ce393174 87 $theme_values = array();
88 foreach ($theme as $theme_key => $theme_attributes) {
be278741 89 $theme_values[$theme_attributes['NAME']] = $theme_attributes['PATH'];
ce393174 90 }
be278741 91 ksort($theme_values);
92 $theme_values = array_flip($theme_values);
bbcafebd 93 $optvals[SMOPT_GRP_GENERAL][] = array(
ce393174 94 'name' => 'chosen_theme',
95 'caption' => _("Theme"),
96 'type' => SMOPT_TYPE_STRLIST,
97 'refresh' => SMOPT_REFRESH_ALL,
cbe5423b 98 'posvals' => $theme_values,
99 'save' => 'save_option_theme'
ce393174 100 );
5d110fa6 101
8f1ba72b 102 $css_values = array( 'none' => _("Default" ) );
bb7173fa 103 $css_dir = SM_PATH . 'themes/css';
104 if (is_readable($css_dir) && is_dir($css_dir)) {
105 $handle=opendir($css_dir);
4f7a5870 106 while ($file = readdir($handle) ) {
107 if ( substr( $file, -4 ) == '.css' ) {
108 $css_values[$file] = substr( $file, 0, strlen( $file ) - 4 );
109 }
8f1ba72b 110 }
4f7a5870 111 closedir($handle);
dcd6f144 112 }
5d110fa6 113
81132de8 114 /*
54078578 115 if ( count( $css_values ) > 1 ) {
5d110fa6 116
e2cdae1f 117 $optvals[SMOPT_GRP_GENERAL][] = array(
118 'name' => 'custom_css',
119 'caption' => _("Custom Stylesheet"),
120 'type' => SMOPT_TYPE_STRLIST,
121 'refresh' => SMOPT_REFRESH_ALL,
122 'posvals' => $css_values
123 );
5d110fa6 124
e2cdae1f 125 }
81132de8 126 */
127
128 $fontset_values = array();
129 foreach (array_keys($fontsets) as $fontset_key) {
130 $fontset_list[$fontset_key]=$fontset_key;
131 }
132 ksort($fontset_list);
133
134 if (count($fontset_list) > 1) {
135 $fontset_list = array_merge(array('' => _("Default font style")), $fontset_list);
136 $optvals[SMOPT_GRP_GENERAL][] = array(
137 'name' => 'chosen_fontset',
138 'caption' => _("Font style"),
139 'type' => SMOPT_TYPE_STRLIST,
140 'refresh' => SMOPT_REFRESH_ALL,
141 'posvals' => $fontset_list
142 );
143 }
144
145 $optvals[SMOPT_GRP_GENERAL][] = array(
146 'name' => 'chosen_fontsize',
147 'caption' => _("Font size"),
148 'type' => SMOPT_TYPE_STRLIST,
149 'refresh' => SMOPT_REFRESH_ALL,
150 'posvals' => array('' => _("Default font size"),
151 '8' => '8 px',
152 '10' => '10 px',
153 '12' => '12 px',
154 '14' => '14 px')
155 );
39d3ec89 156
e557fdb0 157 $language_values = array();
5ba5dc8e 158 foreach ($languages as $lang_key => $lang_attributes) {
159 if (isset($lang_attributes['NAME'])) {
160 $language_values[$lang_key] = $lang_attributes['NAME'];
161 if ( isset($show_alternative_names) &&
162 $show_alternative_names &&
163 isset($lang_attributes['ALTNAME']) ) {
164 $language_values[$lang_key] .= " / " . $lang_attributes['ALTNAME'];
0bb37159 165 }
166 }
ce393174 167 }
5ba5dc8e 168
e557fdb0 169 asort($language_values);
8405d0a4 170 $language_values =
171 array_merge(array('' => _("Default")), $language_values);
ec2c91a1 172 $language = $squirrelmail_language;
5ba5dc8e 173
299d1d03 174 // add language selection only when more than 2 languages are available
48d5ec1f 175 // (default, English and some other)
176 if (count($language_values)>2) {
177 $optvals[SMOPT_GRP_GENERAL][] = array(
178 'name' => 'language',
179 'caption' => _("Language"),
180 'type' => SMOPT_TYPE_STRLIST,
181 'refresh' => SMOPT_REFRESH_ALL,
182 'posvals' => $language_values,
183 'htmlencoded' => true
184 );
185 }
ce393174 186
a3ec3c91 187 /* Set values for the "use javascript" option. */
bbcafebd 188 $optvals[SMOPT_GRP_GENERAL][] = array(
a3ec3c91 189 'name' => 'javascript_setting',
ce393174 190 'caption' => _("Use Javascript"),
a3ec3c91 191 'type' => SMOPT_TYPE_STRLIST,
192 'refresh' => SMOPT_REFRESH_ALL,
193 'posvals' => array(SMPREF_JS_AUTODETECT => _("Autodetect"),
194 SMPREF_JS_ON => _("Always"),
ae958cd3 195 SMPREF_JS_OFF => _("Never")),
196 'save' => 'save_option_javascript_autodetect',
197 'script' => 'onclick="document.forms[0].new_js_autodetect_results.value = \'' . SMPREF_JS_ON . '\';"'
a3ec3c91 198 );
199
bbcafebd 200 $optvals[SMOPT_GRP_GENERAL][] = array(
a3ec3c91 201 'name' => 'js_autodetect_results',
202 'caption' => '',
203 'type' => SMOPT_TYPE_HIDDEN,
ae958cd3 204 'refresh' => SMOPT_REFRESH_NONE
5826affb 205 //'post_script' => $js_autodetect_script,
a3ec3c91 206 );
f2df3fa1 207
5bcd1b00 208 $optvals[SMOPT_GRP_GENERAL][] = array(
209 'name' => 'hour_format',
210 'caption' => _("Hour Format"),
211 'type' => SMOPT_TYPE_STRLIST,
212 'refresh' => SMOPT_REFRESH_FOLDERLIST,
213 'posvals' => array(SMPREF_TIME_12HR => _("12-hour clock"),
214 SMPREF_TIME_24HR => _("24-hour clock"))
215 );
a3ec3c91 216
bbcafebd 217 /*** Load the General Options into the array ***/
218 $optgrps[SMOPT_GRP_MAILBOX] = _("Mailbox Display Options");
219 $optvals[SMOPT_GRP_MAILBOX] = array();
220
221 $optvals[SMOPT_GRP_MAILBOX][] = array(
a3ec3c91 222 'name' => 'show_num',
f2df3fa1 223 'caption' => _("Number of Messages per Page"),
a3ec3c91 224 'type' => SMOPT_TYPE_INTEGER,
bbcafebd 225 'refresh' => SMOPT_REFRESH_NONE,
226 'size' => SMOPT_SIZE_TINY
a3ec3c91 227 );
228
bbcafebd 229 $optvals[SMOPT_GRP_MAILBOX][] = array(
a440e68f 230 'name' => 'alt_index_colors',
231 'caption' => _("Enable Alternating Row Colors"),
232 'type' => SMOPT_TYPE_BOOLEAN,
233 'refresh' => SMOPT_REFRESH_NONE
234 );
235
18adc53f 236 $optvals[SMOPT_GRP_MAILBOX][] = array(
237 'name' => 'fancy_index_highlite',
238 'caption' => _("Enable Fancy Row Mouseover Highlighting"),
239 'type' => SMOPT_TYPE_BOOLEAN,
240 'refresh' => SMOPT_REFRESH_NONE
241 );
242
6395c46d 243 if ($use_icons) {
244 global $icon_themes, $icon_theme;
245 $temp = array();
246 for ($count = 0; $count < sizeof($icon_themes); $count++) {
247 $temp[$count] = $icon_themes[$count]['NAME'];
248 if ($icon_theme == $icon_themes[$count]['PATH'])
249 $value = $count;
250 }
4f7a5870 251 if (sizeof($icon_themes) > 0) {
252 $optvals[SMOPT_GRP_MAILBOX][] = array(
253 'name' => 'icon_theme',
254 'caption' => _("Message Flags Icon Theme"),
255 'type' => SMOPT_TYPE_STRLIST,
256 'refresh' => SMOPT_REFRESH_NONE,
257 'posvals' => $temp,
258 'initial_value' => $value,
259 'save' => 'icon_theme_save'
260 );
261 }
6395c46d 262 }
263
bbcafebd 264 $optvals[SMOPT_GRP_MAILBOX][] = array(
fd181f53 265 'name' => 'show_flag_buttons',
266 'caption' => _("Show Flag / Unflag Buttons"),
267 'type' => SMOPT_TYPE_BOOLEAN,
268 'refresh' => SMOPT_REFRESH_NONE
269 );
270
271 $optvals[SMOPT_GRP_MAILBOX][] = array(
a440e68f 272 'name' => 'page_selector',
273 'caption' => _("Enable Page Selector"),
274 'type' => SMOPT_TYPE_BOOLEAN,
275 'refresh' => SMOPT_REFRESH_NONE
276 );
277
bbcafebd 278 $optvals[SMOPT_GRP_MAILBOX][] = array(
0bb37159 279 'name' => 'compact_paginator',
280 'caption' => _("Use Compact Page Selector"),
281 'type' => SMOPT_TYPE_BOOLEAN,
282 'refresh' => SMOPT_REFRESH_NONE
283 );
284
285 $optvals[SMOPT_GRP_MAILBOX][] = array(
a440e68f 286 'name' => 'page_selector_max',
287 'caption' => _("Maximum Number of Pages to Show"),
288 'type' => SMOPT_TYPE_INTEGER,
bbcafebd 289 'refresh' => SMOPT_REFRESH_NONE,
290 'size' => SMOPT_SIZE_TINY
a440e68f 291 );
292
3e3b60e3 293 $optvals[SMOPT_GRP_MAILBOX][] = array(
294 'name' => 'show_full_date',
295 'caption' => _("Always Show Full Date"),
296 'type' => SMOPT_TYPE_BOOLEAN,
297 'refresh' => SMOPT_REFRESH_NONE
298 );
299
459e3347 300 $optvals[SMOPT_GRP_MAILBOX][] = array(
301 'name' => 'truncate_sender',
302 'caption' => _("Length of From/To Field (0 for full)"),
303 'type' => SMOPT_TYPE_INTEGER,
304 'refresh' => SMOPT_REFRESH_NONE,
305 'size' => SMOPT_SIZE_TINY
306 );
307
3fc1a95f 308 $optvals[SMOPT_GRP_MAILBOX][] = array(
309 'name' => 'truncate_subject',
310 'caption' => _("Length of Subject Field (0 for full)"),
311 'type' => SMOPT_TYPE_INTEGER,
312 'refresh' => SMOPT_REFRESH_NONE,
313 'size' => SMOPT_SIZE_TINY
314 );
91c27aee 315/*
316 disabled because the template doesn't support it (yet?)
1ae2832e 317 $optvals[SMOPT_GRP_MAILBOX][] = array(
318 'name' => 'show_recipient_instead',
319 'caption' => _("Show recipient name if the message is from your default identity"),
320 'type' => SMOPT_TYPE_BOOLEAN,
321 'refresh' => SMOPT_REFRESH_NONE,
322 'size' => SMOPT_SIZE_TINY
323 );
91c27aee 324*/
f2df3fa1 325
5ed9d4fd 326 if ($allow_thread_sort == TRUE) {
327 $optvals[SMOPT_GRP_MAILBOX][] = array(
328 'name' => 'sort_by_ref',
329 'caption' => _("Enable Thread Sort by References Header"),
330 'type' => SMOPT_TYPE_BOOLEAN,
331 'refresh' => SMOPT_REFRESH_ALL
332 );
333 }
334
1ae2832e 335
459e3347 336
bbcafebd 337 /*** Load the General Options into the array ***/
5ed9d4fd 338 $optgrps[SMOPT_GRP_MESSAGE] = _("Message Display Options");
bbcafebd 339 $optvals[SMOPT_GRP_MESSAGE] = array();
340
341 $optvals[SMOPT_GRP_MESSAGE][] = array(
a3ec3c91 342 'name' => 'wrap_at',
343 'caption' => _("Wrap Incoming Text At"),
344 'type' => SMOPT_TYPE_INTEGER,
bbcafebd 345 'refresh' => SMOPT_REFRESH_NONE,
346 'size' => SMOPT_SIZE_TINY
a3ec3c91 347 );
348
bbcafebd 349 $optvals[SMOPT_GRP_MESSAGE][] = array(
fd87494d 350 'name' => 'show_html_default',
351 'caption' => _("Show HTML Version by Default"),
352 'type' => SMOPT_TYPE_BOOLEAN,
353 'refresh' => SMOPT_REFRESH_NONE
354 );
355
a144f6b8 356 if ($use_iframe) {
357 // Type is set to string in order to be able to use 100%.
358 $optvals[SMOPT_GRP_MESSAGE][] = array(
359 'name' => 'iframe_height',
360 'caption' => _("Height of inline frame"),
361 'type' => SMOPT_TYPE_STRING,
362 'size' => SMOPT_SIZE_TINY,
363 'refresh' => SMOPT_REFRESH_NONE
364 );
365 }
bbcafebd 366 $optvals[SMOPT_GRP_MESSAGE][] = array(
6206f6c4 367 'name' => 'enable_forward_as_attachment',
368 'caption' => _("Enable Forward as Attachment"),
fd87494d 369 'type' => SMOPT_TYPE_BOOLEAN,
370 'refresh' => SMOPT_REFRESH_NONE
371 );
372
bbcafebd 373 $optvals[SMOPT_GRP_MESSAGE][] = array(
9ab0d96f 374 'name' => 'show_xmailer_default',
a440e68f 375 'caption' => _("Enable Mailer Display"),
9ab0d96f 376 'type' => SMOPT_TYPE_BOOLEAN,
377 'refresh' => SMOPT_REFRESH_NONE
378 );
379
7baf86a9 380 $optvals[SMOPT_GRP_MESSAGE][] = array(
381 'name' => 'attachment_common_show_images',
10f0ce72 382 'caption' => _("Display Attached Images with Message"),
7baf86a9 383 'type' => SMOPT_TYPE_BOOLEAN,
384 'refresh' => SMOPT_REFRESH_NONE
385 );
386
57257333 387 if ($default_use_mdn) {
388 $optvals[SMOPT_GRP_MESSAGE][] = array(
389 'name' => 'mdn_user_support',
6206f6c4 390 'caption' => _("Enable Mail Delivery Notification"),
57257333 391 'type' => SMOPT_TYPE_BOOLEAN,
392 'refresh' => SMOPT_REFRESH_NONE
393 );
394 }
07687736 395
9c3e6cd4 396 $optvals[SMOPT_GRP_MESSAGE][] = array(
4267d5de 397 'name' => 'delete_prev_next_display',
398 'caption' => _("Show 'Delete & Prev/Next' Links"),
399 'type' => SMOPT_TYPE_BOOLEAN,
400 'refresh' => SMOPT_REFRESH_ALL
401 );
5d110fa6 402
cbe5423b 403 /* Assemble all this together and return it as our result. */
404 $result = array(
405 'grps' => $optgrps,
ae958cd3 406 'vals' => $optvals
cbe5423b 407 );
408 return ($result);
409}
a3ec3c91 410
cbe5423b 411/******************************************************************/
412/** Define any specialized save functions for this option page. ***/
413/******************************************************************/
f1e6f580 414
48af4b64 415/**
299d1d03 416 * This function saves a new template setting.
417 * It updates the template array.
418 */
419function save_option_template($option) {
420 global $aTemplateSet;
421
422 /* Do checking to make sure $new_theme is in the array. */
423 $templateset_in_array = false;
424 for ($i = 0; $i < count($aTemplateSet); ++$i) {
425 if ($aTemplateSet[$i]['PATH'] == $option->new_value) {
426 $templateset_in_array = true;
427 break;
428 }
429 }
430
431 if (!$templateset_in_array) {
432 $option->new_value = '';
433 }
434 /* Save the option like normal. */
435 save_option($option);
436}
437
438/**
48af4b64 439 * This function saves a new theme setting.
440 * It updates the theme array.
441 */
cbe5423b 442function save_option_theme($option) {
443 global $theme;
bb7173fa 444
cbe5423b 445 /* Do checking to make sure $new_theme is in the array. */
446 $theme_in_array = false;
447 for ($i = 0; $i < count($theme); ++$i) {
448 if ($theme[$i]['PATH'] == $option->new_value) {
449 $theme_in_array = true;
450 break;
451 }
452 }
453
454 if (!$theme_in_array) {
455 $option->new_value = '';
456 }
e7db48af 457
cbe5423b 458 /* Save the option like normal. */
459 save_option($option);
460}
e7db48af 461
48af4b64 462/**
463 * This function saves the javascript detection option.
464 */
cbe5423b 465function save_option_javascript_autodetect($option) {
ae958cd3 466 save_option($option);
467 checkForJavascript(TRUE);
cbe5423b 468}
469
5d110fa6 470/**
6395c46d 471 * This function saves the user's icon theme setting
472 */
473function icon_theme_save($option) {
474
475 global $icon_themes, $data_dir, $username;
476
477
5d110fa6 478 // Don't assume the new value is there, double check
479 // and only save if found
6395c46d 480 //
481 if (isset($icon_themes[$option->new_value]['PATH']))
482 setPref($data_dir, $username, 'icon_theme', $icon_themes[$option->new_value]['PATH']);
483 else
484 setPref($data_dir, $username, 'icon_theme', 'none');
485
486}
487
f8a1ed5a 488?>