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