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);
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
33 function load_optpage_data_display() {
34 global $theme, $language, $languages, $js_autodetect_results,
35 $compose_new_win, $default_use_mdn, $squirrelmail_language, $allow_thread_sort,
36 $optmode, $show_alternative_names, $available_languages;
38 /* Build a simple array into which we will build options. */
42 /******************************************************/
43 /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */
44 /******************************************************/
46 /*** Load the General Options into the array ***/
47 $optgrps[SMOPT_GRP_GENERAL
] = _("General Display Options");
48 $optvals[SMOPT_GRP_GENERAL
] = array();
50 /* Load the theme option. */
51 $theme_values = array();
52 foreach ($theme as $theme_key => $theme_attributes) {
53 $theme_values[$theme_attributes['NAME']] = $theme_attributes['PATH'];
56 $theme_values = array_flip($theme_values);
57 $optvals[SMOPT_GRP_GENERAL
][] = array(
58 'name' => 'chosen_theme',
59 'caption' => _("Theme"),
60 'type' => SMOPT_TYPE_STRLIST
,
61 'refresh' => SMOPT_REFRESH_ALL
,
62 'posvals' => $theme_values,
63 'save' => 'save_option_theme'
66 $css_values = array( 'none' => _("Default" ) );
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 );
75 if ( count( $css_values ) > 1 ) {
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
87 // config.php can be unupdated.
88 if (! isset($available_languages) ||
$available_languages=="" ) {
89 $available_languages="ALL"; }
91 $language_values = array();
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'];
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'];
117 asort($language_values);
119 array_merge(array('' => _("Default")), $language_values);
120 $language = $squirrelmail_language;
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
132 /* Set values for the "use javascript" option. */
133 $optvals[SMOPT_GRP_GENERAL
][] = array(
134 'name' => 'javascript_setting',
135 'caption' => _("Use Javascript"),
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"))
144 if ($optmode != 'submit')
145 $onLoadScript = 'document.forms[0].new_js_autodetect_results.value = \'' . SMPREF_JS_ON
. '\'';
149 $optvals[SMOPT_GRP_GENERAL
][] = array(
150 'name' => 'js_autodetect_results',
152 'type' => SMOPT_TYPE_HIDDEN
,
153 'refresh' => SMOPT_REFRESH_NONE
,
154 //'post_script' => $js_autodetect_script,
155 'save' => 'save_option_javascript_autodetect'
158 /*** Load the General Options into the array ***/
159 $optgrps[SMOPT_GRP_MAILBOX
] = _("Mailbox Display Options");
160 $optvals[SMOPT_GRP_MAILBOX
] = array();
162 $optvals[SMOPT_GRP_MAILBOX
][] = array(
163 'name' => 'show_num',
164 'caption' => _("Number of Messages to Index"),
165 'type' => SMOPT_TYPE_INTEGER
,
166 'refresh' => SMOPT_REFRESH_NONE
,
167 'size' => SMOPT_SIZE_TINY
170 $optvals[SMOPT_GRP_MAILBOX
][] = array(
171 'name' => 'alt_index_colors',
172 'caption' => _("Enable Alternating Row Colors"),
173 'type' => SMOPT_TYPE_BOOLEAN
,
174 'refresh' => SMOPT_REFRESH_NONE
177 $optvals[SMOPT_GRP_MAILBOX
][] = array(
178 'name' => 'page_selector',
179 'caption' => _("Enable Page Selector"),
180 'type' => SMOPT_TYPE_BOOLEAN
,
181 'refresh' => SMOPT_REFRESH_NONE
184 $optvals[SMOPT_GRP_MAILBOX
][] = array(
185 'name' => 'page_selector_max',
186 'caption' => _("Maximum Number of Pages to Show"),
187 'type' => SMOPT_TYPE_INTEGER
,
188 'refresh' => SMOPT_REFRESH_NONE
,
189 'size' => SMOPT_SIZE_TINY
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
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
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
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
224 /*** Load the General Options into the array ***/
225 $optgrps[SMOPT_GRP_MESSAGE
] = _("Message Display and Composition");
226 $optvals[SMOPT_GRP_MESSAGE
] = array();
228 $optvals[SMOPT_GRP_MESSAGE
][] = array(
230 'caption' => _("Wrap Incoming Text At"),
231 'type' => SMOPT_TYPE_INTEGER
,
232 'refresh' => SMOPT_REFRESH_NONE
,
233 'size' => SMOPT_SIZE_TINY
236 $optvals[SMOPT_GRP_MESSAGE
][] = array(
237 'name' => 'editor_size',
238 'caption' => _("Size of Editor Window"),
239 'type' => SMOPT_TYPE_INTEGER
,
240 'refresh' => SMOPT_REFRESH_NONE
,
241 'size' => SMOPT_SIZE_TINY
244 $optvals[SMOPT_GRP_MESSAGE
][] = array(
245 'name' => 'location_of_buttons',
246 'caption' => _("Location of Buttons when Composing"),
247 'type' => SMOPT_TYPE_STRLIST
,
248 'refresh' => SMOPT_REFRESH_NONE
,
249 'posvals' => array(SMPREF_LOC_TOP
=> _("Before headers"),
250 SMPREF_LOC_BETWEEN
=> _("Between headers and message body"),
251 SMPREF_LOC_BOTTOM
=> _("After message body"))
255 $optvals[SMOPT_GRP_MESSAGE
][] = array(
256 'name' => 'use_javascript_addr_book',
257 'caption' => _("Addressbook Display Format"),
258 'type' => SMOPT_TYPE_STRLIST
,
259 'refresh' => SMOPT_REFRESH_NONE
,
260 'posvals' => array('1' => _("Javascript"),
264 $optvals[SMOPT_GRP_MESSAGE
][] = array(
265 'name' => 'show_html_default',
266 'caption' => _("Show HTML Version by Default"),
267 'type' => SMOPT_TYPE_BOOLEAN
,
268 'refresh' => SMOPT_REFRESH_NONE
271 $optvals[SMOPT_GRP_MESSAGE
][] = array(
272 'name' => 'enable_forward_as_attachment',
273 'caption' => _("Enable Forward as Attachment"),
274 'type' => SMOPT_TYPE_BOOLEAN
,
275 'refresh' => SMOPT_REFRESH_NONE
278 $optvals[SMOPT_GRP_MESSAGE
][] = array(
279 'name' => 'forward_cc',
280 'caption' => _("Include CCs when Forwarding Messages"),
281 'type' => SMOPT_TYPE_BOOLEAN
,
282 'refresh' => SMOPT_REFRESH_NONE
285 $optvals[SMOPT_GRP_MESSAGE
][] = array(
286 'name' => 'include_self_reply_all',
287 'caption' => _("Include Me in CC when I Reply All"),
288 'type' => SMOPT_TYPE_BOOLEAN
,
289 'refresh' => SMOPT_REFRESH_NONE
292 $optvals[SMOPT_GRP_MESSAGE
][] = array(
293 'name' => 'show_xmailer_default',
294 'caption' => _("Enable Mailer Display"),
295 'type' => SMOPT_TYPE_BOOLEAN
,
296 'refresh' => SMOPT_REFRESH_NONE
299 $optvals[SMOPT_GRP_MESSAGE
][] = array(
300 'name' => 'attachment_common_show_images',
301 'caption' => _("Display Attached Images with Message"),
302 'type' => SMOPT_TYPE_BOOLEAN
,
303 'refresh' => SMOPT_REFRESH_NONE
306 $optvals[SMOPT_GRP_MESSAGE
][] = array(
307 'name' => 'pf_cleandisplay',
308 'caption' => _("Enable Printer Friendly Clean Display"),
309 'type' => SMOPT_TYPE_BOOLEAN
,
310 'refresh' => SMOPT_REFRESH_NONE
313 if ($default_use_mdn) {
314 $optvals[SMOPT_GRP_MESSAGE
][] = array(
315 'name' => 'mdn_user_support',
316 'caption' => _("Enable Mail Delivery Notification"),
317 'type' => SMOPT_TYPE_BOOLEAN
,
318 'refresh' => SMOPT_REFRESH_NONE
322 $optvals[SMOPT_GRP_MESSAGE
][] = array(
323 'name' => 'compose_new_win',
324 'caption' => _("Compose Messages in New Window"),
325 'type' => SMOPT_TYPE_BOOLEAN
,
326 'refresh' => SMOPT_REFRESH_ALL
329 $optvals[SMOPT_GRP_MESSAGE
][] = array(
330 'name' => 'compose_width',
331 'caption' => _("Width of Compose Window"),
332 'type' => SMOPT_TYPE_INTEGER
,
333 'refresh' => SMOPT_REFRESH_ALL
,
334 'size' => SMOPT_SIZE_TINY
337 $optvals[SMOPT_GRP_MESSAGE
][] = array(
338 'name' => 'compose_height',
339 'caption' => _("Height of Compose Window"),
340 'type' => SMOPT_TYPE_INTEGER
,
341 'refresh' => SMOPT_REFRESH_ALL
,
342 'size' => SMOPT_SIZE_TINY
345 $optvals[SMOPT_GRP_MESSAGE
][] = array(
346 'name' => 'sig_first',
347 'caption' => _("Append Signature before Reply/Forward Text"),
348 'type' => SMOPT_TYPE_BOOLEAN
,
349 'refresh' => SMOPT_REFRESH_NONE
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"))
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
369 $optvals[SMOPT_GRP_MESSAGE
][] = array(
370 'name' => 'internal_date_sort',
371 'caption' => _("Enable Sort by of Receive Date"),
372 'type' => SMOPT_TYPE_BOOLEAN
,
373 'refresh' => SMOPT_REFRESH_ALL
375 if ($allow_thread_sort == TRUE) {
376 $optvals[SMOPT_GRP_MESSAGE
][] = array(
377 'name' => 'sort_by_ref',
378 'caption' => _("Enable Thread Sort by References Header"),
379 'type' => SMOPT_TYPE_BOOLEAN
,
380 'refresh' => SMOPT_REFRESH_ALL
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
390 /* Assemble all this together and return it as our result. */
394 'xtra' => $onLoadScript
399 /******************************************************************/
400 /** Define any specialized save functions for this option page. ***/
401 /******************************************************************/
404 * This function saves a new theme setting.
405 * It updates the theme array.
407 function save_option_theme($option) {
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;
419 if (!$theme_in_array) {
420 $option->new_value
= '';
423 /* Save the option like normal. */
424 save_option($option);
428 * This function saves the javascript detection option.
430 function save_option_javascript_autodetect($option) {
431 global $data_dir, $username, $new_javascript_setting;
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
);
438 setPref($data_dir, $username, 'javascript_on', SMPREF_JS_OFF
);
441 setPref($data_dir, $username, 'javascript_on', $new_javascript_setting);