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