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
14 /* Define the group constants for the display options page. */
15 define('SMOPT_GRP_GENERAL', 0);
16 define('SMOPT_GRP_MAILBOX', 1);
17 define('SMOPT_GRP_MESSAGE', 2);
19 /* Define the optpage load function for the display options page. */
20 function load_optpage_data_display() {
21 global $theme, $language, $languages, $js_autodetect_results,
22 $compose_new_win, $default_use_mdn, $squirrelmail_language, $allow_thread_sort,
23 $optmode, $show_alternative_names, $available_languages;
25 /* Build a simple array into which we will build options. */
29 /******************************************************/
30 /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */
31 /******************************************************/
33 /*** Load the General Options into the array ***/
34 $optgrps[SMOPT_GRP_GENERAL
] = _("General Display Options");
35 $optvals[SMOPT_GRP_GENERAL
] = array();
37 /* Load the theme option. */
38 $theme_values = array();
39 foreach ($theme as $theme_key => $theme_attributes) {
40 $theme_values[$theme_attributes['NAME']] = $theme_attributes['PATH'];
43 $theme_values = array_flip($theme_values);
44 $optvals[SMOPT_GRP_GENERAL
][] = array(
45 'name' => 'chosen_theme',
46 'caption' => _("Theme"),
47 'type' => SMOPT_TYPE_STRLIST
,
48 'refresh' => SMOPT_REFRESH_ALL
,
49 'posvals' => $theme_values,
50 'save' => 'save_option_theme'
53 $css_values = array( 'none' => _("Default" ) );
54 $handle=opendir('../themes/css/');
55 while ($file = readdir($handle) ) {
56 if ( substr( $file, -4 ) == '.css' ) {
57 $css_values[$file] = substr( $file, 0, strlen( $file ) - 4 );
62 if ( count( $css_values ) > 1 ) {
64 $optvals[SMOPT_GRP_GENERAL
][] = array(
65 'name' => 'custom_css',
66 'caption' => _("Custom Stylesheet"),
67 'type' => SMOPT_TYPE_STRLIST
,
68 'refresh' => SMOPT_REFRESH_ALL
,
69 'posvals' => $css_values
74 // config.php can be unupdated.
75 if (! isset($available_languages) ||
$available_languages=="" ) {
76 $available_languages="ALL"; }
78 $language_values = array();
79 if ( strtoupper($available_languages)=='ALL') {
80 foreach ($languages as $lang_key => $lang_attributes) {
81 if (isset($lang_attributes['NAME'])) {
82 $language_values[$lang_key] = $lang_attributes['NAME'];
83 if ( isset($show_alternative_names) &&
84 $show_alternative_names &&
85 isset($lang_attributes['ALTNAME']) ) {
86 $language_values[$lang_key] .= " / " . $lang_attributes['ALTNAME'];
90 } else if (strtoupper($available_languages)!='NONE') {
91 // admin can set list of available languages in config
92 $available_languages_array=explode (" ",$available_languages);
93 foreach ($available_languages_array as $lang_key ) {
94 if (isset($languages[$lang_key]['NAME'])) {
95 $language_values[$lang_key] = $languages[$lang_key]['NAME'];
96 if ( isset($show_alternative_names) &&
97 $show_alternative_names &&
98 isset($languages[$lang_key]['ALTNAME']) ) {
99 $language_values[$lang_key] .= " / " . $languages[$lang_key]['ALTNAME'];
104 asort($language_values);
106 array_merge(array('' => _("Default")), $language_values);
107 $language = $squirrelmail_language;
108 if (strtoupper($available_languages)!='NONE') {
109 // if set to 'none', interface will use only default language
110 $optvals[SMOPT_GRP_GENERAL
][] = array(
111 'name' => 'language',
112 'caption' => _("Language"),
113 'type' => SMOPT_TYPE_STRLIST
,
114 'refresh' => SMOPT_REFRESH_ALL
,
115 'posvals' => $language_values
119 /* Set values for the "use javascript" option. */
120 $optvals[SMOPT_GRP_GENERAL
][] = array(
121 'name' => 'javascript_setting',
122 'caption' => _("Use Javascript"),
123 'type' => SMOPT_TYPE_STRLIST
,
124 'refresh' => SMOPT_REFRESH_ALL
,
125 'posvals' => array(SMPREF_JS_AUTODETECT
=> _("Autodetect"),
126 SMPREF_JS_ON
=> _("Always"),
127 SMPREF_JS_OFF
=> _("Never"))
131 if ($optmode != 'submit')
132 $onLoadScript = 'document.forms[0].new_js_autodetect_results.value = \'' . SMPREF_JS_ON
. '\'';
136 $optvals[SMOPT_GRP_GENERAL
][] = array(
137 'name' => 'js_autodetect_results',
139 'type' => SMOPT_TYPE_HIDDEN
,
140 'refresh' => SMOPT_REFRESH_NONE
,
141 //'post_script' => $js_autodetect_script,
142 'save' => 'save_option_javascript_autodetect'
145 /*** Load the General Options into the array ***/
146 $optgrps[SMOPT_GRP_MAILBOX
] = _("Mailbox Display Options");
147 $optvals[SMOPT_GRP_MAILBOX
] = array();
149 $optvals[SMOPT_GRP_MAILBOX
][] = array(
150 'name' => 'show_num',
151 'caption' => _("Number of Messages to Index"),
152 'type' => SMOPT_TYPE_INTEGER
,
153 'refresh' => SMOPT_REFRESH_NONE
,
154 'size' => SMOPT_SIZE_TINY
157 $optvals[SMOPT_GRP_MAILBOX
][] = array(
158 'name' => 'alt_index_colors',
159 'caption' => _("Enable Alternating Row Colors"),
160 'type' => SMOPT_TYPE_BOOLEAN
,
161 'refresh' => SMOPT_REFRESH_NONE
164 $optvals[SMOPT_GRP_MAILBOX
][] = array(
165 'name' => 'page_selector',
166 'caption' => _("Enable Page Selector"),
167 'type' => SMOPT_TYPE_BOOLEAN
,
168 'refresh' => SMOPT_REFRESH_NONE
171 $optvals[SMOPT_GRP_MAILBOX
][] = array(
172 'name' => 'page_selector_max',
173 'caption' => _("Maximum Number of Pages to Show"),
174 'type' => SMOPT_TYPE_INTEGER
,
175 'refresh' => SMOPT_REFRESH_NONE
,
176 'size' => SMOPT_SIZE_TINY
179 $optvals[SMOPT_GRP_MAILBOX
][] = array(
180 'name' => 'show_full_date',
181 'caption' => _("Always Show Full Date"),
182 'type' => SMOPT_TYPE_BOOLEAN
,
183 'refresh' => SMOPT_REFRESH_NONE
186 $optvals[SMOPT_GRP_MAILBOX
][] = array(
187 'name' => 'truncate_sender',
188 'caption' => _("Length of From/To Field (0 for full)"),
189 'type' => SMOPT_TYPE_INTEGER
,
190 'refresh' => SMOPT_REFRESH_NONE
,
191 'size' => SMOPT_SIZE_TINY
194 $optvals[SMOPT_GRP_MAILBOX
][] = array(
195 'name' => 'truncate_subject',
196 'caption' => _("Length of Subject Field (0 for full)"),
197 'type' => SMOPT_TYPE_INTEGER
,
198 'refresh' => SMOPT_REFRESH_NONE
,
199 'size' => SMOPT_SIZE_TINY
202 $optvals[SMOPT_GRP_MAILBOX
][] = array(
203 'name' => 'show_recipient_instead',
204 'caption' => _("Show recipient name if the message is from your default identity"),
205 'type' => SMOPT_TYPE_BOOLEAN
,
206 'refresh' => SMOPT_REFRESH_NONE
,
207 'size' => SMOPT_SIZE_TINY
211 /*** Load the General Options into the array ***/
212 $optgrps[SMOPT_GRP_MESSAGE
] = _("Message Display and Composition");
213 $optvals[SMOPT_GRP_MESSAGE
] = array();
215 $optvals[SMOPT_GRP_MESSAGE
][] = array(
217 'caption' => _("Wrap Incoming Text At"),
218 'type' => SMOPT_TYPE_INTEGER
,
219 'refresh' => SMOPT_REFRESH_NONE
,
220 'size' => SMOPT_SIZE_TINY
223 $optvals[SMOPT_GRP_MESSAGE
][] = array(
224 'name' => 'editor_size',
225 'caption' => _("Size of Editor Window"),
226 'type' => SMOPT_TYPE_INTEGER
,
227 'refresh' => SMOPT_REFRESH_NONE
,
228 'size' => SMOPT_SIZE_TINY
231 $optvals[SMOPT_GRP_MESSAGE
][] = array(
232 'name' => 'location_of_buttons',
233 'caption' => _("Location of Buttons when Composing"),
234 'type' => SMOPT_TYPE_STRLIST
,
235 'refresh' => SMOPT_REFRESH_NONE
,
236 'posvals' => array(SMPREF_LOC_TOP
=> _("Before headers"),
237 SMPREF_LOC_BETWEEN
=> _("Between headers and message body"),
238 SMPREF_LOC_BOTTOM
=> _("After message body"))
242 $optvals[SMOPT_GRP_MESSAGE
][] = array(
243 'name' => 'use_javascript_addr_book',
244 'caption' => _("Addressbook Display Format"),
245 'type' => SMOPT_TYPE_STRLIST
,
246 'refresh' => SMOPT_REFRESH_NONE
,
247 'posvals' => array('1' => _("Javascript"),
251 $optvals[SMOPT_GRP_MESSAGE
][] = array(
252 'name' => 'show_html_default',
253 'caption' => _("Show HTML Version by Default"),
254 'type' => SMOPT_TYPE_BOOLEAN
,
255 'refresh' => SMOPT_REFRESH_NONE
258 $optvals[SMOPT_GRP_MESSAGE
][] = array(
259 'name' => 'enable_forward_as_attachment',
260 'caption' => _("Enable Forward as Attachment"),
261 'type' => SMOPT_TYPE_BOOLEAN
,
262 'refresh' => SMOPT_REFRESH_NONE
265 $optvals[SMOPT_GRP_MESSAGE
][] = array(
266 'name' => 'forward_cc',
267 'caption' => _("Include CCs when Forwarding Messages"),
268 'type' => SMOPT_TYPE_BOOLEAN
,
269 'refresh' => SMOPT_REFRESH_NONE
272 $optvals[SMOPT_GRP_MESSAGE
][] = array(
273 'name' => 'include_self_reply_all',
274 'caption' => _("Include Me in CC when I Reply All"),
275 'type' => SMOPT_TYPE_BOOLEAN
,
276 'refresh' => SMOPT_REFRESH_NONE
279 $optvals[SMOPT_GRP_MESSAGE
][] = array(
280 'name' => 'show_xmailer_default',
281 'caption' => _("Enable Mailer Display"),
282 'type' => SMOPT_TYPE_BOOLEAN
,
283 'refresh' => SMOPT_REFRESH_NONE
286 $optvals[SMOPT_GRP_MESSAGE
][] = array(
287 'name' => 'attachment_common_show_images',
288 'caption' => _("Display Attached Images with Message"),
289 'type' => SMOPT_TYPE_BOOLEAN
,
290 'refresh' => SMOPT_REFRESH_NONE
293 $optvals[SMOPT_GRP_MESSAGE
][] = array(
294 'name' => 'pf_cleandisplay',
295 'caption' => _("Enable Printer Friendly Clean Display"),
296 'type' => SMOPT_TYPE_BOOLEAN
,
297 'refresh' => SMOPT_REFRESH_NONE
300 if ($default_use_mdn) {
301 $optvals[SMOPT_GRP_MESSAGE
][] = array(
302 'name' => 'mdn_user_support',
303 'caption' => _("Enable Mail Delivery Notification"),
304 'type' => SMOPT_TYPE_BOOLEAN
,
305 'refresh' => SMOPT_REFRESH_NONE
309 $optvals[SMOPT_GRP_MESSAGE
][] = array(
310 'name' => 'compose_new_win',
311 'caption' => _("Compose Messages in New Window"),
312 'type' => SMOPT_TYPE_BOOLEAN
,
313 'refresh' => SMOPT_REFRESH_ALL
316 $optvals[SMOPT_GRP_MESSAGE
][] = array(
317 'name' => 'compose_width',
318 'caption' => _("Width of Compose Window"),
319 'type' => SMOPT_TYPE_INTEGER
,
320 'refresh' => SMOPT_REFRESH_ALL
,
321 'size' => SMOPT_SIZE_TINY
324 $optvals[SMOPT_GRP_MESSAGE
][] = array(
325 'name' => 'compose_height',
326 'caption' => _("Height of Compose Window"),
327 'type' => SMOPT_TYPE_INTEGER
,
328 'refresh' => SMOPT_REFRESH_ALL
,
329 'size' => SMOPT_SIZE_TINY
332 $optvals[SMOPT_GRP_MESSAGE
][] = array(
333 'name' => 'sig_first',
334 'caption' => _("Append Signature before Reply/Forward Text"),
335 'type' => SMOPT_TYPE_BOOLEAN
,
336 'refresh' => SMOPT_REFRESH_NONE
339 $optvals[SMOPT_GRP_MESSAGE
][] = array(
340 'name' => 'reply_focus',
341 'caption' => _("Cursor Position when Replying"),
342 'type' => SMOPT_TYPE_STRLIST
,
343 'refresh' => SMOPT_REFRESH_NONE
,
344 'posvals' => array('' => _("To: field"),
345 'focus' => _("Focus in body"),
346 'select' => _("Select body"))
349 $optvals[SMOPT_GRP_MESSAGE
][] = array(
350 'name' => 'strip_sigs',
351 'caption' => _("Strip signature when replying"),
352 'type' => SMOPT_TYPE_BOOLEAN
,
353 'refresh' => SMOPT_REFRESH_NONE
356 $optvals[SMOPT_GRP_MESSAGE
][] = array(
357 'name' => 'internal_date_sort',
358 'caption' => _("Enable Sort by of Receive Date"),
359 'type' => SMOPT_TYPE_BOOLEAN
,
360 'refresh' => SMOPT_REFRESH_ALL
362 if ($allow_thread_sort == TRUE
) {
363 $optvals[SMOPT_GRP_MESSAGE
][] = array(
364 'name' => 'sort_by_ref',
365 'caption' => _("Enable Thread Sort by References Header"),
366 'type' => SMOPT_TYPE_BOOLEAN
,
367 'refresh' => SMOPT_REFRESH_ALL
370 /* Assemble all this together and return it as our result. */
374 'xtra' => $onLoadScript
379 /******************************************************************/
380 /** Define any specialized save functions for this option page. ***/
381 /******************************************************************/
383 function save_option_theme($option) {
386 /* Do checking to make sure $new_theme is in the array. */
387 $theme_in_array = false
;
388 for ($i = 0; $i < count($theme); ++
$i) {
389 if ($theme[$i]['PATH'] == $option->new_value
) {
390 $theme_in_array = true
;
395 if (!$theme_in_array) {
396 $option->new_value
= '';
399 /* Save the option like normal. */
400 save_option($option);
403 function save_option_javascript_autodetect($option) {
404 global $data_dir, $username, $new_javascript_setting;
406 /* Set javascript either on or off. */
407 if ($new_javascript_setting == SMPREF_JS_AUTODETECT
) {
408 if ($option->new_value
== SMPREF_JS_ON
) {
409 setPref($data_dir, $username, 'javascript_on', SMPREF_JS_ON
);
411 setPref($data_dir, $username, 'javascript_on', SMPREF_JS_OFF
);
414 setPref($data_dir, $username, 'javascript_on', $new_javascript_setting);