Phpdocumentor update - sed is your friend for these kinds of things ;)
[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 *
763b63fe 11 * @version $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';
4f7a5870 25 if (is_readable($dirName) && is_dir($dirName)) {
26 $d = dir($dirName);
27 while($dir = $d->read()) {
28 if ($dir != "." && $dir != "..") {
29 if (is_dir($dirName."/".$dir) && file_exists("$dirName/$dir/theme.php"))
30 include("$dirName/$dir/theme.php");
31 }
6395c46d 32 }
33 }
34}
35
48af4b64 36/**
37 * This function builds an array with all the information about
38 * the options available to the user, and returns it. The options
39 * are grouped by the groups in which they are displayed.
40 * For each option, the following information is stored:
41 * - name: the internal (variable) name
42 * - caption: the description of the option in the UI
43 * - type: one of SMOPT_TYPE_*
44 * - refresh: one of SMOPT_REFRESH_*
45 * - size: one of SMOPT_SIZE_*
46 * - save: the name of a function to call when saving this option
47 * @return array all option information
48 */
cbe5423b 49function load_optpage_data_display() {
ae958cd3 50 global $theme, $language, $languages, $js_autodetect_results, $javascript_setting,
46dfa56e 51 $compose_new_win, $default_use_mdn, $squirrelmail_language, $allow_thread_sort,
6395c46d 52 $optmode, $show_alternative_names, $available_languages, $use_icons;
a3ec3c91 53
ce393174 54 /* Build a simple array into which we will build options. */
bbcafebd 55 $optgrps = array();
56 $optvals = array();
a3ec3c91 57
bbcafebd 58 /******************************************************/
59 /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */
60 /******************************************************/
bbcafebd 61
62 /*** Load the General Options into the array ***/
63 $optgrps[SMOPT_GRP_GENERAL] = _("General Display Options");
64 $optvals[SMOPT_GRP_GENERAL] = array();
65
66 /* Load the theme option. */
ce393174 67 $theme_values = array();
68 foreach ($theme as $theme_key => $theme_attributes) {
be278741 69 $theme_values[$theme_attributes['NAME']] = $theme_attributes['PATH'];
ce393174 70 }
be278741 71 ksort($theme_values);
72 $theme_values = array_flip($theme_values);
bbcafebd 73 $optvals[SMOPT_GRP_GENERAL][] = array(
ce393174 74 'name' => 'chosen_theme',
75 'caption' => _("Theme"),
76 'type' => SMOPT_TYPE_STRLIST,
77 'refresh' => SMOPT_REFRESH_ALL,
cbe5423b 78 'posvals' => $theme_values,
79 'save' => 'save_option_theme'
ce393174 80 );
8f1ba72b 81
82 $css_values = array( 'none' => _("Default" ) );
4f7a5870 83
84 if (is_readable(SM_PATH . 'themes/css') && is_dir(SM_PATH . 'themes/css')) {
85 $handle=opendir(SM_PATH . 'themes/css');
86 while ($file = readdir($handle) ) {
87 if ( substr( $file, -4 ) == '.css' ) {
88 $css_values[$file] = substr( $file, 0, strlen( $file ) - 4 );
89 }
8f1ba72b 90 }
4f7a5870 91 closedir($handle);
dcd6f144 92 }
8f1ba72b 93
54078578 94 if ( count( $css_values ) > 1 ) {
e2cdae1f 95
96 $optvals[SMOPT_GRP_GENERAL][] = array(
97 'name' => 'custom_css',
98 'caption' => _("Custom Stylesheet"),
99 'type' => SMOPT_TYPE_STRLIST,
100 'refresh' => SMOPT_REFRESH_ALL,
101 'posvals' => $css_values
102 );
103
104 }
39d3ec89 105
106 // config.php can be unupdated.
107 if (! isset($available_languages) || $available_languages=="" ) {
108 $available_languages="ALL"; }
8f1ba72b 109
e557fdb0 110 $language_values = array();
39d3ec89 111 if ( strtoupper($available_languages)=='ALL') {
112 foreach ($languages as $lang_key => $lang_attributes) {
113 if (isset($lang_attributes['NAME'])) {
114 $language_values[$lang_key] = $lang_attributes['NAME'];
115 if ( isset($show_alternative_names) &&
116 $show_alternative_names &&
117 isset($lang_attributes['ALTNAME']) ) {
118 $language_values[$lang_key] .= " / " . $lang_attributes['ALTNAME'];
119 }
120 }
121 }
122 } else if (strtoupper($available_languages)!='NONE') {
123 // admin can set list of available languages in config
124 $available_languages_array=explode (" ",$available_languages);
125 foreach ($available_languages_array as $lang_key ) {
126 if (isset($languages[$lang_key]['NAME'])) {
127 $language_values[$lang_key] = $languages[$lang_key]['NAME'];
128 if ( isset($show_alternative_names) &&
129 $show_alternative_names &&
130 isset($languages[$lang_key]['ALTNAME']) ) {
131 $language_values[$lang_key] .= " / " . $languages[$lang_key]['ALTNAME'];
132 }
133 }
134 }
ce393174 135 }
e557fdb0 136 asort($language_values);
8405d0a4 137 $language_values =
138 array_merge(array('' => _("Default")), $language_values);
ec2c91a1 139 $language = $squirrelmail_language;
39d3ec89 140 if (strtoupper($available_languages)!='NONE') {
141 // if set to 'none', interface will use only default language
142 $optvals[SMOPT_GRP_GENERAL][] = array(
143 'name' => 'language',
144 'caption' => _("Language"),
145 'type' => SMOPT_TYPE_STRLIST,
146 'refresh' => SMOPT_REFRESH_ALL,
147 'posvals' => $language_values
148 );
149 }
ce393174 150
a3ec3c91 151 /* Set values for the "use javascript" option. */
bbcafebd 152 $optvals[SMOPT_GRP_GENERAL][] = array(
a3ec3c91 153 'name' => 'javascript_setting',
ce393174 154 'caption' => _("Use Javascript"),
a3ec3c91 155 'type' => SMOPT_TYPE_STRLIST,
156 'refresh' => SMOPT_REFRESH_ALL,
157 'posvals' => array(SMPREF_JS_AUTODETECT => _("Autodetect"),
158 SMPREF_JS_ON => _("Always"),
ae958cd3 159 SMPREF_JS_OFF => _("Never")),
160 'save' => 'save_option_javascript_autodetect',
161 'script' => 'onclick="document.forms[0].new_js_autodetect_results.value = \'' . SMPREF_JS_ON . '\';"'
a3ec3c91 162 );
163
bbcafebd 164 $optvals[SMOPT_GRP_GENERAL][] = array(
a3ec3c91 165 'name' => 'js_autodetect_results',
166 'caption' => '',
167 'type' => SMOPT_TYPE_HIDDEN,
ae958cd3 168 'refresh' => SMOPT_REFRESH_NONE
5826affb 169 //'post_script' => $js_autodetect_script,
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 }
4f7a5870 199 if (sizeof($icon_themes) > 0) {
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,
205 'posvals' => $temp,
206 'initial_value' => $value,
207 'save' => 'icon_theme_save'
208 );
209 }
6395c46d 210 }
211
bbcafebd 212 $optvals[SMOPT_GRP_MAILBOX][] = array(
fd181f53 213 'name' => 'show_flag_buttons',
214 'caption' => _("Show Flag / Unflag Buttons"),
215 'type' => SMOPT_TYPE_BOOLEAN,
216 'refresh' => SMOPT_REFRESH_NONE
217 );
218
219 $optvals[SMOPT_GRP_MAILBOX][] = array(
a440e68f 220 'name' => 'page_selector',
221 'caption' => _("Enable Page Selector"),
222 'type' => SMOPT_TYPE_BOOLEAN,
223 'refresh' => SMOPT_REFRESH_NONE
224 );
225
bbcafebd 226 $optvals[SMOPT_GRP_MAILBOX][] = array(
a440e68f 227 'name' => 'page_selector_max',
228 'caption' => _("Maximum Number of Pages to Show"),
229 'type' => SMOPT_TYPE_INTEGER,
bbcafebd 230 'refresh' => SMOPT_REFRESH_NONE,
231 'size' => SMOPT_SIZE_TINY
a440e68f 232 );
233
3e3b60e3 234 $optvals[SMOPT_GRP_MAILBOX][] = array(
235 'name' => 'show_full_date',
236 'caption' => _("Always Show Full Date"),
237 'type' => SMOPT_TYPE_BOOLEAN,
238 'refresh' => SMOPT_REFRESH_NONE
239 );
240
459e3347 241 $optvals[SMOPT_GRP_MAILBOX][] = array(
242 'name' => 'truncate_sender',
243 'caption' => _("Length of From/To Field (0 for full)"),
244 'type' => SMOPT_TYPE_INTEGER,
245 'refresh' => SMOPT_REFRESH_NONE,
246 'size' => SMOPT_SIZE_TINY
247 );
248
3fc1a95f 249 $optvals[SMOPT_GRP_MAILBOX][] = array(
250 'name' => 'truncate_subject',
251 'caption' => _("Length of Subject Field (0 for full)"),
252 'type' => SMOPT_TYPE_INTEGER,
253 'refresh' => SMOPT_REFRESH_NONE,
254 'size' => SMOPT_SIZE_TINY
255 );
256
1ae2832e 257 $optvals[SMOPT_GRP_MAILBOX][] = array(
258 'name' => 'show_recipient_instead',
259 'caption' => _("Show recipient name if the message is from your default identity"),
260 'type' => SMOPT_TYPE_BOOLEAN,
261 'refresh' => SMOPT_REFRESH_NONE,
262 'size' => SMOPT_SIZE_TINY
263 );
264
459e3347 265
bbcafebd 266 /*** Load the General Options into the array ***/
267 $optgrps[SMOPT_GRP_MESSAGE] = _("Message Display and Composition");
268 $optvals[SMOPT_GRP_MESSAGE] = array();
269
270 $optvals[SMOPT_GRP_MESSAGE][] = array(
a3ec3c91 271 'name' => 'wrap_at',
272 'caption' => _("Wrap Incoming Text At"),
273 'type' => SMOPT_TYPE_INTEGER,
bbcafebd 274 'refresh' => SMOPT_REFRESH_NONE,
275 'size' => SMOPT_SIZE_TINY
a3ec3c91 276 );
277
bbcafebd 278 $optvals[SMOPT_GRP_MESSAGE][] = array(
a3ec3c91 279 'name' => 'editor_size',
3cb80c8c 280 'caption' => _("Width of Editor Window"),
281 'type' => SMOPT_TYPE_INTEGER,
282 'refresh' => SMOPT_REFRESH_NONE,
283 'size' => SMOPT_SIZE_TINY
284 );
285
286 $optvals[SMOPT_GRP_MESSAGE][] = array(
287 'name' => 'editor_height',
288 'caption' => _("Height of Editor Window"),
a3ec3c91 289 'type' => SMOPT_TYPE_INTEGER,
bbcafebd 290 'refresh' => SMOPT_REFRESH_NONE,
291 'size' => SMOPT_SIZE_TINY
a3ec3c91 292 );
293
bbcafebd 294 $optvals[SMOPT_GRP_MESSAGE][] = array(
a3ec3c91 295 'name' => 'location_of_buttons',
ce393174 296 'caption' => _("Location of Buttons when Composing"),
a3ec3c91 297 'type' => SMOPT_TYPE_STRLIST,
298 'refresh' => SMOPT_REFRESH_NONE,
ce393174 299 'posvals' => array(SMPREF_LOC_TOP => _("Before headers"),
300 SMPREF_LOC_BETWEEN => _("Between headers and message body"),
301 SMPREF_LOC_BOTTOM => _("After message body"))
a3ec3c91 302 );
303
07687736 304
bbcafebd 305 $optvals[SMOPT_GRP_MESSAGE][] = array(
a440e68f 306 'name' => 'use_javascript_addr_book',
307 'caption' => _("Addressbook Display Format"),
ce393174 308 'type' => SMOPT_TYPE_STRLIST,
a440e68f 309 'refresh' => SMOPT_REFRESH_NONE,
310 'posvals' => array('1' => _("Javascript"),
311 '0' => _("HTML"))
fd87494d 312 );
313
bbcafebd 314 $optvals[SMOPT_GRP_MESSAGE][] = array(
fd87494d 315 'name' => 'show_html_default',
316 'caption' => _("Show HTML Version by Default"),
317 'type' => SMOPT_TYPE_BOOLEAN,
318 'refresh' => SMOPT_REFRESH_NONE
319 );
320
bbcafebd 321 $optvals[SMOPT_GRP_MESSAGE][] = array(
6206f6c4 322 'name' => 'enable_forward_as_attachment',
323 'caption' => _("Enable Forward as Attachment"),
fd87494d 324 'type' => SMOPT_TYPE_BOOLEAN,
325 'refresh' => SMOPT_REFRESH_NONE
326 );
327
bbcafebd 328 $optvals[SMOPT_GRP_MESSAGE][] = array(
a0bc3274 329 'name' => 'forward_cc',
6206f6c4 330 'caption' => _("Include CCs when Forwarding Messages"),
331 'type' => SMOPT_TYPE_BOOLEAN,
332 'refresh' => SMOPT_REFRESH_NONE
333 );
334
335 $optvals[SMOPT_GRP_MESSAGE][] = array(
336 'name' => 'include_self_reply_all',
337 'caption' => _("Include Me in CC when I Reply All"),
a0bc3274 338 'type' => SMOPT_TYPE_BOOLEAN,
339 'refresh' => SMOPT_REFRESH_NONE
340 );
341
342 $optvals[SMOPT_GRP_MESSAGE][] = array(
9ab0d96f 343 'name' => 'show_xmailer_default',
a440e68f 344 'caption' => _("Enable Mailer Display"),
9ab0d96f 345 'type' => SMOPT_TYPE_BOOLEAN,
346 'refresh' => SMOPT_REFRESH_NONE
347 );
348
7baf86a9 349 $optvals[SMOPT_GRP_MESSAGE][] = array(
350 'name' => 'attachment_common_show_images',
10f0ce72 351 'caption' => _("Display Attached Images with Message"),
7baf86a9 352 'type' => SMOPT_TYPE_BOOLEAN,
353 'refresh' => SMOPT_REFRESH_NONE
354 );
355
f226cba7 356 $optvals[SMOPT_GRP_MESSAGE][] = array(
f226cba7 357 'name' => 'pf_cleandisplay',
10f0ce72 358 'caption' => _("Enable Printer Friendly Clean Display"),
f226cba7 359 'type' => SMOPT_TYPE_BOOLEAN,
360 'refresh' => SMOPT_REFRESH_NONE
361 );
07687736 362
57257333 363 if ($default_use_mdn) {
364 $optvals[SMOPT_GRP_MESSAGE][] = array(
365 'name' => 'mdn_user_support',
6206f6c4 366 'caption' => _("Enable Mail Delivery Notification"),
57257333 367 'type' => SMOPT_TYPE_BOOLEAN,
368 'refresh' => SMOPT_REFRESH_NONE
369 );
370 }
07687736 371
9c3e6cd4 372 $optvals[SMOPT_GRP_MESSAGE][] = array(
373 'name' => 'compose_new_win',
6206f6c4 374 'caption' => _("Compose Messages in New Window"),
9c3e6cd4 375 'type' => SMOPT_TYPE_BOOLEAN,
376 'refresh' => SMOPT_REFRESH_ALL
377 );
07687736 378
379 $optvals[SMOPT_GRP_MESSAGE][] = array(
380 'name' => 'compose_width',
6206f6c4 381 'caption' => _("Width of Compose Window"),
07687736 382 'type' => SMOPT_TYPE_INTEGER,
383 'refresh' => SMOPT_REFRESH_ALL,
384 'size' => SMOPT_SIZE_TINY
385 );
386
387 $optvals[SMOPT_GRP_MESSAGE][] = array(
388 'name' => 'compose_height',
6206f6c4 389 'caption' => _("Height of Compose Window"),
07687736 390 'type' => SMOPT_TYPE_INTEGER,
391 'refresh' => SMOPT_REFRESH_ALL,
392 'size' => SMOPT_SIZE_TINY
393 );
394
3b17e952 395 $optvals[SMOPT_GRP_MESSAGE][] = array(
396 'name' => 'sig_first',
6206f6c4 397 'caption' => _("Append Signature before Reply/Forward Text"),
3b17e952 398 'type' => SMOPT_TYPE_BOOLEAN,
399 'refresh' => SMOPT_REFRESH_NONE
400 );
07687736 401
df9fdeb9 402 $optvals[SMOPT_GRP_MESSAGE][] = array(
9f2f6126 403 'name' => 'reply_focus',
404 'caption' => _("Cursor Position when Replying"),
405 'type' => SMOPT_TYPE_STRLIST,
406 'refresh' => SMOPT_REFRESH_NONE,
407 'posvals' => array('' => _("To: field"),
408 'focus' => _("Focus in body"),
409 'select' => _("Select body"))
410 );
411
412 $optvals[SMOPT_GRP_MESSAGE][] = array(
4ee86d70 413 'name' => 'strip_sigs',
414 'caption' => _("Strip signature when replying"),
415 'type' => SMOPT_TYPE_BOOLEAN,
416 'refresh' => SMOPT_REFRESH_NONE
417 );
418
419 $optvals[SMOPT_GRP_MESSAGE][] = array(
df9fdeb9 420 'name' => 'internal_date_sort',
6206f6c4 421 'caption' => _("Enable Sort by of Receive Date"),
df9fdeb9 422 'type' => SMOPT_TYPE_BOOLEAN,
423 'refresh' => SMOPT_REFRESH_ALL
424 );
794d59c0 425 if ($allow_thread_sort == TRUE) {
7c612fdd 426 $optvals[SMOPT_GRP_MESSAGE][] = array(
427 'name' => 'sort_by_ref',
6206f6c4 428 'caption' => _("Enable Thread Sort by References Header"),
7c612fdd 429 'type' => SMOPT_TYPE_BOOLEAN,
430 'refresh' => SMOPT_REFRESH_ALL
431 );
4267d5de 432 $optvals[SMOPT_GRP_MESSAGE][] = array(
433 'name' => 'delete_prev_next_display',
434 'caption' => _("Show 'Delete & Prev/Next' Links"),
435 'type' => SMOPT_TYPE_BOOLEAN,
436 'refresh' => SMOPT_REFRESH_ALL
437 );
438
7c612fdd 439 }
cbe5423b 440 /* Assemble all this together and return it as our result. */
441 $result = array(
442 'grps' => $optgrps,
ae958cd3 443 'vals' => $optvals
cbe5423b 444 );
445 return ($result);
446}
a3ec3c91 447
cbe5423b 448/******************************************************************/
449/** Define any specialized save functions for this option page. ***/
450/******************************************************************/
f1e6f580 451
48af4b64 452/**
453 * This function saves a new theme setting.
454 * It updates the theme array.
455 */
cbe5423b 456function save_option_theme($option) {
457 global $theme;
e7db48af 458
cbe5423b 459 /* Do checking to make sure $new_theme is in the array. */
460 $theme_in_array = false;
461 for ($i = 0; $i < count($theme); ++$i) {
462 if ($theme[$i]['PATH'] == $option->new_value) {
463 $theme_in_array = true;
464 break;
465 }
466 }
467
468 if (!$theme_in_array) {
469 $option->new_value = '';
470 }
e7db48af 471
cbe5423b 472 /* Save the option like normal. */
473 save_option($option);
474}
e7db48af 475
48af4b64 476/**
477 * This function saves the javascript detection option.
478 */
cbe5423b 479function save_option_javascript_autodetect($option) {
ae958cd3 480 global $data_dir, $username;
23d6bd09 481
ae958cd3 482 save_option($option);
483 checkForJavascript(TRUE);
cbe5423b 484}
485
6395c46d 486/**
487 * This function saves the user's icon theme setting
488 */
489function icon_theme_save($option) {
490
491 global $icon_themes, $data_dir, $username;
492
493
494 // Don't assume the new value is there, double check
495 // and only save if found
496 //
497 if (isset($icon_themes[$option->new_value]['PATH']))
498 setPref($data_dir, $username, 'icon_theme', $icon_themes[$option->new_value]['PATH']);
499 else
500 setPref($data_dir, $username, 'icon_theme', 'none');
501
502}
503
cbe5423b 504?>