c351a990b569ceb69f93da59781c876c042364b3
6 ** Copyright (c) 1999-2001 The SquirrelMail Development Team
7 ** Licensed under the GNU GPL. For full terms see the file COPYING.
9 ** Displays all optinos about display preferences
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);
19 /* Define the optpage load function for the display options page. */
20 function load_optpage_data_display() {
21 global $theme, $languages, $js_autodetect_results;
23 /* Build a simple array into which we will build options. */
27 /******************************************************/
28 /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */
29 /******************************************************/
31 /*** Load the General Options into the array ***/
32 $optgrps[SMOPT_GRP_GENERAL
] = _("General Display Options");
33 $optvals[SMOPT_GRP_GENERAL
] = array();
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'];
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'
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'];
55 $optvals[SMOPT_GRP_GENERAL
][] = array(
57 'caption' => _("Language"),
58 'type' => SMOPT_TYPE_STRLIST
,
59 'refresh' => SMOPT_REFRESH_ALL
,
60 'posvals' => $language_values
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"))
74 $js_autodetect_script = "
75 <SCRIPT LANGUAGE=\"JavaScript\"><!--
76 document.forms[0].new_js_autodetect_results.value = '" . SMPREF_JS_ON
. "';
79 $js_autodetect_results = SMPREF_JS_OFF
;
80 $optvals[SMOPT_GRP_GENERAL
][] = array(
81 'name' => 'js_autodetect_results',
83 'type' => SMOPT_TYPE_HIDDEN
,
84 'refresh' => SMOPT_REFRESH_NONE
,
85 'script' => $js_autodetect_script,
86 'save' => 'save_option_javascript_autodetect'
89 /*** Load the General Options into the array ***/
90 $optgrps[SMOPT_GRP_MAILBOX
] = _("Mailbox Display Options");
91 $optvals[SMOPT_GRP_MAILBOX
] = array();
93 $optvals[SMOPT_GRP_MAILBOX
][] = array(
95 'caption' => _("Number of Messages to Index"),
96 'type' => SMOPT_TYPE_INTEGER
,
97 'refresh' => SMOPT_REFRESH_NONE
,
98 'size' => SMOPT_SIZE_TINY
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
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
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
123 /*** Load the General Options into the array ***/
124 $optgrps[SMOPT_GRP_MESSAGE
] = _("Message Display and Composition");
125 $optvals[SMOPT_GRP_MESSAGE
] = array();
127 $optvals[SMOPT_GRP_MESSAGE
][] = array(
129 'caption' => _("Wrap Incoming Text At"),
130 'type' => SMOPT_TYPE_INTEGER
,
131 'refresh' => SMOPT_REFRESH_NONE
,
132 'size' => SMOPT_SIZE_TINY
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
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"))
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"),
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
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
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
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
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
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
204 /* Assemble all this together and return it as our result. */
212 /******************************************************************/
213 /** Define any specialized save functions for this option page. ***/
214 /******************************************************************/
216 function save_option_theme($option) {
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;
228 if (!$theme_in_array) {
229 $option->new_value
= '';
232 /* Save the option like normal. */
233 save_option($option);
236 function save_option_javascript_autodetect($option) {
237 global $data_dir, $username, $new_javascript_setting;
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
);
244 setPref($data_dir, $username, 'javascript_on', SMPREF_JS_OFF
);
247 setPref($data_dir, $username, 'javascript_on', $new_javascript_setting);