c36ed9cf |
1 | <?php |
e7db48af |
2 | |
35586184 |
3 | /** |
4 | * options_display.php |
5 | * |
6c84ba1e |
6 | * Copyright (c) 1999-2005 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 |
16 | define('SMOPT_GRP_GENERAL', 0); |
17 | define('SMOPT_GRP_MAILBOX', 1); |
18 | define('SMOPT_GRP_MESSAGE', 2); |
19 | |
6395c46d |
20 | // load icon themes if in use |
21 | global $use_icons; |
22 | if ($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 |
49 | function load_optpage_data_display() { |
91e0dccc |
50 | global $theme, $language, $languages, |
ce68b76b |
51 | $default_use_mdn, $squirrelmail_language, $allow_thread_sort, |
52 | $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 | ); |
5d110fa6 |
81 | |
8f1ba72b |
82 | $css_values = array( 'none' => _("Default" ) ); |
bb7173fa |
83 | $css_dir = SM_PATH . 'themes/css'; |
84 | if (is_readable($css_dir) && is_dir($css_dir)) { |
85 | $handle=opendir($css_dir); |
4f7a5870 |
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 | } |
5d110fa6 |
93 | |
54078578 |
94 | if ( count( $css_values ) > 1 ) { |
5d110fa6 |
95 | |
e2cdae1f |
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 | ); |
5d110fa6 |
103 | |
e2cdae1f |
104 | } |
39d3ec89 |
105 | |
106 | // config.php can be unupdated. |
107 | if (! isset($available_languages) || $available_languages=="" ) { |
108 | $available_languages="ALL"; } |
5d110fa6 |
109 | |
e557fdb0 |
110 | $language_values = array(); |
39d3ec89 |
111 | if ( strtoupper($available_languages)=='ALL') { |
0bb37159 |
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 | } |
39d3ec89 |
122 | } else if (strtoupper($available_languages)!='NONE') { |
0bb37159 |
123 | // admin can set list of available languages in config |
124 | $available_languages_array=explode (" ",$available_languages); |
39d3ec89 |
125 | foreach ($available_languages_array as $lang_key ) { |
0bb37159 |
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') { |
0bb37159 |
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 | 'htmlencoded' => true |
149 | ); |
39d3ec89 |
150 | } |
ce393174 |
151 | |
a3ec3c91 |
152 | /* Set values for the "use javascript" option. */ |
bbcafebd |
153 | $optvals[SMOPT_GRP_GENERAL][] = array( |
a3ec3c91 |
154 | 'name' => 'javascript_setting', |
ce393174 |
155 | 'caption' => _("Use Javascript"), |
a3ec3c91 |
156 | 'type' => SMOPT_TYPE_STRLIST, |
157 | 'refresh' => SMOPT_REFRESH_ALL, |
158 | 'posvals' => array(SMPREF_JS_AUTODETECT => _("Autodetect"), |
159 | SMPREF_JS_ON => _("Always"), |
ae958cd3 |
160 | SMPREF_JS_OFF => _("Never")), |
161 | 'save' => 'save_option_javascript_autodetect', |
162 | 'script' => 'onclick="document.forms[0].new_js_autodetect_results.value = \'' . SMPREF_JS_ON . '\';"' |
a3ec3c91 |
163 | ); |
164 | |
bbcafebd |
165 | $optvals[SMOPT_GRP_GENERAL][] = array( |
a3ec3c91 |
166 | 'name' => 'js_autodetect_results', |
167 | 'caption' => '', |
168 | 'type' => SMOPT_TYPE_HIDDEN, |
ae958cd3 |
169 | 'refresh' => SMOPT_REFRESH_NONE |
5826affb |
170 | //'post_script' => $js_autodetect_script, |
a3ec3c91 |
171 | ); |
5bcd1b00 |
172 | |
173 | $optvals[SMOPT_GRP_GENERAL][] = array( |
174 | 'name' => 'hour_format', |
175 | 'caption' => _("Hour Format"), |
176 | 'type' => SMOPT_TYPE_STRLIST, |
177 | 'refresh' => SMOPT_REFRESH_FOLDERLIST, |
178 | 'posvals' => array(SMPREF_TIME_12HR => _("12-hour clock"), |
179 | SMPREF_TIME_24HR => _("24-hour clock")) |
180 | ); |
a3ec3c91 |
181 | |
bbcafebd |
182 | /*** Load the General Options into the array ***/ |
183 | $optgrps[SMOPT_GRP_MAILBOX] = _("Mailbox Display Options"); |
184 | $optvals[SMOPT_GRP_MAILBOX] = array(); |
185 | |
186 | $optvals[SMOPT_GRP_MAILBOX][] = array( |
a3ec3c91 |
187 | 'name' => 'show_num', |
5ed9d4fd |
188 | 'caption' => _("Number of Messages on one Page"), |
a3ec3c91 |
189 | 'type' => SMOPT_TYPE_INTEGER, |
bbcafebd |
190 | 'refresh' => SMOPT_REFRESH_NONE, |
191 | 'size' => SMOPT_SIZE_TINY |
a3ec3c91 |
192 | ); |
193 | |
bbcafebd |
194 | $optvals[SMOPT_GRP_MAILBOX][] = array( |
a440e68f |
195 | 'name' => 'alt_index_colors', |
196 | 'caption' => _("Enable Alternating Row Colors"), |
197 | 'type' => SMOPT_TYPE_BOOLEAN, |
198 | 'refresh' => SMOPT_REFRESH_NONE |
199 | ); |
200 | |
6395c46d |
201 | if ($use_icons) { |
202 | global $icon_themes, $icon_theme; |
203 | $temp = array(); |
204 | for ($count = 0; $count < sizeof($icon_themes); $count++) { |
205 | $temp[$count] = $icon_themes[$count]['NAME']; |
206 | if ($icon_theme == $icon_themes[$count]['PATH']) |
207 | $value = $count; |
208 | } |
4f7a5870 |
209 | if (sizeof($icon_themes) > 0) { |
210 | $optvals[SMOPT_GRP_MAILBOX][] = array( |
211 | 'name' => 'icon_theme', |
212 | 'caption' => _("Message Flags Icon Theme"), |
213 | 'type' => SMOPT_TYPE_STRLIST, |
214 | 'refresh' => SMOPT_REFRESH_NONE, |
215 | 'posvals' => $temp, |
216 | 'initial_value' => $value, |
217 | 'save' => 'icon_theme_save' |
218 | ); |
219 | } |
6395c46d |
220 | } |
221 | |
fd181f53 |
222 | $optvals[SMOPT_GRP_MAILBOX][] = array( |
223 | 'name' => 'show_flag_buttons', |
224 | 'caption' => _("Show Flag / Unflag Buttons"), |
225 | 'type' => SMOPT_TYPE_BOOLEAN, |
226 | 'refresh' => SMOPT_REFRESH_NONE |
227 | ); |
228 | |
bbcafebd |
229 | $optvals[SMOPT_GRP_MAILBOX][] = array( |
a440e68f |
230 | 'name' => 'page_selector', |
231 | 'caption' => _("Enable Page Selector"), |
232 | 'type' => SMOPT_TYPE_BOOLEAN, |
233 | 'refresh' => SMOPT_REFRESH_NONE |
234 | ); |
235 | |
0bb37159 |
236 | $optvals[SMOPT_GRP_MAILBOX][] = array( |
237 | 'name' => 'compact_paginator', |
238 | 'caption' => _("Use Compact Page Selector"), |
239 | 'type' => SMOPT_TYPE_BOOLEAN, |
240 | 'refresh' => SMOPT_REFRESH_NONE |
241 | ); |
242 | |
bbcafebd |
243 | $optvals[SMOPT_GRP_MAILBOX][] = array( |
a440e68f |
244 | 'name' => 'page_selector_max', |
245 | 'caption' => _("Maximum Number of Pages to Show"), |
246 | 'type' => SMOPT_TYPE_INTEGER, |
bbcafebd |
247 | 'refresh' => SMOPT_REFRESH_NONE, |
248 | 'size' => SMOPT_SIZE_TINY |
a440e68f |
249 | ); |
250 | |
3e3b60e3 |
251 | $optvals[SMOPT_GRP_MAILBOX][] = array( |
252 | 'name' => 'show_full_date', |
253 | 'caption' => _("Always Show Full Date"), |
254 | 'type' => SMOPT_TYPE_BOOLEAN, |
255 | 'refresh' => SMOPT_REFRESH_NONE |
256 | ); |
257 | |
459e3347 |
258 | $optvals[SMOPT_GRP_MAILBOX][] = array( |
259 | 'name' => 'truncate_sender', |
260 | 'caption' => _("Length of From/To Field (0 for full)"), |
261 | 'type' => SMOPT_TYPE_INTEGER, |
262 | 'refresh' => SMOPT_REFRESH_NONE, |
263 | 'size' => SMOPT_SIZE_TINY |
264 | ); |
265 | |
3fc1a95f |
266 | $optvals[SMOPT_GRP_MAILBOX][] = array( |
267 | 'name' => 'truncate_subject', |
268 | 'caption' => _("Length of Subject Field (0 for full)"), |
269 | 'type' => SMOPT_TYPE_INTEGER, |
270 | 'refresh' => SMOPT_REFRESH_NONE, |
271 | 'size' => SMOPT_SIZE_TINY |
272 | ); |
273 | |
1ae2832e |
274 | $optvals[SMOPT_GRP_MAILBOX][] = array( |
275 | 'name' => 'show_recipient_instead', |
276 | 'caption' => _("Show recipient name if the message is from your default identity"), |
277 | 'type' => SMOPT_TYPE_BOOLEAN, |
278 | 'refresh' => SMOPT_REFRESH_NONE, |
279 | 'size' => SMOPT_SIZE_TINY |
280 | ); |
5ed9d4fd |
281 | |
282 | $optvals[SMOPT_GRP_MAILBOX][] = array( |
283 | 'name' => 'internal_date_sort', |
284 | 'caption' => _("Sort by Received Date"), |
285 | 'type' => SMOPT_TYPE_BOOLEAN, |
286 | 'refresh' => SMOPT_REFRESH_ALL |
287 | ); |
288 | if ($allow_thread_sort == TRUE) { |
289 | $optvals[SMOPT_GRP_MAILBOX][] = array( |
290 | 'name' => 'sort_by_ref', |
291 | 'caption' => _("Enable Thread Sort by References Header"), |
292 | 'type' => SMOPT_TYPE_BOOLEAN, |
293 | 'refresh' => SMOPT_REFRESH_ALL |
294 | ); |
295 | } |
296 | |
1ae2832e |
297 | |
459e3347 |
298 | |
bbcafebd |
299 | /*** Load the General Options into the array ***/ |
5ed9d4fd |
300 | $optgrps[SMOPT_GRP_MESSAGE] = _("Message Display Options"); |
bbcafebd |
301 | $optvals[SMOPT_GRP_MESSAGE] = array(); |
302 | |
303 | $optvals[SMOPT_GRP_MESSAGE][] = array( |
a3ec3c91 |
304 | 'name' => 'wrap_at', |
305 | 'caption' => _("Wrap Incoming Text At"), |
306 | 'type' => SMOPT_TYPE_INTEGER, |
bbcafebd |
307 | 'refresh' => SMOPT_REFRESH_NONE, |
308 | 'size' => SMOPT_SIZE_TINY |
a3ec3c91 |
309 | ); |
310 | |
bbcafebd |
311 | $optvals[SMOPT_GRP_MESSAGE][] = array( |
fd87494d |
312 | 'name' => 'show_html_default', |
313 | 'caption' => _("Show HTML Version by Default"), |
314 | 'type' => SMOPT_TYPE_BOOLEAN, |
315 | 'refresh' => SMOPT_REFRESH_NONE |
316 | ); |
317 | |
bbcafebd |
318 | $optvals[SMOPT_GRP_MESSAGE][] = array( |
6206f6c4 |
319 | 'name' => 'enable_forward_as_attachment', |
320 | 'caption' => _("Enable Forward as Attachment"), |
fd87494d |
321 | 'type' => SMOPT_TYPE_BOOLEAN, |
322 | 'refresh' => SMOPT_REFRESH_NONE |
323 | ); |
324 | |
bbcafebd |
325 | $optvals[SMOPT_GRP_MESSAGE][] = array( |
9ab0d96f |
326 | 'name' => 'show_xmailer_default', |
a440e68f |
327 | 'caption' => _("Enable Mailer Display"), |
9ab0d96f |
328 | 'type' => SMOPT_TYPE_BOOLEAN, |
329 | 'refresh' => SMOPT_REFRESH_NONE |
330 | ); |
331 | |
7baf86a9 |
332 | $optvals[SMOPT_GRP_MESSAGE][] = array( |
333 | 'name' => 'attachment_common_show_images', |
10f0ce72 |
334 | 'caption' => _("Display Attached Images with Message"), |
7baf86a9 |
335 | 'type' => SMOPT_TYPE_BOOLEAN, |
336 | 'refresh' => SMOPT_REFRESH_NONE |
337 | ); |
338 | |
57257333 |
339 | if ($default_use_mdn) { |
340 | $optvals[SMOPT_GRP_MESSAGE][] = array( |
341 | 'name' => 'mdn_user_support', |
6206f6c4 |
342 | 'caption' => _("Enable Mail Delivery Notification"), |
57257333 |
343 | 'type' => SMOPT_TYPE_BOOLEAN, |
344 | 'refresh' => SMOPT_REFRESH_NONE |
345 | ); |
346 | } |
07687736 |
347 | |
4267d5de |
348 | $optvals[SMOPT_GRP_MESSAGE][] = array( |
349 | 'name' => 'delete_prev_next_display', |
350 | 'caption' => _("Show 'Delete & Prev/Next' Links"), |
351 | 'type' => SMOPT_TYPE_BOOLEAN, |
352 | 'refresh' => SMOPT_REFRESH_ALL |
353 | ); |
5d110fa6 |
354 | |
cbe5423b |
355 | /* Assemble all this together and return it as our result. */ |
356 | $result = array( |
357 | 'grps' => $optgrps, |
ae958cd3 |
358 | 'vals' => $optvals |
cbe5423b |
359 | ); |
360 | return ($result); |
361 | } |
a3ec3c91 |
362 | |
cbe5423b |
363 | /******************************************************************/ |
364 | /** Define any specialized save functions for this option page. ***/ |
365 | /******************************************************************/ |
f1e6f580 |
366 | |
48af4b64 |
367 | /** |
368 | * This function saves a new theme setting. |
369 | * It updates the theme array. |
370 | */ |
cbe5423b |
371 | function save_option_theme($option) { |
372 | global $theme; |
bb7173fa |
373 | |
cbe5423b |
374 | /* Do checking to make sure $new_theme is in the array. */ |
375 | $theme_in_array = false; |
376 | for ($i = 0; $i < count($theme); ++$i) { |
377 | if ($theme[$i]['PATH'] == $option->new_value) { |
378 | $theme_in_array = true; |
379 | break; |
380 | } |
381 | } |
382 | |
383 | if (!$theme_in_array) { |
384 | $option->new_value = ''; |
385 | } |
e7db48af |
386 | |
cbe5423b |
387 | /* Save the option like normal. */ |
388 | save_option($option); |
389 | } |
e7db48af |
390 | |
48af4b64 |
391 | /** |
392 | * This function saves the javascript detection option. |
393 | */ |
cbe5423b |
394 | function save_option_javascript_autodetect($option) { |
ae958cd3 |
395 | save_option($option); |
396 | checkForJavascript(TRUE); |
cbe5423b |
397 | } |
398 | |
5d110fa6 |
399 | /** |
6395c46d |
400 | * This function saves the user's icon theme setting |
401 | */ |
402 | function icon_theme_save($option) { |
403 | |
404 | global $icon_themes, $data_dir, $username; |
405 | |
406 | |
5d110fa6 |
407 | // Don't assume the new value is there, double check |
408 | // and only save if found |
6395c46d |
409 | // |
410 | if (isset($icon_themes[$option->new_value]['PATH'])) |
411 | setPref($data_dir, $username, 'icon_theme', $icon_themes[$option->new_value]['PATH']); |
412 | else |
413 | setPref($data_dir, $username, 'icon_theme', 'none'); |
414 | |
415 | } |
416 | |
240f05f5 |
417 | ?> |