Added Flag/Unflag buttons. I have been up for 2 days straight. Please check for...
[squirrelmail.git] / include / options / display.php
CommitLineData
c36ed9cf 1<?php
e7db48af 2
35586184 3/**
4 * options_display.php
5 *
82d304a0 6 * Copyright (c) 1999-2004 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
6395c46d 20// load icon themes if in use
21global $use_icons;
22if ($use_icons) {
23 global $icon_themes;
24 $dirName = SM_PATH . 'images/themes';
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 }
31 }
32}
33
48af4b64 34/**
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
46 */
cbe5423b 47function load_optpage_data_display() {
ec2c91a1 48 global $theme, $language, $languages, $js_autodetect_results,
46dfa56e 49 $compose_new_win, $default_use_mdn, $squirrelmail_language, $allow_thread_sort,
6395c46d 50 $optmode, $show_alternative_names, $available_languages, $use_icons;
a3ec3c91 51
ce393174 52 /* Build a simple array into which we will build options. */
bbcafebd 53 $optgrps = array();
54 $optvals = array();
a3ec3c91 55
bbcafebd 56 /******************************************************/
57 /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */
58 /******************************************************/
bbcafebd 59
60 /*** Load the General Options into the array ***/
61 $optgrps[SMOPT_GRP_GENERAL] = _("General Display Options");
62 $optvals[SMOPT_GRP_GENERAL] = array();
63
64 /* Load the theme option. */
ce393174 65 $theme_values = array();
66 foreach ($theme as $theme_key => $theme_attributes) {
be278741 67 $theme_values[$theme_attributes['NAME']] = $theme_attributes['PATH'];
ce393174 68 }
be278741 69 ksort($theme_values);
70 $theme_values = array_flip($theme_values);
bbcafebd 71 $optvals[SMOPT_GRP_GENERAL][] = array(
ce393174 72 'name' => 'chosen_theme',
73 'caption' => _("Theme"),
74 'type' => SMOPT_TYPE_STRLIST,
75 'refresh' => SMOPT_REFRESH_ALL,
cbe5423b 76 'posvals' => $theme_values,
77 'save' => 'save_option_theme'
ce393174 78 );
8f1ba72b 79
80 $css_values = array( 'none' => _("Default" ) );
dcd6f144 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 );
8f1ba72b 85 }
dcd6f144 86 }
87 closedir($handle);
8f1ba72b 88
54078578 89 if ( count( $css_values ) > 1 ) {
e2cdae1f 90
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
97 );
98
99 }
39d3ec89 100
101 // config.php can be unupdated.
102 if (! isset($available_languages) || $available_languages=="" ) {
103 $available_languages="ALL"; }
8f1ba72b 104
e557fdb0 105 $language_values = array();
39d3ec89 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'];
114 }
115 }
116 }
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'];
127 }
128 }
129 }
ce393174 130 }
e557fdb0 131 asort($language_values);
8405d0a4 132 $language_values =
133 array_merge(array('' => _("Default")), $language_values);
ec2c91a1 134 $language = $squirrelmail_language;
39d3ec89 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
143 );
144 }
ce393174 145
a3ec3c91 146 /* Set values for the "use javascript" option. */
bbcafebd 147 $optvals[SMOPT_GRP_GENERAL][] = array(
a3ec3c91 148 'name' => 'javascript_setting',
ce393174 149 'caption' => _("Use Javascript"),
a3ec3c91 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"))
155 );
156
46dfa56e 157
158 if ($optmode != 'submit')
159 $onLoadScript = 'document.forms[0].new_js_autodetect_results.value = \'' . SMPREF_JS_ON . '\'';
160 else
161 $onLoadScript = '';
162
bbcafebd 163 $optvals[SMOPT_GRP_GENERAL][] = array(
a3ec3c91 164 'name' => 'js_autodetect_results',
165 'caption' => '',
166 'type' => SMOPT_TYPE_HIDDEN,
cbe5423b 167 'refresh' => SMOPT_REFRESH_NONE,
5826affb 168 //'post_script' => $js_autodetect_script,
cbe5423b 169 'save' => 'save_option_javascript_autodetect'
a3ec3c91 170 );
171
bbcafebd 172 /*** Load the General Options into the array ***/
173 $optgrps[SMOPT_GRP_MAILBOX] = _("Mailbox Display Options");
174 $optvals[SMOPT_GRP_MAILBOX] = array();
175
176 $optvals[SMOPT_GRP_MAILBOX][] = array(
a3ec3c91 177 'name' => 'show_num',
178 'caption' => _("Number of Messages to Index"),
179 'type' => SMOPT_TYPE_INTEGER,
bbcafebd 180 'refresh' => SMOPT_REFRESH_NONE,
181 'size' => SMOPT_SIZE_TINY
a3ec3c91 182 );
183
bbcafebd 184 $optvals[SMOPT_GRP_MAILBOX][] = array(
a440e68f 185 'name' => 'alt_index_colors',
186 'caption' => _("Enable Alternating Row Colors"),
187 'type' => SMOPT_TYPE_BOOLEAN,
188 'refresh' => SMOPT_REFRESH_NONE
189 );
190
6395c46d 191 if ($use_icons) {
192 global $icon_themes, $icon_theme;
193 $temp = array();
194 for ($count = 0; $count < sizeof($icon_themes); $count++) {
195 $temp[$count] = $icon_themes[$count]['NAME'];
196 if ($icon_theme == $icon_themes[$count]['PATH'])
197 $value = $count;
198 }
199 $optvals[SMOPT_GRP_MAILBOX][] = array(
200 'name' => 'icon_theme',
201 'caption' => _("Message Flags Icon Theme"),
202 'type' => SMOPT_TYPE_STRLIST,
203 'refresh' => SMOPT_REFRESH_NONE,
204 'posvals' => $temp,
205 'initial_value' => $value,
206 'save' => 'icon_theme_save'
207 );
208 }
209
fd181f53 210 $optvals[SMOPT_GRP_MAILBOX][] = array(
211 'name' => 'show_flag_buttons',
212 'caption' => _("Show Flag / Unflag Buttons"),
213 'type' => SMOPT_TYPE_BOOLEAN,
214 'refresh' => SMOPT_REFRESH_NONE
215 );
216
bbcafebd 217 $optvals[SMOPT_GRP_MAILBOX][] = array(
a440e68f 218 'name' => 'page_selector',
219 'caption' => _("Enable Page Selector"),
220 'type' => SMOPT_TYPE_BOOLEAN,
221 'refresh' => SMOPT_REFRESH_NONE
222 );
223
bbcafebd 224 $optvals[SMOPT_GRP_MAILBOX][] = array(
a440e68f 225 'name' => 'page_selector_max',
226 'caption' => _("Maximum Number of Pages to Show"),
227 'type' => SMOPT_TYPE_INTEGER,
bbcafebd 228 'refresh' => SMOPT_REFRESH_NONE,
229 'size' => SMOPT_SIZE_TINY
a440e68f 230 );
231
3e3b60e3 232 $optvals[SMOPT_GRP_MAILBOX][] = array(
233 'name' => 'show_full_date',
234 'caption' => _("Always Show Full Date"),
235 'type' => SMOPT_TYPE_BOOLEAN,
236 'refresh' => SMOPT_REFRESH_NONE
237 );
238
459e3347 239 $optvals[SMOPT_GRP_MAILBOX][] = array(
240 'name' => 'truncate_sender',
241 'caption' => _("Length of From/To Field (0 for full)"),
242 'type' => SMOPT_TYPE_INTEGER,
243 'refresh' => SMOPT_REFRESH_NONE,
244 'size' => SMOPT_SIZE_TINY
245 );
246
3fc1a95f 247 $optvals[SMOPT_GRP_MAILBOX][] = array(
248 'name' => 'truncate_subject',
249 'caption' => _("Length of Subject Field (0 for full)"),
250 'type' => SMOPT_TYPE_INTEGER,
251 'refresh' => SMOPT_REFRESH_NONE,
252 'size' => SMOPT_SIZE_TINY
253 );
254
1ae2832e 255 $optvals[SMOPT_GRP_MAILBOX][] = array(
256 'name' => 'show_recipient_instead',
257 'caption' => _("Show recipient name if the message is from your default identity"),
258 'type' => SMOPT_TYPE_BOOLEAN,
259 'refresh' => SMOPT_REFRESH_NONE,
260 'size' => SMOPT_SIZE_TINY
261 );
262
459e3347 263
bbcafebd 264 /*** Load the General Options into the array ***/
265 $optgrps[SMOPT_GRP_MESSAGE] = _("Message Display and Composition");
266 $optvals[SMOPT_GRP_MESSAGE] = array();
267
268 $optvals[SMOPT_GRP_MESSAGE][] = array(
a3ec3c91 269 'name' => 'wrap_at',
270 'caption' => _("Wrap Incoming Text At"),
271 'type' => SMOPT_TYPE_INTEGER,
bbcafebd 272 'refresh' => SMOPT_REFRESH_NONE,
273 'size' => SMOPT_SIZE_TINY
a3ec3c91 274 );
275
bbcafebd 276 $optvals[SMOPT_GRP_MESSAGE][] = array(
a3ec3c91 277 'name' => 'editor_size',
3cb80c8c 278 'caption' => _("Width of Editor Window"),
279 'type' => SMOPT_TYPE_INTEGER,
280 'refresh' => SMOPT_REFRESH_NONE,
281 'size' => SMOPT_SIZE_TINY
282 );
283
284 $optvals[SMOPT_GRP_MESSAGE][] = array(
285 'name' => 'editor_height',
286 'caption' => _("Height of Editor Window"),
a3ec3c91 287 'type' => SMOPT_TYPE_INTEGER,
bbcafebd 288 'refresh' => SMOPT_REFRESH_NONE,
289 'size' => SMOPT_SIZE_TINY
a3ec3c91 290 );
291
bbcafebd 292 $optvals[SMOPT_GRP_MESSAGE][] = array(
a3ec3c91 293 'name' => 'location_of_buttons',
ce393174 294 'caption' => _("Location of Buttons when Composing"),
a3ec3c91 295 'type' => SMOPT_TYPE_STRLIST,
296 'refresh' => SMOPT_REFRESH_NONE,
ce393174 297 'posvals' => array(SMPREF_LOC_TOP => _("Before headers"),
298 SMPREF_LOC_BETWEEN => _("Between headers and message body"),
299 SMPREF_LOC_BOTTOM => _("After message body"))
a3ec3c91 300 );
301
07687736 302
bbcafebd 303 $optvals[SMOPT_GRP_MESSAGE][] = array(
a440e68f 304 'name' => 'use_javascript_addr_book',
305 'caption' => _("Addressbook Display Format"),
ce393174 306 'type' => SMOPT_TYPE_STRLIST,
a440e68f 307 'refresh' => SMOPT_REFRESH_NONE,
308 'posvals' => array('1' => _("Javascript"),
309 '0' => _("HTML"))
fd87494d 310 );
311
bbcafebd 312 $optvals[SMOPT_GRP_MESSAGE][] = array(
fd87494d 313 'name' => 'show_html_default',
314 'caption' => _("Show HTML Version by Default"),
315 'type' => SMOPT_TYPE_BOOLEAN,
316 'refresh' => SMOPT_REFRESH_NONE
317 );
318
bbcafebd 319 $optvals[SMOPT_GRP_MESSAGE][] = array(
6206f6c4 320 'name' => 'enable_forward_as_attachment',
321 'caption' => _("Enable Forward as Attachment"),
fd87494d 322 'type' => SMOPT_TYPE_BOOLEAN,
323 'refresh' => SMOPT_REFRESH_NONE
324 );
325
a0bc3274 326 $optvals[SMOPT_GRP_MESSAGE][] = array(
327 'name' => 'forward_cc',
6206f6c4 328 'caption' => _("Include CCs when Forwarding Messages"),
329 'type' => SMOPT_TYPE_BOOLEAN,
330 'refresh' => SMOPT_REFRESH_NONE
331 );
332
333 $optvals[SMOPT_GRP_MESSAGE][] = array(
334 'name' => 'include_self_reply_all',
335 'caption' => _("Include Me in CC when I Reply All"),
a0bc3274 336 'type' => SMOPT_TYPE_BOOLEAN,
337 'refresh' => SMOPT_REFRESH_NONE
338 );
339
bbcafebd 340 $optvals[SMOPT_GRP_MESSAGE][] = array(
9ab0d96f 341 'name' => 'show_xmailer_default',
a440e68f 342 'caption' => _("Enable Mailer Display"),
9ab0d96f 343 'type' => SMOPT_TYPE_BOOLEAN,
344 'refresh' => SMOPT_REFRESH_NONE
345 );
346
7baf86a9 347 $optvals[SMOPT_GRP_MESSAGE][] = array(
348 'name' => 'attachment_common_show_images',
10f0ce72 349 'caption' => _("Display Attached Images with Message"),
7baf86a9 350 'type' => SMOPT_TYPE_BOOLEAN,
351 'refresh' => SMOPT_REFRESH_NONE
352 );
353
f226cba7 354 $optvals[SMOPT_GRP_MESSAGE][] = array(
355 'name' => 'pf_cleandisplay',
10f0ce72 356 'caption' => _("Enable Printer Friendly Clean Display"),
f226cba7 357 'type' => SMOPT_TYPE_BOOLEAN,
358 'refresh' => SMOPT_REFRESH_NONE
359 );
07687736 360
57257333 361 if ($default_use_mdn) {
362 $optvals[SMOPT_GRP_MESSAGE][] = array(
363 'name' => 'mdn_user_support',
6206f6c4 364 'caption' => _("Enable Mail Delivery Notification"),
57257333 365 'type' => SMOPT_TYPE_BOOLEAN,
366 'refresh' => SMOPT_REFRESH_NONE
367 );
368 }
07687736 369
9c3e6cd4 370 $optvals[SMOPT_GRP_MESSAGE][] = array(
371 'name' => 'compose_new_win',
6206f6c4 372 'caption' => _("Compose Messages in New Window"),
9c3e6cd4 373 'type' => SMOPT_TYPE_BOOLEAN,
374 'refresh' => SMOPT_REFRESH_ALL
375 );
07687736 376
377 $optvals[SMOPT_GRP_MESSAGE][] = array(
378 'name' => 'compose_width',
6206f6c4 379 'caption' => _("Width of Compose Window"),
07687736 380 'type' => SMOPT_TYPE_INTEGER,
381 'refresh' => SMOPT_REFRESH_ALL,
382 'size' => SMOPT_SIZE_TINY
383 );
384
385 $optvals[SMOPT_GRP_MESSAGE][] = array(
386 'name' => 'compose_height',
6206f6c4 387 'caption' => _("Height of Compose Window"),
07687736 388 'type' => SMOPT_TYPE_INTEGER,
389 'refresh' => SMOPT_REFRESH_ALL,
390 'size' => SMOPT_SIZE_TINY
391 );
392
3b17e952 393 $optvals[SMOPT_GRP_MESSAGE][] = array(
394 'name' => 'sig_first',
6206f6c4 395 'caption' => _("Append Signature before Reply/Forward Text"),
3b17e952 396 'type' => SMOPT_TYPE_BOOLEAN,
397 'refresh' => SMOPT_REFRESH_NONE
398 );
07687736 399
9f2f6126 400 $optvals[SMOPT_GRP_MESSAGE][] = array(
401 'name' => 'reply_focus',
402 'caption' => _("Cursor Position when Replying"),
403 'type' => SMOPT_TYPE_STRLIST,
404 'refresh' => SMOPT_REFRESH_NONE,
405 'posvals' => array('' => _("To: field"),
406 'focus' => _("Focus in body"),
407 'select' => _("Select body"))
408 );
409
4ee86d70 410 $optvals[SMOPT_GRP_MESSAGE][] = array(
411 'name' => 'strip_sigs',
412 'caption' => _("Strip signature when replying"),
413 'type' => SMOPT_TYPE_BOOLEAN,
414 'refresh' => SMOPT_REFRESH_NONE
415 );
416
df9fdeb9 417 $optvals[SMOPT_GRP_MESSAGE][] = array(
418 'name' => 'internal_date_sort',
6206f6c4 419 'caption' => _("Enable Sort by of Receive Date"),
df9fdeb9 420 'type' => SMOPT_TYPE_BOOLEAN,
421 'refresh' => SMOPT_REFRESH_ALL
422 );
794d59c0 423 if ($allow_thread_sort == TRUE) {
7c612fdd 424 $optvals[SMOPT_GRP_MESSAGE][] = array(
425 'name' => 'sort_by_ref',
6206f6c4 426 'caption' => _("Enable Thread Sort by References Header"),
7c612fdd 427 'type' => SMOPT_TYPE_BOOLEAN,
428 'refresh' => SMOPT_REFRESH_ALL
429 );
4267d5de 430 $optvals[SMOPT_GRP_MESSAGE][] = array(
431 'name' => 'delete_prev_next_display',
432 'caption' => _("Show 'Delete & Prev/Next' Links"),
433 'type' => SMOPT_TYPE_BOOLEAN,
434 'refresh' => SMOPT_REFRESH_ALL
435 );
436
7c612fdd 437 }
cbe5423b 438 /* Assemble all this together and return it as our result. */
439 $result = array(
440 'grps' => $optgrps,
5826affb 441 'vals' => $optvals,
442 'xtra' => $onLoadScript
cbe5423b 443 );
444 return ($result);
445}
a3ec3c91 446
cbe5423b 447/******************************************************************/
448/** Define any specialized save functions for this option page. ***/
449/******************************************************************/
f1e6f580 450
48af4b64 451/**
452 * This function saves a new theme setting.
453 * It updates the theme array.
454 */
cbe5423b 455function save_option_theme($option) {
456 global $theme;
e7db48af 457
cbe5423b 458 /* Do checking to make sure $new_theme is in the array. */
459 $theme_in_array = false;
460 for ($i = 0; $i < count($theme); ++$i) {
461 if ($theme[$i]['PATH'] == $option->new_value) {
462 $theme_in_array = true;
463 break;
464 }
465 }
466
467 if (!$theme_in_array) {
468 $option->new_value = '';
469 }
e7db48af 470
cbe5423b 471 /* Save the option like normal. */
472 save_option($option);
473}
e7db48af 474
48af4b64 475/**
476 * This function saves the javascript detection option.
477 */
cbe5423b 478function save_option_javascript_autodetect($option) {
479 global $data_dir, $username, $new_javascript_setting;
23d6bd09 480
cbe5423b 481 /* Set javascript either on or off. */
482 if ($new_javascript_setting == SMPREF_JS_AUTODETECT) {
483 if ($option->new_value == SMPREF_JS_ON) {
484 setPref($data_dir, $username, 'javascript_on', SMPREF_JS_ON);
485 } else {
486 setPref($data_dir, $username, 'javascript_on', SMPREF_JS_OFF);
487 }
488 } else {
489 setPref($data_dir, $username, 'javascript_on', $new_javascript_setting);
490 }
491}
492
6395c46d 493/**
494 * This function saves the user's icon theme setting
495 */
496function icon_theme_save($option) {
497
498 global $icon_themes, $data_dir, $username;
499
500
501 // Don't assume the new value is there, double check
502 // and only save if found
503 //
504 if (isset($icon_themes[$option->new_value]['PATH']))
505 setPref($data_dir, $username, 'icon_theme', $icon_themes[$option->new_value]['PATH']);
506 else
507 setPref($data_dir, $username, 'icon_theme', 'none');
508
509}
510
cbe5423b 511?>