75184af5c7a4706eadce28ec835832fcd46ee068
6 * Copyright (c) 1999-2002 The SquirrelMail Project 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['NAME']] = $theme_attributes['PATH'];
41 $theme_values = array_flip($theme_values);
42 $optvals[SMOPT_GRP_GENERAL
][] = array(
43 'name' => 'chosen_theme',
44 'caption' => _("Theme"),
45 'type' => SMOPT_TYPE_STRLIST
,
46 'refresh' => SMOPT_REFRESH_ALL
,
47 'posvals' => $theme_values,
48 'save' => 'save_option_theme'
51 $language_values = array('');
52 foreach ($languages as $lang_key => $lang_attributes) {
53 if (isset($lang_attributes['NAME'])) {
54 $language_values[$lang_key] = $lang_attributes['NAME'];
57 $optvals[SMOPT_GRP_GENERAL
][] = array(
59 'caption' => _("Language"),
60 'type' => SMOPT_TYPE_STRLIST
,
61 'refresh' => SMOPT_REFRESH_ALL
,
62 'posvals' => $language_values
65 /* Set values for the "use javascript" option. */
66 $optvals[SMOPT_GRP_GENERAL
][] = array(
67 'name' => 'javascript_setting',
68 'caption' => _("Use Javascript"),
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"))
76 $js_autodetect_script =
77 "<SCRIPT LANGUAGE=\"JavaScript\"><!--\n".
78 "document.forms[0].new_js_autodetect_results.value = '" . SMPREF_JS_ON
. "';\n".
80 $js_autodetect_results = SMPREF_JS_OFF
;
81 $optvals[SMOPT_GRP_GENERAL
][] = array(
82 'name' => 'js_autodetect_results',
84 'type' => SMOPT_TYPE_HIDDEN
,
85 'refresh' => SMOPT_REFRESH_NONE
,
86 'script' => $js_autodetect_script,
87 'save' => 'save_option_javascript_autodetect'
90 /*** Load the General Options into the array ***/
91 $optgrps[SMOPT_GRP_MAILBOX
] = _("Mailbox Display Options");
92 $optvals[SMOPT_GRP_MAILBOX
] = array();
94 $optvals[SMOPT_GRP_MAILBOX
][] = array(
96 'caption' => _("Number of Messages to Index"),
97 'type' => SMOPT_TYPE_INTEGER
,
98 'refresh' => SMOPT_REFRESH_NONE
,
99 'size' => SMOPT_SIZE_TINY
102 $optvals[SMOPT_GRP_MAILBOX
][] = array(
103 'name' => 'alt_index_colors',
104 'caption' => _("Enable Alternating Row Colors"),
105 'type' => SMOPT_TYPE_BOOLEAN
,
106 'refresh' => SMOPT_REFRESH_NONE
109 $optvals[SMOPT_GRP_MAILBOX
][] = array(
110 'name' => 'page_selector',
111 'caption' => _("Enable Page Selector"),
112 'type' => SMOPT_TYPE_BOOLEAN
,
113 'refresh' => SMOPT_REFRESH_NONE
116 $optvals[SMOPT_GRP_MAILBOX
][] = array(
117 'name' => 'page_selector_max',
118 'caption' => _("Maximum Number of Pages to Show"),
119 'type' => SMOPT_TYPE_INTEGER
,
120 'refresh' => SMOPT_REFRESH_NONE
,
121 'size' => SMOPT_SIZE_TINY
124 /*** Load the General Options into the array ***/
125 $optgrps[SMOPT_GRP_MESSAGE
] = _("Message Display and Composition");
126 $optvals[SMOPT_GRP_MESSAGE
] = array();
128 $optvals[SMOPT_GRP_MESSAGE
][] = array(
130 'caption' => _("Wrap Incoming Text At"),
131 'type' => SMOPT_TYPE_INTEGER
,
132 'refresh' => SMOPT_REFRESH_NONE
,
133 'size' => SMOPT_SIZE_TINY
136 $optvals[SMOPT_GRP_MESSAGE
][] = array(
137 'name' => 'editor_size',
138 'caption' => _("Size of Editor Window"),
139 'type' => SMOPT_TYPE_INTEGER
,
140 'refresh' => SMOPT_REFRESH_NONE
,
141 'size' => SMOPT_SIZE_TINY
144 $optvals[SMOPT_GRP_MESSAGE
][] = array(
145 'name' => 'location_of_buttons',
146 'caption' => _("Location of Buttons when Composing"),
147 'type' => SMOPT_TYPE_STRLIST
,
148 'refresh' => SMOPT_REFRESH_NONE
,
149 'posvals' => array(SMPREF_LOC_TOP
=> _("Before headers"),
150 SMPREF_LOC_BETWEEN
=> _("Between headers and message body"),
151 SMPREF_LOC_BOTTOM
=> _("After message body"))
154 $optvals[SMOPT_GRP_MESSAGE
][] = array(
155 'name' => 'use_javascript_addr_book',
156 'caption' => _("Addressbook Display Format"),
157 'type' => SMOPT_TYPE_STRLIST
,
158 'refresh' => SMOPT_REFRESH_NONE
,
159 'posvals' => array('1' => _("Javascript"),
163 $optvals[SMOPT_GRP_MESSAGE
][] = array(
164 'name' => 'show_html_default',
165 'caption' => _("Show HTML Version by Default"),
166 'type' => SMOPT_TYPE_BOOLEAN
,
167 'refresh' => SMOPT_REFRESH_NONE
170 $optvals[SMOPT_GRP_MESSAGE
][] = array(
171 'name' => 'include_self_reply_all',
172 'caption' => _("Include Me in CC when I Reply All"),
173 'type' => SMOPT_TYPE_BOOLEAN
,
174 'refresh' => SMOPT_REFRESH_NONE
177 $optvals[SMOPT_GRP_MESSAGE
][] = array(
178 'name' => 'show_xmailer_default',
179 'caption' => _("Enable Mailer Display"),
180 'type' => SMOPT_TYPE_BOOLEAN
,
181 'refresh' => SMOPT_REFRESH_NONE
184 $optvals[SMOPT_GRP_MESSAGE
][] = array(
185 'name' => 'attachment_common_show_images',
186 'caption' => _("Display Attached Images with Message"),
187 'type' => SMOPT_TYPE_BOOLEAN
,
188 'refresh' => SMOPT_REFRESH_NONE
191 $optvals[SMOPT_GRP_MESSAGE
][] = array(
192 'name' => 'pf_subtle_link',
193 'caption' => _("Enable Subtle Printer Friendly Link"),
194 'type' => SMOPT_TYPE_BOOLEAN
,
195 'refresh' => SMOPT_REFRESH_NONE
198 $optvals[SMOPT_GRP_MESSAGE
][] = array(
199 'name' => 'pf_cleandisplay',
200 'caption' => _("Enable Printer Friendly Clean Display"),
201 'type' => SMOPT_TYPE_BOOLEAN
,
202 'refresh' => SMOPT_REFRESH_NONE
205 /* Assemble all this together and return it as our result. */
213 /******************************************************************/
214 /** Define any specialized save functions for this option page. ***/
215 /******************************************************************/
217 function save_option_theme($option) {
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;
229 if (!$theme_in_array) {
230 $option->new_value
= '';
233 /* Save the option like normal. */
234 save_option($option);
237 function save_option_javascript_autodetect($option) {
238 global $data_dir, $username, $new_javascript_setting;
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
);
245 setPref($data_dir, $username, 'javascript_on', SMPREF_JS_OFF
);
248 setPref($data_dir, $username, 'javascript_on', $new_javascript_setting);