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