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