6 * Copyright (c) 1999-2003 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
9 * Displays all optinos about display preferences
12 * @package squirrelmail
15 /** Define the group constants for the display options page. */
16 define('SMOPT_GRP_GENERAL', 0);
17 define('SMOPT_GRP_MAILBOX', 1);
18 define('SMOPT_GRP_MESSAGE', 2);
20 // load icon themes if in use
24 $dirName = SM_PATH
. 'images/themes';
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");
35 * This function builds an array with all the information about
36 * the options available to the user, and returns it. The options
37 * are grouped by the groups in which they are displayed.
38 * For each option, the following information is stored:
39 * - name: the internal (variable) name
40 * - caption: the description of the option in the UI
41 * - type: one of SMOPT_TYPE_*
42 * - refresh: one of SMOPT_REFRESH_*
43 * - size: one of SMOPT_SIZE_*
44 * - save: the name of a function to call when saving this option
45 * @return array all option information
47 function load_optpage_data_display() {
48 global $theme, $language, $languages, $js_autodetect_results,
49 $compose_new_win, $default_use_mdn, $squirrelmail_language, $allow_thread_sort,
50 $optmode, $show_alternative_names, $available_languages, $use_icons;
52 /* Build a simple array into which we will build options. */
56 /******************************************************/
57 /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */
58 /******************************************************/
60 /*** Load the General Options into the array ***/
61 $optgrps[SMOPT_GRP_GENERAL
] = _("General Display Options");
62 $optvals[SMOPT_GRP_GENERAL
] = array();
64 /* Load the theme option. */
65 $theme_values = array();
66 foreach ($theme as $theme_key => $theme_attributes) {
67 $theme_values[$theme_attributes['NAME']] = $theme_attributes['PATH'];
70 $theme_values = array_flip($theme_values);
71 $optvals[SMOPT_GRP_GENERAL
][] = array(
72 'name' => 'chosen_theme',
73 'caption' => _("Theme"),
74 'type' => SMOPT_TYPE_STRLIST
,
75 'refresh' => SMOPT_REFRESH_ALL
,
76 'posvals' => $theme_values,
77 'save' => 'save_option_theme'
80 $css_values = array( 'none' => _("Default" ) );
81 $handle=opendir('../themes/css/');
82 while ($file = readdir($handle) ) {
83 if ( substr( $file, -4 ) == '.css' ) {
84 $css_values[$file] = substr( $file, 0, strlen( $file ) - 4 );
89 if ( count( $css_values ) > 1 ) {
91 $optvals[SMOPT_GRP_GENERAL
][] = array(
92 'name' => 'custom_css',
93 'caption' => _("Custom Stylesheet"),
94 'type' => SMOPT_TYPE_STRLIST
,
95 'refresh' => SMOPT_REFRESH_ALL
,
96 'posvals' => $css_values
101 // config.php can be unupdated.
102 if (! isset($available_languages) ||
$available_languages=="" ) {
103 $available_languages="ALL"; }
105 $language_values = array();
106 if ( strtoupper($available_languages)=='ALL') {
107 foreach ($languages as $lang_key => $lang_attributes) {
108 if (isset($lang_attributes['NAME'])) {
109 $language_values[$lang_key] = $lang_attributes['NAME'];
110 if ( isset($show_alternative_names) &&
111 $show_alternative_names &&
112 isset($lang_attributes['ALTNAME']) ) {
113 $language_values[$lang_key] .= " / " . $lang_attributes['ALTNAME'];
117 } else if (strtoupper($available_languages)!='NONE') {
118 // admin can set list of available languages in config
119 $available_languages_array=explode (" ",$available_languages);
120 foreach ($available_languages_array as $lang_key ) {
121 if (isset($languages[$lang_key]['NAME'])) {
122 $language_values[$lang_key] = $languages[$lang_key]['NAME'];
123 if ( isset($show_alternative_names) &&
124 $show_alternative_names &&
125 isset($languages[$lang_key]['ALTNAME']) ) {
126 $language_values[$lang_key] .= " / " . $languages[$lang_key]['ALTNAME'];
131 asort($language_values);
133 array_merge(array('' => _("Default")), $language_values);
134 $language = $squirrelmail_language;
135 if (strtoupper($available_languages)!='NONE') {
136 // if set to 'none', interface will use only default language
137 $optvals[SMOPT_GRP_GENERAL
][] = array(
138 'name' => 'language',
139 'caption' => _("Language"),
140 'type' => SMOPT_TYPE_STRLIST
,
141 'refresh' => SMOPT_REFRESH_ALL
,
142 'posvals' => $language_values
146 /* Set values for the "use javascript" option. */
147 $optvals[SMOPT_GRP_GENERAL
][] = array(
148 'name' => 'javascript_setting',
149 'caption' => _("Use Javascript"),
150 'type' => SMOPT_TYPE_STRLIST
,
151 'refresh' => SMOPT_REFRESH_ALL
,
152 'posvals' => array(SMPREF_JS_AUTODETECT
=> _("Autodetect"),
153 SMPREF_JS_ON
=> _("Always"),
154 SMPREF_JS_OFF
=> _("Never"))
158 if ($optmode != 'submit')
159 $onLoadScript = 'document.forms[0].new_js_autodetect_results.value = \'' . SMPREF_JS_ON
. '\'';
163 $optvals[SMOPT_GRP_GENERAL
][] = array(
164 'name' => 'js_autodetect_results',
166 'type' => SMOPT_TYPE_HIDDEN
,
167 'refresh' => SMOPT_REFRESH_NONE
,
168 //'post_script' => $js_autodetect_script,
169 'save' => 'save_option_javascript_autodetect'
172 /*** Load the General Options into the array ***/
173 $optgrps[SMOPT_GRP_MAILBOX
] = _("Mailbox Display Options");
174 $optvals[SMOPT_GRP_MAILBOX
] = array();
176 $optvals[SMOPT_GRP_MAILBOX
][] = array(
177 'name' => 'show_num',
178 'caption' => _("Number of Messages to Index"),
179 'type' => SMOPT_TYPE_INTEGER
,
180 'refresh' => SMOPT_REFRESH_NONE
,
181 'size' => SMOPT_SIZE_TINY
184 $optvals[SMOPT_GRP_MAILBOX
][] = array(
185 'name' => 'alt_index_colors',
186 'caption' => _("Enable Alternating Row Colors"),
187 'type' => SMOPT_TYPE_BOOLEAN
,
188 'refresh' => SMOPT_REFRESH_NONE
191 echo "use icons? $use_icons<br>";
193 global $icon_themes, $icon_theme;
195 for ($count = 0; $count < sizeof($icon_themes); $count++
) {
196 $temp[$count] = $icon_themes[$count]['NAME'];
197 if ($icon_theme == $icon_themes[$count]['PATH'])
200 $optvals[SMOPT_GRP_MAILBOX
][] = array(
201 'name' => 'icon_theme',
202 'caption' => _("Message Flags Icon Theme"),
203 'type' => SMOPT_TYPE_STRLIST
,
204 'refresh' => SMOPT_REFRESH_NONE
,
206 'initial_value' => $value,
207 'save' => 'icon_theme_save'
211 $optvals[SMOPT_GRP_MAILBOX
][] = array(
212 'name' => 'page_selector',
213 'caption' => _("Enable Page Selector"),
214 'type' => SMOPT_TYPE_BOOLEAN
,
215 'refresh' => SMOPT_REFRESH_NONE
218 $optvals[SMOPT_GRP_MAILBOX
][] = array(
219 'name' => 'page_selector_max',
220 'caption' => _("Maximum Number of Pages to Show"),
221 'type' => SMOPT_TYPE_INTEGER
,
222 'refresh' => SMOPT_REFRESH_NONE
,
223 'size' => SMOPT_SIZE_TINY
226 $optvals[SMOPT_GRP_MAILBOX
][] = array(
227 'name' => 'show_full_date',
228 'caption' => _("Always Show Full Date"),
229 'type' => SMOPT_TYPE_BOOLEAN
,
230 'refresh' => SMOPT_REFRESH_NONE
233 $optvals[SMOPT_GRP_MAILBOX
][] = array(
234 'name' => 'truncate_sender',
235 'caption' => _("Length of From/To Field (0 for full)"),
236 'type' => SMOPT_TYPE_INTEGER
,
237 'refresh' => SMOPT_REFRESH_NONE
,
238 'size' => SMOPT_SIZE_TINY
241 $optvals[SMOPT_GRP_MAILBOX
][] = array(
242 'name' => 'truncate_subject',
243 'caption' => _("Length of Subject Field (0 for full)"),
244 'type' => SMOPT_TYPE_INTEGER
,
245 'refresh' => SMOPT_REFRESH_NONE
,
246 'size' => SMOPT_SIZE_TINY
249 $optvals[SMOPT_GRP_MAILBOX
][] = array(
250 'name' => 'show_recipient_instead',
251 'caption' => _("Show recipient name if the message is from your default identity"),
252 'type' => SMOPT_TYPE_BOOLEAN
,
253 'refresh' => SMOPT_REFRESH_NONE
,
254 'size' => SMOPT_SIZE_TINY
258 /*** Load the General Options into the array ***/
259 $optgrps[SMOPT_GRP_MESSAGE
] = _("Message Display and Composition");
260 $optvals[SMOPT_GRP_MESSAGE
] = array();
262 $optvals[SMOPT_GRP_MESSAGE
][] = array(
264 'caption' => _("Wrap Incoming Text At"),
265 'type' => SMOPT_TYPE_INTEGER
,
266 'refresh' => SMOPT_REFRESH_NONE
,
267 'size' => SMOPT_SIZE_TINY
270 $optvals[SMOPT_GRP_MESSAGE
][] = array(
271 'name' => 'editor_size',
272 'caption' => _("Width of Editor Window"),
273 'type' => SMOPT_TYPE_INTEGER
,
274 'refresh' => SMOPT_REFRESH_NONE
,
275 'size' => SMOPT_SIZE_TINY
278 $optvals[SMOPT_GRP_MESSAGE
][] = array(
279 'name' => 'editor_height',
280 'caption' => _("Height of Editor Window"),
281 'type' => SMOPT_TYPE_INTEGER
,
282 'refresh' => SMOPT_REFRESH_NONE
,
283 'size' => SMOPT_SIZE_TINY
286 $optvals[SMOPT_GRP_MESSAGE
][] = array(
287 'name' => 'location_of_buttons',
288 'caption' => _("Location of Buttons when Composing"),
289 'type' => SMOPT_TYPE_STRLIST
,
290 'refresh' => SMOPT_REFRESH_NONE
,
291 'posvals' => array(SMPREF_LOC_TOP
=> _("Before headers"),
292 SMPREF_LOC_BETWEEN
=> _("Between headers and message body"),
293 SMPREF_LOC_BOTTOM
=> _("After message body"))
297 $optvals[SMOPT_GRP_MESSAGE
][] = array(
298 'name' => 'use_javascript_addr_book',
299 'caption' => _("Addressbook Display Format"),
300 'type' => SMOPT_TYPE_STRLIST
,
301 'refresh' => SMOPT_REFRESH_NONE
,
302 'posvals' => array('1' => _("Javascript"),
306 $optvals[SMOPT_GRP_MESSAGE
][] = array(
307 'name' => 'show_html_default',
308 'caption' => _("Show HTML Version by Default"),
309 'type' => SMOPT_TYPE_BOOLEAN
,
310 'refresh' => SMOPT_REFRESH_NONE
313 $optvals[SMOPT_GRP_MESSAGE
][] = array(
314 'name' => 'enable_forward_as_attachment',
315 'caption' => _("Enable Forward as Attachment"),
316 'type' => SMOPT_TYPE_BOOLEAN
,
317 'refresh' => SMOPT_REFRESH_NONE
320 $optvals[SMOPT_GRP_MESSAGE
][] = array(
321 'name' => 'forward_cc',
322 'caption' => _("Include CCs when Forwarding Messages"),
323 'type' => SMOPT_TYPE_BOOLEAN
,
324 'refresh' => SMOPT_REFRESH_NONE
327 $optvals[SMOPT_GRP_MESSAGE
][] = array(
328 'name' => 'include_self_reply_all',
329 'caption' => _("Include Me in CC when I Reply All"),
330 'type' => SMOPT_TYPE_BOOLEAN
,
331 'refresh' => SMOPT_REFRESH_NONE
334 $optvals[SMOPT_GRP_MESSAGE
][] = array(
335 'name' => 'show_xmailer_default',
336 'caption' => _("Enable Mailer Display"),
337 'type' => SMOPT_TYPE_BOOLEAN
,
338 'refresh' => SMOPT_REFRESH_NONE
341 $optvals[SMOPT_GRP_MESSAGE
][] = array(
342 'name' => 'attachment_common_show_images',
343 'caption' => _("Display Attached Images with Message"),
344 'type' => SMOPT_TYPE_BOOLEAN
,
345 'refresh' => SMOPT_REFRESH_NONE
348 $optvals[SMOPT_GRP_MESSAGE
][] = array(
349 'name' => 'pf_cleandisplay',
350 'caption' => _("Enable Printer Friendly Clean Display"),
351 'type' => SMOPT_TYPE_BOOLEAN
,
352 'refresh' => SMOPT_REFRESH_NONE
355 if ($default_use_mdn) {
356 $optvals[SMOPT_GRP_MESSAGE
][] = array(
357 'name' => 'mdn_user_support',
358 'caption' => _("Enable Mail Delivery Notification"),
359 'type' => SMOPT_TYPE_BOOLEAN
,
360 'refresh' => SMOPT_REFRESH_NONE
364 $optvals[SMOPT_GRP_MESSAGE
][] = array(
365 'name' => 'compose_new_win',
366 'caption' => _("Compose Messages in New Window"),
367 'type' => SMOPT_TYPE_BOOLEAN
,
368 'refresh' => SMOPT_REFRESH_ALL
371 $optvals[SMOPT_GRP_MESSAGE
][] = array(
372 'name' => 'compose_width',
373 'caption' => _("Width of Compose Window"),
374 'type' => SMOPT_TYPE_INTEGER
,
375 'refresh' => SMOPT_REFRESH_ALL
,
376 'size' => SMOPT_SIZE_TINY
379 $optvals[SMOPT_GRP_MESSAGE
][] = array(
380 'name' => 'compose_height',
381 'caption' => _("Height of Compose Window"),
382 'type' => SMOPT_TYPE_INTEGER
,
383 'refresh' => SMOPT_REFRESH_ALL
,
384 'size' => SMOPT_SIZE_TINY
387 $optvals[SMOPT_GRP_MESSAGE
][] = array(
388 'name' => 'sig_first',
389 'caption' => _("Append Signature before Reply/Forward Text"),
390 'type' => SMOPT_TYPE_BOOLEAN
,
391 'refresh' => SMOPT_REFRESH_NONE
394 $optvals[SMOPT_GRP_MESSAGE
][] = array(
395 'name' => 'reply_focus',
396 'caption' => _("Cursor Position when Replying"),
397 'type' => SMOPT_TYPE_STRLIST
,
398 'refresh' => SMOPT_REFRESH_NONE
,
399 'posvals' => array('' => _("To: field"),
400 'focus' => _("Focus in body"),
401 'select' => _("Select body"))
404 $optvals[SMOPT_GRP_MESSAGE
][] = array(
405 'name' => 'strip_sigs',
406 'caption' => _("Strip signature when replying"),
407 'type' => SMOPT_TYPE_BOOLEAN
,
408 'refresh' => SMOPT_REFRESH_NONE
411 $optvals[SMOPT_GRP_MESSAGE
][] = array(
412 'name' => 'internal_date_sort',
413 'caption' => _("Enable Sort by of Receive Date"),
414 'type' => SMOPT_TYPE_BOOLEAN
,
415 'refresh' => SMOPT_REFRESH_ALL
417 if ($allow_thread_sort == TRUE) {
418 $optvals[SMOPT_GRP_MESSAGE
][] = array(
419 'name' => 'sort_by_ref',
420 'caption' => _("Enable Thread Sort by References Header"),
421 'type' => SMOPT_TYPE_BOOLEAN
,
422 'refresh' => SMOPT_REFRESH_ALL
424 $optvals[SMOPT_GRP_MESSAGE
][] = array(
425 'name' => 'delete_prev_next_display',
426 'caption' => _("Show 'Delete & Prev/Next' Links"),
427 'type' => SMOPT_TYPE_BOOLEAN
,
428 'refresh' => SMOPT_REFRESH_ALL
432 /* Assemble all this together and return it as our result. */
436 'xtra' => $onLoadScript
441 /******************************************************************/
442 /** Define any specialized save functions for this option page. ***/
443 /******************************************************************/
446 * This function saves a new theme setting.
447 * It updates the theme array.
449 function save_option_theme($option) {
452 /* Do checking to make sure $new_theme is in the array. */
453 $theme_in_array = false;
454 for ($i = 0; $i < count($theme); ++
$i) {
455 if ($theme[$i]['PATH'] == $option->new_value
) {
456 $theme_in_array = true;
461 if (!$theme_in_array) {
462 $option->new_value
= '';
465 /* Save the option like normal. */
466 save_option($option);
470 * This function saves the javascript detection option.
472 function save_option_javascript_autodetect($option) {
473 global $data_dir, $username, $new_javascript_setting;
475 /* Set javascript either on or off. */
476 if ($new_javascript_setting == SMPREF_JS_AUTODETECT
) {
477 if ($option->new_value
== SMPREF_JS_ON
) {
478 setPref($data_dir, $username, 'javascript_on', SMPREF_JS_ON
);
480 setPref($data_dir, $username, 'javascript_on', SMPREF_JS_OFF
);
483 setPref($data_dir, $username, 'javascript_on', $new_javascript_setting);
488 * This function saves the user's icon theme setting
490 function icon_theme_save($option) {
492 global $icon_themes, $data_dir, $username;
495 // Don't assume the new value is there, double check
496 // and only save if found
498 if (isset($icon_themes[$option->new_value
]['PATH']))
499 setPref($data_dir, $username, 'icon_theme', $icon_themes[$option->new_value
]['PATH']);
501 setPref($data_dir, $username, 'icon_theme', 'none');