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