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