17e14fc32482bfec95ab3f15918574832beaba08
6 * Copyright (c) 1999-2003 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
9 * Displays all optinos about display preferences
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);
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,
25 /* Build a simple array into which we will build options. */
29 /******************************************************/
30 /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */
31 /******************************************************/
33 /*** Load the General Options into the array ***/
34 $optgrps[SMOPT_GRP_GENERAL
] = _("General Display Options");
35 $optvals[SMOPT_GRP_GENERAL
] = array();
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'];
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'
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 );
62 if ( count( $css_values ) > 1 ) {
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
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'];
80 asort($language_values);
82 array_merge(array('' => _("Default")), $language_values);
83 $language = $squirrelmail_language;
84 $optvals[SMOPT_GRP_GENERAL
][] = array(
86 'caption' => _("Language"),
87 'type' => SMOPT_TYPE_STRLIST
,
88 'refresh' => SMOPT_REFRESH_ALL
,
89 'posvals' => $language_values
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"))
104 if ($optmode != 'submit')
105 $onLoadScript = 'document.forms[0].new_js_autodetect_results.value = \'' . SMPREF_JS_ON
. '\'';
109 $optvals[SMOPT_GRP_GENERAL
][] = array(
110 'name' => 'js_autodetect_results',
112 'type' => SMOPT_TYPE_HIDDEN
,
113 'refresh' => SMOPT_REFRESH_NONE
,
114 //'post_script' => $js_autodetect_script,
115 'save' => 'save_option_javascript_autodetect'
118 /*** Load the General Options into the array ***/
119 $optgrps[SMOPT_GRP_MAILBOX
] = _("Mailbox Display Options");
120 $optvals[SMOPT_GRP_MAILBOX
] = array();
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
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
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
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
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
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
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
175 $optvals[SMOPT_GRP_MAILBOX
][] = array(
176 'name' => 'show_recipient_instead',
177 'caption' => _("Show recipient name if the message is from your default identity"),
178 'type' => SMOPT_TYPE_BOOLEAN
,
179 'refresh' => SMOPT_REFRESH_NONE
,
180 'size' => SMOPT_SIZE_TINY
184 /*** Load the General Options into the array ***/
185 $optgrps[SMOPT_GRP_MESSAGE
] = _("Message Display and Composition");
186 $optvals[SMOPT_GRP_MESSAGE
] = array();
188 $optvals[SMOPT_GRP_MESSAGE
][] = array(
190 'caption' => _("Wrap Incoming Text At"),
191 'type' => SMOPT_TYPE_INTEGER
,
192 'refresh' => SMOPT_REFRESH_NONE
,
193 'size' => SMOPT_SIZE_TINY
196 $optvals[SMOPT_GRP_MESSAGE
][] = array(
197 'name' => 'editor_size',
198 'caption' => _("Size of Editor Window"),
199 'type' => SMOPT_TYPE_INTEGER
,
200 'refresh' => SMOPT_REFRESH_NONE
,
201 'size' => SMOPT_SIZE_TINY
204 $optvals[SMOPT_GRP_MESSAGE
][] = array(
205 'name' => 'location_of_buttons',
206 'caption' => _("Location of Buttons when Composing"),
207 'type' => SMOPT_TYPE_STRLIST
,
208 'refresh' => SMOPT_REFRESH_NONE
,
209 'posvals' => array(SMPREF_LOC_TOP
=> _("Before headers"),
210 SMPREF_LOC_BETWEEN
=> _("Between headers and message body"),
211 SMPREF_LOC_BOTTOM
=> _("After message body"))
215 $optvals[SMOPT_GRP_MESSAGE
][] = array(
216 'name' => 'use_javascript_addr_book',
217 'caption' => _("Addressbook Display Format"),
218 'type' => SMOPT_TYPE_STRLIST
,
219 'refresh' => SMOPT_REFRESH_NONE
,
220 'posvals' => array('1' => _("Javascript"),
224 $optvals[SMOPT_GRP_MESSAGE
][] = array(
225 'name' => 'show_html_default',
226 'caption' => _("Show HTML Version by Default"),
227 'type' => SMOPT_TYPE_BOOLEAN
,
228 'refresh' => SMOPT_REFRESH_NONE
231 $optvals[SMOPT_GRP_MESSAGE
][] = array(
232 'name' => 'enable_forward_as_attachment',
233 'caption' => _("Enable Forward as Attachment"),
234 'type' => SMOPT_TYPE_BOOLEAN
,
235 'refresh' => SMOPT_REFRESH_NONE
238 $optvals[SMOPT_GRP_MESSAGE
][] = array(
239 'name' => 'forward_cc',
240 'caption' => _("Include CCs when Forwarding Messages"),
241 'type' => SMOPT_TYPE_BOOLEAN
,
242 'refresh' => SMOPT_REFRESH_NONE
245 $optvals[SMOPT_GRP_MESSAGE
][] = array(
246 'name' => 'include_self_reply_all',
247 'caption' => _("Include Me in CC when I Reply All"),
248 'type' => SMOPT_TYPE_BOOLEAN
,
249 'refresh' => SMOPT_REFRESH_NONE
252 $optvals[SMOPT_GRP_MESSAGE
][] = array(
253 'name' => 'show_xmailer_default',
254 'caption' => _("Enable Mailer Display"),
255 'type' => SMOPT_TYPE_BOOLEAN
,
256 'refresh' => SMOPT_REFRESH_NONE
259 $optvals[SMOPT_GRP_MESSAGE
][] = array(
260 'name' => 'attachment_common_show_images',
261 'caption' => _("Display Attached Images with Message"),
262 'type' => SMOPT_TYPE_BOOLEAN
,
263 'refresh' => SMOPT_REFRESH_NONE
266 $optvals[SMOPT_GRP_MESSAGE
][] = array(
267 'name' => 'pf_cleandisplay',
268 'caption' => _("Enable Printer Friendly Clean Display"),
269 'type' => SMOPT_TYPE_BOOLEAN
,
270 'refresh' => SMOPT_REFRESH_NONE
273 if ($default_use_mdn) {
274 $optvals[SMOPT_GRP_MESSAGE
][] = array(
275 'name' => 'mdn_user_support',
276 'caption' => _("Enable Mail Delivery Notification"),
277 'type' => SMOPT_TYPE_BOOLEAN
,
278 'refresh' => SMOPT_REFRESH_NONE
282 $optvals[SMOPT_GRP_MESSAGE
][] = array(
283 'name' => 'compose_new_win',
284 'caption' => _("Compose Messages in New Window"),
285 'type' => SMOPT_TYPE_BOOLEAN
,
286 'refresh' => SMOPT_REFRESH_ALL
289 $optvals[SMOPT_GRP_MESSAGE
][] = array(
290 'name' => 'compose_width',
291 'caption' => _("Width of Compose Window"),
292 'type' => SMOPT_TYPE_INTEGER
,
293 'refresh' => SMOPT_REFRESH_ALL
,
294 'size' => SMOPT_SIZE_TINY
297 $optvals[SMOPT_GRP_MESSAGE
][] = array(
298 'name' => 'compose_height',
299 'caption' => _("Height of Compose Window"),
300 'type' => SMOPT_TYPE_INTEGER
,
301 'refresh' => SMOPT_REFRESH_ALL
,
302 'size' => SMOPT_SIZE_TINY
305 $optvals[SMOPT_GRP_MESSAGE
][] = array(
306 'name' => 'sig_first',
307 'caption' => _("Append Signature before Reply/Forward Text"),
308 'type' => SMOPT_TYPE_BOOLEAN
,
309 'refresh' => SMOPT_REFRESH_NONE
312 $optvals[SMOPT_GRP_MESSAGE
][] = array(
313 'name' => 'reply_focus',
314 'caption' => _("Cursor Position when Replying"),
315 'type' => SMOPT_TYPE_STRLIST
,
316 'refresh' => SMOPT_REFRESH_NONE
,
317 'posvals' => array('' => _("To: field"),
318 'focus' => _("Focus in body"),
319 'select' => _("Select body"))
322 $optvals[SMOPT_GRP_MESSAGE
][] = array(
323 'name' => 'strip_sigs',
324 'caption' => _("Strip signature when replying"),
325 'type' => SMOPT_TYPE_BOOLEAN
,
326 'refresh' => SMOPT_REFRESH_NONE
329 $optvals[SMOPT_GRP_MESSAGE
][] = array(
330 'name' => 'internal_date_sort',
331 'caption' => _("Enable Sort by of Receive Date"),
332 'type' => SMOPT_TYPE_BOOLEAN
,
333 'refresh' => SMOPT_REFRESH_ALL
335 if ($allow_thread_sort == TRUE) {
336 $optvals[SMOPT_GRP_MESSAGE
][] = array(
337 'name' => 'sort_by_ref',
338 'caption' => _("Enable Thread Sort by References Header"),
339 'type' => SMOPT_TYPE_BOOLEAN
,
340 'refresh' => SMOPT_REFRESH_ALL
343 /* Assemble all this together and return it as our result. */
347 'xtra' => $onLoadScript
352 /******************************************************************/
353 /** Define any specialized save functions for this option page. ***/
354 /******************************************************************/
356 function save_option_theme($option) {
359 /* Do checking to make sure $new_theme is in the array. */
360 $theme_in_array = false;
361 for ($i = 0; $i < count($theme); ++
$i) {
362 if ($theme[$i]['PATH'] == $option->new_value
) {
363 $theme_in_array = true;
368 if (!$theme_in_array) {
369 $option->new_value
= '';
372 /* Save the option like normal. */
373 save_option($option);
376 function save_option_javascript_autodetect($option) {
377 global $data_dir, $username, $new_javascript_setting;
379 /* Set javascript either on or off. */
380 if ($new_javascript_setting == SMPREF_JS_AUTODETECT
) {
381 if ($option->new_value
== SMPREF_JS_ON
) {
382 setPref($data_dir, $username, 'javascript_on', SMPREF_JS_ON
);
384 setPref($data_dir, $username, 'javascript_on', SMPREF_JS_OFF
);
387 setPref($data_dir, $username, 'javascript_on', $new_javascript_setting);