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