fixed comp_in_new handling
[squirrelmail.git] / src / options_display.php
CommitLineData
c36ed9cf 1<?php
e7db48af 2
35586184 3/**
4 * options_display.php
5 *
15e6162e 6 * Copyright (c) 1999-2002 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$
12 */
cbe5423b 13
14/* Define the group constants for the display options page. */
15define('SMOPT_GRP_GENERAL', 0);
16define('SMOPT_GRP_MAILBOX', 1);
17define('SMOPT_GRP_MESSAGE', 2);
18
19/* Define the optpage load function for the display options page. */
20function load_optpage_data_display() {
ec2c91a1 21 global $theme, $language, $languages, $js_autodetect_results,
07687736 22 $compose_new_win, $default_use_mdn, $squirrelmail_language, $allow_thread_sort;
a3ec3c91 23
ce393174 24 /* Build a simple array into which we will build options. */
bbcafebd 25 $optgrps = array();
26 $optvals = array();
a3ec3c91 27
bbcafebd 28 /******************************************************/
29 /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */
30 /******************************************************/
bbcafebd 31
32 /*** Load the General Options into the array ***/
33 $optgrps[SMOPT_GRP_GENERAL] = _("General Display Options");
34 $optvals[SMOPT_GRP_GENERAL] = array();
35
36 /* Load the theme option. */
ce393174 37 $theme_values = array();
38 foreach ($theme as $theme_key => $theme_attributes) {
be278741 39 $theme_values[$theme_attributes['NAME']] = $theme_attributes['PATH'];
ce393174 40 }
be278741 41 ksort($theme_values);
42 $theme_values = array_flip($theme_values);
bbcafebd 43 $optvals[SMOPT_GRP_GENERAL][] = array(
ce393174 44 'name' => 'chosen_theme',
45 'caption' => _("Theme"),
46 'type' => SMOPT_TYPE_STRLIST,
47 'refresh' => SMOPT_REFRESH_ALL,
cbe5423b 48 'posvals' => $theme_values,
49 'save' => 'save_option_theme'
ce393174 50 );
8f1ba72b 51
52 $css_values = array( 'none' => _("Default" ) );
dcd6f144 53 $handle=opendir('../themes/css/');
54 while ($file = readdir($handle) ) {
55 if ( substr( $file, -4 ) == '.css' ) {
56 $css_values[$file] = substr( $file, 0, strlen( $file ) - 4 );
8f1ba72b 57 }
dcd6f144 58 }
59 closedir($handle);
8f1ba72b 60
e2cdae1f 61 if ( count( $css_values > 1 ) ) {
62
63 $optvals[SMOPT_GRP_GENERAL][] = array(
64 'name' => 'custom_css',
65 'caption' => _("Custom Stylesheet"),
66 'type' => SMOPT_TYPE_STRLIST,
67 'refresh' => SMOPT_REFRESH_ALL,
68 'posvals' => $css_values
69 );
70
71 }
8f1ba72b 72
e557fdb0 73 $language_values = array();
ce393174 74 foreach ($languages as $lang_key => $lang_attributes) {
75 if (isset($lang_attributes['NAME'])) {
7f79cdf0 76 $language_values[$lang_key] = $lang_attributes['NAME'];
ce393174 77 }
78 }
e557fdb0 79 asort($language_values);
8405d0a4 80 $language_values =
81 array_merge(array('' => _("Default")), $language_values);
ec2c91a1 82 $language = $squirrelmail_language;
bbcafebd 83 $optvals[SMOPT_GRP_GENERAL][] = array(
ce393174 84 'name' => 'language',
85 'caption' => _("Language"),
86 'type' => SMOPT_TYPE_STRLIST,
87 'refresh' => SMOPT_REFRESH_ALL,
88 'posvals' => $language_values
89 );
90
a3ec3c91 91 /* Set values for the "use javascript" option. */
bbcafebd 92 $optvals[SMOPT_GRP_GENERAL][] = array(
a3ec3c91 93 'name' => 'javascript_setting',
ce393174 94 'caption' => _("Use Javascript"),
a3ec3c91 95 'type' => SMOPT_TYPE_STRLIST,
96 'refresh' => SMOPT_REFRESH_ALL,
97 'posvals' => array(SMPREF_JS_AUTODETECT => _("Autodetect"),
98 SMPREF_JS_ON => _("Always"),
99 SMPREF_JS_OFF => _("Never"))
100 );
101
e697b6cc 102 $js_autodetect_script =
103 "<SCRIPT LANGUAGE=\"JavaScript\"><!--\n".
104 "document.forms[0].new_js_autodetect_results.value = '" . SMPREF_JS_ON . "';\n".
105 "// --></SCRIPT>\n";
a3ec3c91 106 $js_autodetect_results = SMPREF_JS_OFF;
bbcafebd 107 $optvals[SMOPT_GRP_GENERAL][] = array(
a3ec3c91 108 'name' => 'js_autodetect_results',
109 'caption' => '',
110 'type' => SMOPT_TYPE_HIDDEN,
cbe5423b 111 'refresh' => SMOPT_REFRESH_NONE,
112 'script' => $js_autodetect_script,
113 'save' => 'save_option_javascript_autodetect'
a3ec3c91 114 );
115
bbcafebd 116 /*** Load the General Options into the array ***/
117 $optgrps[SMOPT_GRP_MAILBOX] = _("Mailbox Display Options");
118 $optvals[SMOPT_GRP_MAILBOX] = array();
119
120 $optvals[SMOPT_GRP_MAILBOX][] = array(
a3ec3c91 121 'name' => 'show_num',
122 'caption' => _("Number of Messages to Index"),
123 'type' => SMOPT_TYPE_INTEGER,
bbcafebd 124 'refresh' => SMOPT_REFRESH_NONE,
125 'size' => SMOPT_SIZE_TINY
a3ec3c91 126 );
127
bbcafebd 128 $optvals[SMOPT_GRP_MAILBOX][] = array(
a440e68f 129 'name' => 'alt_index_colors',
130 'caption' => _("Enable Alternating Row Colors"),
131 'type' => SMOPT_TYPE_BOOLEAN,
132 'refresh' => SMOPT_REFRESH_NONE
133 );
134
bbcafebd 135 $optvals[SMOPT_GRP_MAILBOX][] = array(
a440e68f 136 'name' => 'page_selector',
137 'caption' => _("Enable Page Selector"),
138 'type' => SMOPT_TYPE_BOOLEAN,
139 'refresh' => SMOPT_REFRESH_NONE
140 );
141
bbcafebd 142 $optvals[SMOPT_GRP_MAILBOX][] = array(
a440e68f 143 'name' => 'page_selector_max',
144 'caption' => _("Maximum Number of Pages to Show"),
145 'type' => SMOPT_TYPE_INTEGER,
bbcafebd 146 'refresh' => SMOPT_REFRESH_NONE,
147 'size' => SMOPT_SIZE_TINY
a440e68f 148 );
149
bbcafebd 150 /*** Load the General Options into the array ***/
151 $optgrps[SMOPT_GRP_MESSAGE] = _("Message Display and Composition");
152 $optvals[SMOPT_GRP_MESSAGE] = array();
153
154 $optvals[SMOPT_GRP_MESSAGE][] = array(
a3ec3c91 155 'name' => 'wrap_at',
156 'caption' => _("Wrap Incoming Text At"),
157 'type' => SMOPT_TYPE_INTEGER,
bbcafebd 158 'refresh' => SMOPT_REFRESH_NONE,
159 'size' => SMOPT_SIZE_TINY
a3ec3c91 160 );
161
bbcafebd 162 $optvals[SMOPT_GRP_MESSAGE][] = array(
a3ec3c91 163 'name' => 'editor_size',
164 'caption' => _("Size of Editor Window"),
165 'type' => SMOPT_TYPE_INTEGER,
bbcafebd 166 'refresh' => SMOPT_REFRESH_NONE,
167 'size' => SMOPT_SIZE_TINY
a3ec3c91 168 );
169
bbcafebd 170 $optvals[SMOPT_GRP_MESSAGE][] = array(
a3ec3c91 171 'name' => 'location_of_buttons',
ce393174 172 'caption' => _("Location of Buttons when Composing"),
a3ec3c91 173 'type' => SMOPT_TYPE_STRLIST,
174 'refresh' => SMOPT_REFRESH_NONE,
ce393174 175 'posvals' => array(SMPREF_LOC_TOP => _("Before headers"),
176 SMPREF_LOC_BETWEEN => _("Between headers and message body"),
177 SMPREF_LOC_BOTTOM => _("After message body"))
a3ec3c91 178 );
179
07687736 180
bbcafebd 181 $optvals[SMOPT_GRP_MESSAGE][] = array(
a440e68f 182 'name' => 'use_javascript_addr_book',
183 'caption' => _("Addressbook Display Format"),
ce393174 184 'type' => SMOPT_TYPE_STRLIST,
a440e68f 185 'refresh' => SMOPT_REFRESH_NONE,
186 'posvals' => array('1' => _("Javascript"),
187 '0' => _("HTML"))
fd87494d 188 );
189
bbcafebd 190 $optvals[SMOPT_GRP_MESSAGE][] = array(
fd87494d 191 'name' => 'show_html_default',
192 'caption' => _("Show HTML Version by Default"),
193 'type' => SMOPT_TYPE_BOOLEAN,
194 'refresh' => SMOPT_REFRESH_NONE
195 );
196
bbcafebd 197 $optvals[SMOPT_GRP_MESSAGE][] = array(
fd87494d 198 'name' => 'include_self_reply_all',
bbcafebd 199 'caption' => _("Include Me in CC when I Reply All"),
fd87494d 200 'type' => SMOPT_TYPE_BOOLEAN,
201 'refresh' => SMOPT_REFRESH_NONE
202 );
203
a0bc3274 204 $optvals[SMOPT_GRP_MESSAGE][] = array(
205 'name' => 'forward_cc',
206 'caption' => _("Include CCs when forwarding messages"),
207 'type' => SMOPT_TYPE_BOOLEAN,
208 'refresh' => SMOPT_REFRESH_NONE
209 );
210
bbcafebd 211 $optvals[SMOPT_GRP_MESSAGE][] = array(
9ab0d96f 212 'name' => 'show_xmailer_default',
a440e68f 213 'caption' => _("Enable Mailer Display"),
9ab0d96f 214 'type' => SMOPT_TYPE_BOOLEAN,
215 'refresh' => SMOPT_REFRESH_NONE
216 );
217
7baf86a9 218 $optvals[SMOPT_GRP_MESSAGE][] = array(
219 'name' => 'attachment_common_show_images',
10f0ce72 220 'caption' => _("Display Attached Images with Message"),
7baf86a9 221 'type' => SMOPT_TYPE_BOOLEAN,
222 'refresh' => SMOPT_REFRESH_NONE
223 );
224
f226cba7 225 $optvals[SMOPT_GRP_MESSAGE][] = array(
226 'name' => 'pf_subtle_link',
10f0ce72 227 'caption' => _("Enable Subtle Printer Friendly Link"),
f226cba7 228 'type' => SMOPT_TYPE_BOOLEAN,
229 'refresh' => SMOPT_REFRESH_NONE
230 );
231
232 $optvals[SMOPT_GRP_MESSAGE][] = array(
233 'name' => 'pf_cleandisplay',
10f0ce72 234 'caption' => _("Enable Printer Friendly Clean Display"),
f226cba7 235 'type' => SMOPT_TYPE_BOOLEAN,
236 'refresh' => SMOPT_REFRESH_NONE
237 );
07687736 238
57257333 239 if ($default_use_mdn) {
240 $optvals[SMOPT_GRP_MESSAGE][] = array(
241 'name' => 'mdn_user_support',
242 'caption' => _("Enable request/confirm reading"),
243 'type' => SMOPT_TYPE_BOOLEAN,
244 'refresh' => SMOPT_REFRESH_NONE
245 );
246 }
07687736 247
9c3e6cd4 248 $optvals[SMOPT_GRP_MESSAGE][] = array(
249 'name' => 'compose_new_win',
250 'caption' => _("Always compose in a new window"),
251 'type' => SMOPT_TYPE_BOOLEAN,
252 'refresh' => SMOPT_REFRESH_ALL
253 );
07687736 254
255 $optvals[SMOPT_GRP_MESSAGE][] = array(
256 'name' => 'compose_width',
257 'caption' => _("Width of compose window"),
258 'type' => SMOPT_TYPE_INTEGER,
259 'refresh' => SMOPT_REFRESH_ALL,
260 'size' => SMOPT_SIZE_TINY
261 );
262
263 $optvals[SMOPT_GRP_MESSAGE][] = array(
264 'name' => 'compose_height',
265 'caption' => _("Height of compose window"),
266 'type' => SMOPT_TYPE_INTEGER,
267 'refresh' => SMOPT_REFRESH_ALL,
268 'size' => SMOPT_SIZE_TINY
269 );
270
3b17e952 271 $optvals[SMOPT_GRP_MESSAGE][] = array(
272 'name' => 'sig_first',
273 'caption' => _("Append signature before reply/forward text"),
274 'type' => SMOPT_TYPE_BOOLEAN,
275 'refresh' => SMOPT_REFRESH_NONE
276 );
07687736 277
df9fdeb9 278 $optvals[SMOPT_GRP_MESSAGE][] = array(
279 'name' => 'internal_date_sort',
280 'caption' => _("Use receive date for sort"),
281 'type' => SMOPT_TYPE_BOOLEAN,
282 'refresh' => SMOPT_REFRESH_ALL
283 );
794d59c0 284 if ($allow_thread_sort == TRUE) {
7c612fdd 285 $optvals[SMOPT_GRP_MESSAGE][] = array(
286 'name' => 'sort_by_ref',
287 'caption' => _("Use References header for thread sort"),
288 'type' => SMOPT_TYPE_BOOLEAN,
289 'refresh' => SMOPT_REFRESH_ALL
290 );
291 }
cbe5423b 292 /* Assemble all this together and return it as our result. */
293 $result = array(
294 'grps' => $optgrps,
295 'vals' => $optvals
296 );
297 return ($result);
298}
a3ec3c91 299
cbe5423b 300/******************************************************************/
301/** Define any specialized save functions for this option page. ***/
302/******************************************************************/
f1e6f580 303
cbe5423b 304function save_option_theme($option) {
305 global $theme;
e7db48af 306
cbe5423b 307 /* Do checking to make sure $new_theme is in the array. */
308 $theme_in_array = false;
309 for ($i = 0; $i < count($theme); ++$i) {
310 if ($theme[$i]['PATH'] == $option->new_value) {
311 $theme_in_array = true;
312 break;
313 }
314 }
315
316 if (!$theme_in_array) {
317 $option->new_value = '';
318 }
e7db48af 319
cbe5423b 320 /* Save the option like normal. */
321 save_option($option);
322}
e7db48af 323
cbe5423b 324function save_option_javascript_autodetect($option) {
325 global $data_dir, $username, $new_javascript_setting;
23d6bd09 326
cbe5423b 327 /* Set javascript either on or off. */
328 if ($new_javascript_setting == SMPREF_JS_AUTODETECT) {
329 if ($option->new_value == SMPREF_JS_ON) {
330 setPref($data_dir, $username, 'javascript_on', SMPREF_JS_ON);
331 } else {
332 setPref($data_dir, $username, 'javascript_on', SMPREF_JS_OFF);
333 }
334 } else {
335 setPref($data_dir, $username, 'javascript_on', $new_javascript_setting);
336 }
337}
338
339?>