Forgot that one
[squirrelmail.git] / src / options_display.php
CommitLineData
c36ed9cf 1<?php
e7db48af 2
35586184 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. */
15define('SMOPT_GRP_GENERAL', 0);
16define('SMOPT_GRP_MAILBOX', 1);
17define('SMOPT_GRP_MESSAGE', 2);
18
19/* Define the optpage load function for the display options page. */
20function 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) {
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
0bc94135 51 $language_values = array('');
ce393174 52 foreach ($languages as $lang_key => $lang_attributes) {
53 if (isset($lang_attributes['NAME'])) {
54 $language_values[$lang_key] = $lang_attributes['NAME'];
55 }
56 }
bbcafebd 57 $optvals[SMOPT_GRP_GENERAL][] = array(
ce393174 58 'name' => 'language',
59 'caption' => _("Language"),
60 'type' => SMOPT_TYPE_STRLIST,
61 'refresh' => SMOPT_REFRESH_ALL,
62 'posvals' => $language_values
63 );
64
a3ec3c91 65 /* Set values for the "use javascript" option. */
bbcafebd 66 $optvals[SMOPT_GRP_GENERAL][] = array(
a3ec3c91 67 'name' => 'javascript_setting',
ce393174 68 'caption' => _("Use Javascript"),
a3ec3c91 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
e697b6cc 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";
a3ec3c91 80 $js_autodetect_results = SMPREF_JS_OFF;
bbcafebd 81 $optvals[SMOPT_GRP_GENERAL][] = array(
a3ec3c91 82 'name' => 'js_autodetect_results',
83 'caption' => '',
84 'type' => SMOPT_TYPE_HIDDEN,
cbe5423b 85 'refresh' => SMOPT_REFRESH_NONE,
86 'script' => $js_autodetect_script,
87 'save' => 'save_option_javascript_autodetect'
a3ec3c91 88 );
89
bbcafebd 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(
a3ec3c91 95 'name' => 'show_num',
96 'caption' => _("Number of Messages to Index"),
97 'type' => SMOPT_TYPE_INTEGER,
bbcafebd 98 'refresh' => SMOPT_REFRESH_NONE,
99 'size' => SMOPT_SIZE_TINY
a3ec3c91 100 );
101
bbcafebd 102 $optvals[SMOPT_GRP_MAILBOX][] = array(
a440e68f 103 'name' => 'alt_index_colors',
104 'caption' => _("Enable Alternating Row Colors"),
105 'type' => SMOPT_TYPE_BOOLEAN,
106 'refresh' => SMOPT_REFRESH_NONE
107 );
108
bbcafebd 109 $optvals[SMOPT_GRP_MAILBOX][] = array(
a440e68f 110 'name' => 'page_selector',
111 'caption' => _("Enable Page Selector"),
112 'type' => SMOPT_TYPE_BOOLEAN,
113 'refresh' => SMOPT_REFRESH_NONE
114 );
115
bbcafebd 116 $optvals[SMOPT_GRP_MAILBOX][] = array(
a440e68f 117 'name' => 'page_selector_max',
118 'caption' => _("Maximum Number of Pages to Show"),
119 'type' => SMOPT_TYPE_INTEGER,
bbcafebd 120 'refresh' => SMOPT_REFRESH_NONE,
121 'size' => SMOPT_SIZE_TINY
a440e68f 122 );
123
bbcafebd 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(
a3ec3c91 129 'name' => 'wrap_at',
130 'caption' => _("Wrap Incoming Text At"),
131 'type' => SMOPT_TYPE_INTEGER,
bbcafebd 132 'refresh' => SMOPT_REFRESH_NONE,
133 'size' => SMOPT_SIZE_TINY
a3ec3c91 134 );
135
bbcafebd 136 $optvals[SMOPT_GRP_MESSAGE][] = array(
a3ec3c91 137 'name' => 'editor_size',
138 'caption' => _("Size of Editor Window"),
139 'type' => SMOPT_TYPE_INTEGER,
bbcafebd 140 'refresh' => SMOPT_REFRESH_NONE,
141 'size' => SMOPT_SIZE_TINY
a3ec3c91 142 );
143
bbcafebd 144 $optvals[SMOPT_GRP_MESSAGE][] = array(
a3ec3c91 145 'name' => 'location_of_buttons',
ce393174 146 'caption' => _("Location of Buttons when Composing"),
a3ec3c91 147 'type' => SMOPT_TYPE_STRLIST,
148 'refresh' => SMOPT_REFRESH_NONE,
ce393174 149 'posvals' => array(SMPREF_LOC_TOP => _("Before headers"),
150 SMPREF_LOC_BETWEEN => _("Between headers and message body"),
151 SMPREF_LOC_BOTTOM => _("After message body"))
a3ec3c91 152 );
153
bbcafebd 154 $optvals[SMOPT_GRP_MESSAGE][] = array(
a440e68f 155 'name' => 'use_javascript_addr_book',
156 'caption' => _("Addressbook Display Format"),
ce393174 157 'type' => SMOPT_TYPE_STRLIST,
a440e68f 158 'refresh' => SMOPT_REFRESH_NONE,
159 'posvals' => array('1' => _("Javascript"),
160 '0' => _("HTML"))
fd87494d 161 );
162
bbcafebd 163 $optvals[SMOPT_GRP_MESSAGE][] = array(
fd87494d 164 'name' => 'show_html_default',
165 'caption' => _("Show HTML Version by Default"),
166 'type' => SMOPT_TYPE_BOOLEAN,
167 'refresh' => SMOPT_REFRESH_NONE
168 );
169
bbcafebd 170 $optvals[SMOPT_GRP_MESSAGE][] = array(
fd87494d 171 'name' => 'include_self_reply_all',
bbcafebd 172 'caption' => _("Include Me in CC when I Reply All"),
fd87494d 173 'type' => SMOPT_TYPE_BOOLEAN,
174 'refresh' => SMOPT_REFRESH_NONE
175 );
176
bbcafebd 177 $optvals[SMOPT_GRP_MESSAGE][] = array(
9ab0d96f 178 'name' => 'show_xmailer_default',
a440e68f 179 'caption' => _("Enable Mailer Display"),
9ab0d96f 180 'type' => SMOPT_TYPE_BOOLEAN,
181 'refresh' => SMOPT_REFRESH_NONE
182 );
183
7baf86a9 184 $optvals[SMOPT_GRP_MESSAGE][] = array(
185 'name' => 'attachment_common_show_images',
10f0ce72 186 'caption' => _("Display Attached Images with Message"),
7baf86a9 187 'type' => SMOPT_TYPE_BOOLEAN,
188 'refresh' => SMOPT_REFRESH_NONE
189 );
190
f226cba7 191 $optvals[SMOPT_GRP_MESSAGE][] = array(
192 'name' => 'pf_subtle_link',
10f0ce72 193 'caption' => _("Enable Subtle Printer Friendly Link"),
f226cba7 194 'type' => SMOPT_TYPE_BOOLEAN,
195 'refresh' => SMOPT_REFRESH_NONE
196 );
197
198 $optvals[SMOPT_GRP_MESSAGE][] = array(
199 'name' => 'pf_cleandisplay',
10f0ce72 200 'caption' => _("Enable Printer Friendly Clean Display"),
f226cba7 201 'type' => SMOPT_TYPE_BOOLEAN,
202 'refresh' => SMOPT_REFRESH_NONE
203 );
204
cbe5423b 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}
a3ec3c91 212
cbe5423b 213/******************************************************************/
214/** Define any specialized save functions for this option page. ***/
215/******************************************************************/
f1e6f580 216
cbe5423b 217function save_option_theme($option) {
218 global $theme;
e7db48af 219
cbe5423b 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 }
e7db48af 232
cbe5423b 233 /* Save the option like normal. */
234 save_option($option);
235}
e7db48af 236
cbe5423b 237function save_option_javascript_autodetect($option) {
238 global $data_dir, $username, $new_javascript_setting;
23d6bd09 239
cbe5423b 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?>