fix for personal names with "," inside it. This will fix wrong address
[squirrelmail.git] / include / options / display.php
1 <?php
2
3 /**
4 * options_display.php
5 *
6 * Copyright (c) 1999-2003 The SquirrelMail Project Team
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 */
13
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);
18
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;
24
25 /* Build a simple array into which we will build options. */
26 $optgrps = array();
27 $optvals = array();
28
29 /******************************************************/
30 /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */
31 /******************************************************/
32
33 /*** Load the General Options into the array ***/
34 $optgrps[SMOPT_GRP_GENERAL] = _("General Display Options");
35 $optvals[SMOPT_GRP_GENERAL] = array();
36
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'];
41 }
42 ksort($theme_values);
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'
51 );
52
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 );
58 }
59 }
60 closedir($handle);
61
62 if ( count( $css_values ) > 1 ) {
63
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
70 );
71
72 }
73
74 $language_values = array();
75 foreach ($languages as $lang_key => $lang_attributes) {
76 if (isset($lang_attributes['NAME'])) {
77 $language_values[$lang_key] = $lang_attributes['NAME'];
78 }
79 }
80 asort($language_values);
81 $language_values =
82 array_merge(array('' => _("Default")), $language_values);
83 $language = $squirrelmail_language;
84 $optvals[SMOPT_GRP_GENERAL][] = array(
85 'name' => 'language',
86 'caption' => _("Language"),
87 'type' => SMOPT_TYPE_STRLIST,
88 'refresh' => SMOPT_REFRESH_ALL,
89 'posvals' => $language_values
90 );
91
92 /* Set values for the "use javascript" option. */
93 $optvals[SMOPT_GRP_GENERAL][] = array(
94 'name' => 'javascript_setting',
95 'caption' => _("Use Javascript"),
96 'type' => SMOPT_TYPE_STRLIST,
97 'refresh' => SMOPT_REFRESH_ALL,
98 'posvals' => array(SMPREF_JS_AUTODETECT => _("Autodetect"),
99 SMPREF_JS_ON => _("Always"),
100 SMPREF_JS_OFF => _("Never"))
101 );
102
103
104 if ($optmode != 'submit')
105 $onLoadScript = 'document.forms[0].new_js_autodetect_results.value = \'' . SMPREF_JS_ON . '\'';
106 else
107 $onLoadScript = '';
108
109 $optvals[SMOPT_GRP_GENERAL][] = array(
110 'name' => 'js_autodetect_results',
111 'caption' => '',
112 'type' => SMOPT_TYPE_HIDDEN,
113 'refresh' => SMOPT_REFRESH_NONE,
114 //'post_script' => $js_autodetect_script,
115 'save' => 'save_option_javascript_autodetect'
116 );
117
118 /*** Load the General Options into the array ***/
119 $optgrps[SMOPT_GRP_MAILBOX] = _("Mailbox Display Options");
120 $optvals[SMOPT_GRP_MAILBOX] = array();
121
122 $optvals[SMOPT_GRP_MAILBOX][] = array(
123 'name' => 'show_num',
124 'caption' => _("Number of Messages to Index"),
125 'type' => SMOPT_TYPE_INTEGER,
126 'refresh' => SMOPT_REFRESH_NONE,
127 'size' => SMOPT_SIZE_TINY
128 );
129
130 $optvals[SMOPT_GRP_MAILBOX][] = array(
131 'name' => 'alt_index_colors',
132 'caption' => _("Enable Alternating Row Colors"),
133 'type' => SMOPT_TYPE_BOOLEAN,
134 'refresh' => SMOPT_REFRESH_NONE
135 );
136
137 $optvals[SMOPT_GRP_MAILBOX][] = array(
138 'name' => 'page_selector',
139 'caption' => _("Enable Page Selector"),
140 'type' => SMOPT_TYPE_BOOLEAN,
141 'refresh' => SMOPT_REFRESH_NONE
142 );
143
144 $optvals[SMOPT_GRP_MAILBOX][] = array(
145 'name' => 'page_selector_max',
146 'caption' => _("Maximum Number of Pages to Show"),
147 'type' => SMOPT_TYPE_INTEGER,
148 'refresh' => SMOPT_REFRESH_NONE,
149 'size' => SMOPT_SIZE_TINY
150 );
151
152 $optvals[SMOPT_GRP_MAILBOX][] = array(
153 'name' => 'show_full_date',
154 'caption' => _("Always Show Full Date"),
155 'type' => SMOPT_TYPE_BOOLEAN,
156 'refresh' => SMOPT_REFRESH_NONE
157 );
158
159 $optvals[SMOPT_GRP_MAILBOX][] = array(
160 'name' => 'truncate_sender',
161 'caption' => _("Length of From/To Field (0 for full)"),
162 'type' => SMOPT_TYPE_INTEGER,
163 'refresh' => SMOPT_REFRESH_NONE,
164 'size' => SMOPT_SIZE_TINY
165 );
166
167 $optvals[SMOPT_GRP_MAILBOX][] = array(
168 'name' => 'truncate_subject',
169 'caption' => _("Length of Subject Field (0 for full)"),
170 'type' => SMOPT_TYPE_INTEGER,
171 'refresh' => SMOPT_REFRESH_NONE,
172 'size' => SMOPT_SIZE_TINY
173 );
174
175
176 /*** Load the General Options into the array ***/
177 $optgrps[SMOPT_GRP_MESSAGE] = _("Message Display and Composition");
178 $optvals[SMOPT_GRP_MESSAGE] = array();
179
180 $optvals[SMOPT_GRP_MESSAGE][] = array(
181 'name' => 'wrap_at',
182 'caption' => _("Wrap Incoming Text At"),
183 'type' => SMOPT_TYPE_INTEGER,
184 'refresh' => SMOPT_REFRESH_NONE,
185 'size' => SMOPT_SIZE_TINY
186 );
187
188 $optvals[SMOPT_GRP_MESSAGE][] = array(
189 'name' => 'editor_size',
190 'caption' => _("Size of Editor Window"),
191 'type' => SMOPT_TYPE_INTEGER,
192 'refresh' => SMOPT_REFRESH_NONE,
193 'size' => SMOPT_SIZE_TINY
194 );
195
196 $optvals[SMOPT_GRP_MESSAGE][] = array(
197 'name' => 'location_of_buttons',
198 'caption' => _("Location of Buttons when Composing"),
199 'type' => SMOPT_TYPE_STRLIST,
200 'refresh' => SMOPT_REFRESH_NONE,
201 'posvals' => array(SMPREF_LOC_TOP => _("Before headers"),
202 SMPREF_LOC_BETWEEN => _("Between headers and message body"),
203 SMPREF_LOC_BOTTOM => _("After message body"))
204 );
205
206
207 $optvals[SMOPT_GRP_MESSAGE][] = array(
208 'name' => 'use_javascript_addr_book',
209 'caption' => _("Addressbook Display Format"),
210 'type' => SMOPT_TYPE_STRLIST,
211 'refresh' => SMOPT_REFRESH_NONE,
212 'posvals' => array('1' => _("Javascript"),
213 '0' => _("HTML"))
214 );
215
216 $optvals[SMOPT_GRP_MESSAGE][] = array(
217 'name' => 'show_html_default',
218 'caption' => _("Show HTML Version by Default"),
219 'type' => SMOPT_TYPE_BOOLEAN,
220 'refresh' => SMOPT_REFRESH_NONE
221 );
222
223 $optvals[SMOPT_GRP_MESSAGE][] = array(
224 'name' => 'enable_forward_as_attachment',
225 'caption' => _("Enable Forward as Attachment"),
226 'type' => SMOPT_TYPE_BOOLEAN,
227 'refresh' => SMOPT_REFRESH_NONE
228 );
229
230 $optvals[SMOPT_GRP_MESSAGE][] = array(
231 'name' => 'forward_cc',
232 'caption' => _("Include CCs when Forwarding Messages"),
233 'type' => SMOPT_TYPE_BOOLEAN,
234 'refresh' => SMOPT_REFRESH_NONE
235 );
236
237 $optvals[SMOPT_GRP_MESSAGE][] = array(
238 'name' => 'include_self_reply_all',
239 'caption' => _("Include Me in CC when I Reply All"),
240 'type' => SMOPT_TYPE_BOOLEAN,
241 'refresh' => SMOPT_REFRESH_NONE
242 );
243
244 $optvals[SMOPT_GRP_MESSAGE][] = array(
245 'name' => 'show_xmailer_default',
246 'caption' => _("Enable Mailer Display"),
247 'type' => SMOPT_TYPE_BOOLEAN,
248 'refresh' => SMOPT_REFRESH_NONE
249 );
250
251 $optvals[SMOPT_GRP_MESSAGE][] = array(
252 'name' => 'attachment_common_show_images',
253 'caption' => _("Display Attached Images with Message"),
254 'type' => SMOPT_TYPE_BOOLEAN,
255 'refresh' => SMOPT_REFRESH_NONE
256 );
257
258 $optvals[SMOPT_GRP_MESSAGE][] = array(
259 'name' => 'pf_cleandisplay',
260 'caption' => _("Enable Printer Friendly Clean Display"),
261 'type' => SMOPT_TYPE_BOOLEAN,
262 'refresh' => SMOPT_REFRESH_NONE
263 );
264
265 if ($default_use_mdn) {
266 $optvals[SMOPT_GRP_MESSAGE][] = array(
267 'name' => 'mdn_user_support',
268 'caption' => _("Enable Mail Delivery Notification"),
269 'type' => SMOPT_TYPE_BOOLEAN,
270 'refresh' => SMOPT_REFRESH_NONE
271 );
272 }
273
274 $optvals[SMOPT_GRP_MESSAGE][] = array(
275 'name' => 'compose_new_win',
276 'caption' => _("Compose Messages in New Window"),
277 'type' => SMOPT_TYPE_BOOLEAN,
278 'refresh' => SMOPT_REFRESH_ALL
279 );
280
281 $optvals[SMOPT_GRP_MESSAGE][] = array(
282 'name' => 'compose_width',
283 'caption' => _("Width of Compose Window"),
284 'type' => SMOPT_TYPE_INTEGER,
285 'refresh' => SMOPT_REFRESH_ALL,
286 'size' => SMOPT_SIZE_TINY
287 );
288
289 $optvals[SMOPT_GRP_MESSAGE][] = array(
290 'name' => 'compose_height',
291 'caption' => _("Height of Compose Window"),
292 'type' => SMOPT_TYPE_INTEGER,
293 'refresh' => SMOPT_REFRESH_ALL,
294 'size' => SMOPT_SIZE_TINY
295 );
296
297 $optvals[SMOPT_GRP_MESSAGE][] = array(
298 'name' => 'sig_first',
299 'caption' => _("Append Signature before Reply/Forward Text"),
300 'type' => SMOPT_TYPE_BOOLEAN,
301 'refresh' => SMOPT_REFRESH_NONE
302 );
303
304 $optvals[SMOPT_GRP_MESSAGE][] = array(
305 'name' => 'strip_sigs',
306 'caption' => _("Strip signature when replying"),
307 'type' => SMOPT_TYPE_BOOLEAN,
308 'refresh' => SMOPT_REFRESH_NONE
309 );
310
311 $optvals[SMOPT_GRP_MESSAGE][] = array(
312 'name' => 'internal_date_sort',
313 'caption' => _("Enable Sort by of Receive Date"),
314 'type' => SMOPT_TYPE_BOOLEAN,
315 'refresh' => SMOPT_REFRESH_ALL
316 );
317 if ($allow_thread_sort == TRUE) {
318 $optvals[SMOPT_GRP_MESSAGE][] = array(
319 'name' => 'sort_by_ref',
320 'caption' => _("Enable Thread Sort by References Header"),
321 'type' => SMOPT_TYPE_BOOLEAN,
322 'refresh' => SMOPT_REFRESH_ALL
323 );
324 }
325 /* Assemble all this together and return it as our result. */
326 $result = array(
327 'grps' => $optgrps,
328 'vals' => $optvals,
329 'xtra' => $onLoadScript
330 );
331 return ($result);
332 }
333
334 /******************************************************************/
335 /** Define any specialized save functions for this option page. ***/
336 /******************************************************************/
337
338 function save_option_theme($option) {
339 global $theme;
340
341 /* Do checking to make sure $new_theme is in the array. */
342 $theme_in_array = false;
343 for ($i = 0; $i < count($theme); ++$i) {
344 if ($theme[$i]['PATH'] == $option->new_value) {
345 $theme_in_array = true;
346 break;
347 }
348 }
349
350 if (!$theme_in_array) {
351 $option->new_value = '';
352 }
353
354 /* Save the option like normal. */
355 save_option($option);
356 }
357
358 function save_option_javascript_autodetect($option) {
359 global $data_dir, $username, $new_javascript_setting;
360
361 /* Set javascript either on or off. */
362 if ($new_javascript_setting == SMPREF_JS_AUTODETECT) {
363 if ($option->new_value == SMPREF_JS_ON) {
364 setPref($data_dir, $username, 'javascript_on', SMPREF_JS_ON);
365 } else {
366 setPref($data_dir, $username, 'javascript_on', SMPREF_JS_OFF);
367 }
368 } else {
369 setPref($data_dir, $username, 'javascript_on', $new_javascript_setting);
370 }
371 }
372
373 ?>