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