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