c36ed9cf |
1 | <?php |
e7db48af |
2 | |
895905c0 |
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 | */ |
cbe5423b |
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; |
a3ec3c91 |
22 | |
ce393174 |
23 | /* Build a simple array into which we will build options. */ |
bbcafebd |
24 | $optgrps = array(); |
25 | $optvals = array(); |
a3ec3c91 |
26 | |
bbcafebd |
27 | /******************************************************/ |
28 | /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */ |
29 | /******************************************************/ |
bbcafebd |
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. */ |
ce393174 |
36 | $theme_values = array(); |
37 | foreach ($theme as $theme_key => $theme_attributes) { |
38 | $theme_values[$theme_attributes['PATH']] = $theme_attributes['NAME']; |
39 | } |
bbcafebd |
40 | $optvals[SMOPT_GRP_GENERAL][] = array( |
ce393174 |
41 | 'name' => 'chosen_theme', |
42 | 'caption' => _("Theme"), |
43 | 'type' => SMOPT_TYPE_STRLIST, |
44 | 'refresh' => SMOPT_REFRESH_ALL, |
cbe5423b |
45 | 'posvals' => $theme_values, |
46 | 'save' => 'save_option_theme' |
ce393174 |
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 | } |
bbcafebd |
55 | $optvals[SMOPT_GRP_GENERAL][] = array( |
ce393174 |
56 | 'name' => 'language', |
57 | 'caption' => _("Language"), |
58 | 'type' => SMOPT_TYPE_STRLIST, |
59 | 'refresh' => SMOPT_REFRESH_ALL, |
60 | 'posvals' => $language_values |
61 | ); |
62 | |
a3ec3c91 |
63 | /* Set values for the "use javascript" option. */ |
bbcafebd |
64 | $optvals[SMOPT_GRP_GENERAL][] = array( |
a3ec3c91 |
65 | 'name' => 'javascript_setting', |
ce393174 |
66 | 'caption' => _("Use Javascript"), |
a3ec3c91 |
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 | |
cbe5423b |
74 | $js_autodetect_script = " |
75 | <SCRIPT LANGUAGE=\"JavaScript\"><!-- |
76 | document.forms[0].new_js_autodetect_results.value = '" . SMPREF_JS_ON . "'; |
77 | // --></SCRIPT> |
78 | "; |
a3ec3c91 |
79 | $js_autodetect_results = SMPREF_JS_OFF; |
bbcafebd |
80 | $optvals[SMOPT_GRP_GENERAL][] = array( |
a3ec3c91 |
81 | 'name' => 'js_autodetect_results', |
82 | 'caption' => '', |
83 | 'type' => SMOPT_TYPE_HIDDEN, |
cbe5423b |
84 | 'refresh' => SMOPT_REFRESH_NONE, |
85 | 'script' => $js_autodetect_script, |
86 | 'save' => 'save_option_javascript_autodetect' |
a3ec3c91 |
87 | ); |
88 | |
bbcafebd |
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( |
a3ec3c91 |
94 | 'name' => 'show_num', |
95 | 'caption' => _("Number of Messages to Index"), |
96 | 'type' => SMOPT_TYPE_INTEGER, |
bbcafebd |
97 | 'refresh' => SMOPT_REFRESH_NONE, |
98 | 'size' => SMOPT_SIZE_TINY |
a3ec3c91 |
99 | ); |
100 | |
bbcafebd |
101 | $optvals[SMOPT_GRP_MAILBOX][] = array( |
a440e68f |
102 | 'name' => 'alt_index_colors', |
103 | 'caption' => _("Enable Alternating Row Colors"), |
104 | 'type' => SMOPT_TYPE_BOOLEAN, |
105 | 'refresh' => SMOPT_REFRESH_NONE |
106 | ); |
107 | |
bbcafebd |
108 | $optvals[SMOPT_GRP_MAILBOX][] = array( |
a440e68f |
109 | 'name' => 'page_selector', |
110 | 'caption' => _("Enable Page Selector"), |
111 | 'type' => SMOPT_TYPE_BOOLEAN, |
112 | 'refresh' => SMOPT_REFRESH_NONE |
113 | ); |
114 | |
bbcafebd |
115 | $optvals[SMOPT_GRP_MAILBOX][] = array( |
a440e68f |
116 | 'name' => 'page_selector_max', |
117 | 'caption' => _("Maximum Number of Pages to Show"), |
118 | 'type' => SMOPT_TYPE_INTEGER, |
bbcafebd |
119 | 'refresh' => SMOPT_REFRESH_NONE, |
120 | 'size' => SMOPT_SIZE_TINY |
a440e68f |
121 | ); |
122 | |
bbcafebd |
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( |
a3ec3c91 |
128 | 'name' => 'wrap_at', |
129 | 'caption' => _("Wrap Incoming Text At"), |
130 | 'type' => SMOPT_TYPE_INTEGER, |
bbcafebd |
131 | 'refresh' => SMOPT_REFRESH_NONE, |
132 | 'size' => SMOPT_SIZE_TINY |
a3ec3c91 |
133 | ); |
134 | |
bbcafebd |
135 | $optvals[SMOPT_GRP_MESSAGE][] = array( |
a3ec3c91 |
136 | 'name' => 'editor_size', |
137 | 'caption' => _("Size of Editor Window"), |
138 | 'type' => SMOPT_TYPE_INTEGER, |
bbcafebd |
139 | 'refresh' => SMOPT_REFRESH_NONE, |
140 | 'size' => SMOPT_SIZE_TINY |
a3ec3c91 |
141 | ); |
142 | |
bbcafebd |
143 | $optvals[SMOPT_GRP_MESSAGE][] = array( |
a3ec3c91 |
144 | 'name' => 'location_of_buttons', |
ce393174 |
145 | 'caption' => _("Location of Buttons when Composing"), |
a3ec3c91 |
146 | 'type' => SMOPT_TYPE_STRLIST, |
147 | 'refresh' => SMOPT_REFRESH_NONE, |
ce393174 |
148 | 'posvals' => array(SMPREF_LOC_TOP => _("Before headers"), |
149 | SMPREF_LOC_BETWEEN => _("Between headers and message body"), |
150 | SMPREF_LOC_BOTTOM => _("After message body")) |
a3ec3c91 |
151 | ); |
152 | |
bbcafebd |
153 | $optvals[SMOPT_GRP_MESSAGE][] = array( |
a440e68f |
154 | 'name' => 'use_javascript_addr_book', |
155 | 'caption' => _("Addressbook Display Format"), |
ce393174 |
156 | 'type' => SMOPT_TYPE_STRLIST, |
a440e68f |
157 | 'refresh' => SMOPT_REFRESH_NONE, |
158 | 'posvals' => array('1' => _("Javascript"), |
159 | '0' => _("HTML")) |
fd87494d |
160 | ); |
161 | |
bbcafebd |
162 | $optvals[SMOPT_GRP_MESSAGE][] = array( |
fd87494d |
163 | 'name' => 'show_html_default', |
164 | 'caption' => _("Show HTML Version by Default"), |
165 | 'type' => SMOPT_TYPE_BOOLEAN, |
166 | 'refresh' => SMOPT_REFRESH_NONE |
167 | ); |
168 | |
bbcafebd |
169 | $optvals[SMOPT_GRP_MESSAGE][] = array( |
fd87494d |
170 | 'name' => 'include_self_reply_all', |
bbcafebd |
171 | 'caption' => _("Include Me in CC when I Reply All"), |
fd87494d |
172 | 'type' => SMOPT_TYPE_BOOLEAN, |
173 | 'refresh' => SMOPT_REFRESH_NONE |
174 | ); |
175 | |
bbcafebd |
176 | $optvals[SMOPT_GRP_MESSAGE][] = array( |
9ab0d96f |
177 | 'name' => 'show_xmailer_default', |
a440e68f |
178 | 'caption' => _("Enable Mailer Display"), |
9ab0d96f |
179 | 'type' => SMOPT_TYPE_BOOLEAN, |
180 | 'refresh' => SMOPT_REFRESH_NONE |
181 | ); |
182 | |
7baf86a9 |
183 | $optvals[SMOPT_GRP_MESSAGE][] = array( |
184 | 'name' => 'attachment_common_show_images', |
10f0ce72 |
185 | 'caption' => _("Display Attached Images with Message"), |
7baf86a9 |
186 | 'type' => SMOPT_TYPE_BOOLEAN, |
187 | 'refresh' => SMOPT_REFRESH_NONE |
188 | ); |
189 | |
f226cba7 |
190 | $optvals[SMOPT_GRP_MESSAGE][] = array( |
191 | 'name' => 'pf_subtle_link', |
10f0ce72 |
192 | 'caption' => _("Enable Subtle Printer Friendly Link"), |
f226cba7 |
193 | 'type' => SMOPT_TYPE_BOOLEAN, |
194 | 'refresh' => SMOPT_REFRESH_NONE |
195 | ); |
196 | |
197 | $optvals[SMOPT_GRP_MESSAGE][] = array( |
198 | 'name' => 'pf_cleandisplay', |
10f0ce72 |
199 | 'caption' => _("Enable Printer Friendly Clean Display"), |
f226cba7 |
200 | 'type' => SMOPT_TYPE_BOOLEAN, |
201 | 'refresh' => SMOPT_REFRESH_NONE |
202 | ); |
203 | |
cbe5423b |
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 | } |
a3ec3c91 |
211 | |
cbe5423b |
212 | /******************************************************************/ |
213 | /** Define any specialized save functions for this option page. ***/ |
214 | /******************************************************************/ |
f1e6f580 |
215 | |
cbe5423b |
216 | function save_option_theme($option) { |
217 | global $theme; |
e7db48af |
218 | |
cbe5423b |
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 | } |
e7db48af |
231 | |
cbe5423b |
232 | /* Save the option like normal. */ |
233 | save_option($option); |
234 | } |
e7db48af |
235 | |
cbe5423b |
236 | function save_option_javascript_autodetect($option) { |
237 | global $data_dir, $username, $new_javascript_setting; |
23d6bd09 |
238 | |
cbe5423b |
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 | ?> |