squirrelmail-webmail  1.4.22
About: SquirrelMail is a standards-based webmail package with strong MIME support, address books, and folder manipulation (written in PHP4).
  Fossies Dox: squirrelmail-webmail-1.4.22.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

display.php
Go to the documentation of this file.
1 <?php
2 
15 define('SMOPT_GRP_GENERAL', 0);
16 define('SMOPT_GRP_MAILBOX', 1);
17 define('SMOPT_GRP_MESSAGE', 2);
18 
33  global $theme, $language, $languages, $js_autodetect_results,
35  $optmode;
36 
37  /* Build a simple array into which we will build options. */
38  $optgrps = array();
39  $optvals = array();
40 
41  /******************************************************/
42  /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */
43  /******************************************************/
44 
45  /*** Load the General Options into the array ***/
46  $optgrps[SMOPT_GRP_GENERAL] = _("General Display Options");
47  $optvals[SMOPT_GRP_GENERAL] = array();
48 
49  /* Load the theme option. */
50  $theme_values = array();
51  foreach ($theme as $theme_key => $theme_attributes) {
52  $theme_values[$theme_attributes['NAME']] = $theme_attributes['PATH'];
53  }
54  ksort($theme_values);
55  $theme_values = array_flip($theme_values);
56  $optvals[SMOPT_GRP_GENERAL][] = array(
57  'name' => 'chosen_theme',
58  'caption' => _("Theme"),
59  'type' => SMOPT_TYPE_STRLIST,
60  'refresh' => SMOPT_REFRESH_ALL,
61  'posvals' => $theme_values,
62  'save' => 'save_option_theme'
63  );
64 
65  $css_values = array( 'none' => _("Default" ) );
66  $css_dir = SM_PATH . 'themes/css';
67  if (is_readable($css_dir) && is_dir($css_dir)) {
68  $handle=opendir($css_dir);
69  while ($file = readdir($handle) ) {
70  if ( substr( $file, -4 ) == '.css' ) {
71  $css_values[$file] = substr( $file, 0, strlen( $file ) - 4 );
72  }
73  }
74  closedir($handle);
75  }
76 
77  if ( count( $css_values ) > 1 ) {
78 
79  $optvals[SMOPT_GRP_GENERAL][] = array(
80  'name' => 'custom_css',
81  'caption' => _("Custom Stylesheet"),
82  'type' => SMOPT_TYPE_STRLIST,
83  'refresh' => SMOPT_REFRESH_ALL,
84  'posvals' => $css_values
85  );
86 
87  }
88 
89  $language_values = array();
90  foreach ($languages as $lang_key => $lang_attributes) {
91  if (isset($lang_attributes['NAME'])) {
92  $language_values[$lang_key] = $lang_attributes['NAME'];
93  }
94  }
95 
96  asort($language_values);
98  array_merge(array('' => _("Default")), $language_values);
99  $language = $squirrelmail_language;
100  $optvals[SMOPT_GRP_GENERAL][] = array(
101  'name' => 'language',
102  'caption' => _("Language"),
103  'type' => SMOPT_TYPE_STRLIST,
104  'refresh' => SMOPT_REFRESH_ALL,
105  'posvals' => $language_values,
106  'htmlencoded' => true
107  );
108 
109  /* Set values for the "use javascript" option. */
110  $optvals[SMOPT_GRP_GENERAL][] = array(
111  'name' => 'javascript_setting',
112  'caption' => _("Use Javascript"),
113  'type' => SMOPT_TYPE_STRLIST,
114  'refresh' => SMOPT_REFRESH_ALL,
115  'posvals' => array(SMPREF_JS_AUTODETECT => _("Autodetect"),
116  SMPREF_JS_ON => _("Always"),
117  SMPREF_JS_OFF => _("Never"))
118  );
119 
120  if ($optmode != 'submit')
121  // FIXME: our form is named "f" - why? let's use something better
122  $onLoadScript = 'document.f.new_js_autodetect_results.value = \'' . SMPREF_JS_ON . '\'';
123  else
124  $onLoadScript = '';
125 
126  $optvals[SMOPT_GRP_GENERAL][] = array(
127  'name' => 'js_autodetect_results',
128  'caption' => '',
129  'type' => SMOPT_TYPE_HIDDEN,
130  'refresh' => SMOPT_REFRESH_NONE,
131  //'post_script' => $js_autodetect_script,
132  'save' => 'save_option_javascript_autodetect'
133  );
134 
135  /*** Load the General Options into the array ***/
136  $optgrps[SMOPT_GRP_MAILBOX] = _("Mailbox Display Options");
137  $optvals[SMOPT_GRP_MAILBOX] = array();
138 
139  $optvals[SMOPT_GRP_MAILBOX][] = array(
140  'name' => 'show_num',
141  'caption' => _("Number of Messages per Page"),
142  'type' => SMOPT_TYPE_INTEGER,
143  'refresh' => SMOPT_REFRESH_NONE,
144  'size' => SMOPT_SIZE_TINY
145  );
146 
147  $optvals[SMOPT_GRP_MAILBOX][] = array(
148  'name' => 'alt_index_colors',
149  'caption' => _("Enable Alternating Row Colors"),
150  'type' => SMOPT_TYPE_BOOLEAN,
151  'refresh' => SMOPT_REFRESH_NONE
152  );
153 
154  $optvals[SMOPT_GRP_MAILBOX][] = array(
155  'name' => 'page_selector',
156  'caption' => _("Enable Page Selector"),
157  'type' => SMOPT_TYPE_BOOLEAN,
158  'refresh' => SMOPT_REFRESH_NONE
159  );
160 
161  $optvals[SMOPT_GRP_MAILBOX][] = array(
162  'name' => 'page_selector_max',
163  'caption' => _("Maximum Number of Pages to Show"),
164  'type' => SMOPT_TYPE_INTEGER,
165  'refresh' => SMOPT_REFRESH_NONE,
166  'size' => SMOPT_SIZE_TINY
167  );
168 
169  $optvals[SMOPT_GRP_MAILBOX][] = array(
170  'name' => 'show_full_date',
171  'caption' => _("Always Show Full Date"),
172  'type' => SMOPT_TYPE_BOOLEAN,
173  'refresh' => SMOPT_REFRESH_NONE
174  );
175 
176  $optvals[SMOPT_GRP_MAILBOX][] = array(
177  'name' => 'truncate_sender',
178  'caption' => _("Length of From/To Field (0 for full)"),
179  'type' => SMOPT_TYPE_INTEGER,
180  'refresh' => SMOPT_REFRESH_NONE,
181  'size' => SMOPT_SIZE_TINY,
182  'initial_value' => 55
183  );
184 
185  $optvals[SMOPT_GRP_MAILBOX][] = array(
186  'name' => 'truncate_subject',
187  'caption' => _("Length of Subject Field (0 for full)"),
188  'type' => SMOPT_TYPE_INTEGER,
189  'refresh' => SMOPT_REFRESH_NONE,
190  'size' => SMOPT_SIZE_TINY,
191  'initial_value' => 55
192  );
193 
194  /*** Load the General Options into the array ***/
195  $optgrps[SMOPT_GRP_MESSAGE] = _("Message Display and Composition");
196  $optvals[SMOPT_GRP_MESSAGE] = array();
197 
198  $optvals[SMOPT_GRP_MESSAGE][] = array(
199  'name' => 'wrap_at',
200  'caption' => _("Wrap Incoming Text At"),
201  'type' => SMOPT_TYPE_INTEGER,
202  'refresh' => SMOPT_REFRESH_NONE,
203  'size' => SMOPT_SIZE_TINY
204  );
205 
206  $optvals[SMOPT_GRP_MESSAGE][] = array(
207  'name' => 'editor_size',
208  'caption' => _("Width of Editor Window"),
209  'type' => SMOPT_TYPE_INTEGER,
210  'refresh' => SMOPT_REFRESH_NONE,
211  'size' => SMOPT_SIZE_TINY
212  );
213 
214  $optvals[SMOPT_GRP_MESSAGE][] = array(
215  'name' => 'editor_height',
216  'caption' => _("Height of Editor Window"),
217  'type' => SMOPT_TYPE_INTEGER,
218  'refresh' => SMOPT_REFRESH_NONE,
219  'size' => SMOPT_SIZE_TINY
220  );
221 
222  $optvals[SMOPT_GRP_MESSAGE][] = array(
223  'name' => 'location_of_buttons',
224  'caption' => _("Location of Buttons when Composing"),
225  'type' => SMOPT_TYPE_STRLIST,
226  'refresh' => SMOPT_REFRESH_NONE,
227  'posvals' => array(SMPREF_LOC_TOP => _("Before headers"),
228  SMPREF_LOC_BETWEEN => _("Between headers and message body"),
229  SMPREF_LOC_BOTTOM => _("After message body"))
230  );
231 
232 
233  $optvals[SMOPT_GRP_MESSAGE][] = array(
234  'name' => 'use_javascript_addr_book',
235  'caption' => _("Address Book Display Format"),
236  'type' => SMOPT_TYPE_STRLIST,
237  'refresh' => SMOPT_REFRESH_NONE,
238  'posvals' => array('1' => _("Javascript"),
239  '0' => _("HTML"))
240  );
241 
242  $optvals[SMOPT_GRP_MESSAGE][] = array(
243  'name' => 'addrsrch_fullname',
244  'caption' => _("Format of Addresses Added From Address Book"),
245  'type' => SMOPT_TYPE_STRLIST,
246  'refresh' => SMOPT_REFRESH_NONE,
247  'posvals' => array('noprefix' => _("No prefix/Address only"),
248  'nickname' => _("Nickname and address"),
249  'fullname' => _("Full name and address"))
250  );
251 
252  $optvals[SMOPT_GRP_MESSAGE][] = array(
253  'name' => 'show_html_default',
254  'caption' => _("Show HTML Version by Default"),
255  'type' => SMOPT_TYPE_BOOLEAN,
256  'refresh' => SMOPT_REFRESH_NONE
257  );
258 
259  $optvals[SMOPT_GRP_MESSAGE][] = array(
260  'name' => 'enable_forward_as_attachment',
261  'caption' => _("Enable Forward as Attachment"),
262  'type' => SMOPT_TYPE_BOOLEAN,
263  'refresh' => SMOPT_REFRESH_NONE
264  );
265 
266  $optvals[SMOPT_GRP_MESSAGE][] = array(
267  'name' => 'include_self_reply_all',
268  'caption' => _("Include Me in CC when I Reply All"),
269  'type' => SMOPT_TYPE_BOOLEAN,
270  'refresh' => SMOPT_REFRESH_NONE
271  );
272 
273  $optvals[SMOPT_GRP_MESSAGE][] = array(
274  'name' => 'show_xmailer_default',
275  'caption' => _("Enable Mailer Display"),
276  'type' => SMOPT_TYPE_BOOLEAN,
277  'refresh' => SMOPT_REFRESH_NONE
278  );
279 
280  $optvals[SMOPT_GRP_MESSAGE][] = array(
281  'name' => 'attachment_common_show_images',
282  'caption' => _("Display Attached Images with Message"),
283  'type' => SMOPT_TYPE_BOOLEAN,
284  'refresh' => SMOPT_REFRESH_NONE
285  );
286 
287  $optvals[SMOPT_GRP_MESSAGE][] = array(
288  'name' => 'pf_cleandisplay',
289  'caption' => _("Enable Printer Friendly Clean Display"),
290  'type' => SMOPT_TYPE_BOOLEAN,
291  'refresh' => SMOPT_REFRESH_NONE
292  );
293 
294  if ($default_use_mdn) {
295  $optvals[SMOPT_GRP_MESSAGE][] = array(
296  'name' => 'mdn_user_support',
297  'caption' => _("Enable Mail Delivery Notification"),
298  'type' => SMOPT_TYPE_BOOLEAN,
299  'refresh' => SMOPT_REFRESH_NONE
300  );
301  }
302 
303  $optvals[SMOPT_GRP_MESSAGE][] = array(
304  'name' => 'compose_new_win',
305  'caption' => _("Compose Messages in New Window"),
306  'type' => SMOPT_TYPE_BOOLEAN,
307  'refresh' => SMOPT_REFRESH_ALL
308  );
309 
310  $optvals[SMOPT_GRP_MESSAGE][] = array(
311  'name' => 'compose_width',
312  'caption' => _("Width of Compose Window"),
313  'type' => SMOPT_TYPE_INTEGER,
314  'refresh' => SMOPT_REFRESH_ALL,
315  'size' => SMOPT_SIZE_TINY
316  );
317 
318  $optvals[SMOPT_GRP_MESSAGE][] = array(
319  'name' => 'compose_height',
320  'caption' => _("Height of Compose Window"),
321  'type' => SMOPT_TYPE_INTEGER,
322  'refresh' => SMOPT_REFRESH_ALL,
323  'size' => SMOPT_SIZE_TINY
324  );
325 
326  $optvals[SMOPT_GRP_MESSAGE][] = array(
327  'name' => 'sig_first',
328  'caption' => _("Prepend Signature before Reply/Forward Text"),
329  'type' => SMOPT_TYPE_BOOLEAN,
330  'refresh' => SMOPT_REFRESH_NONE
331  );
332 
333  $optvals[SMOPT_GRP_MESSAGE][] = array(
334  'name' => 'strip_sigs',
335  'caption' => _("Strip signature when replying"),
336  'type' => SMOPT_TYPE_BOOLEAN,
337  'refresh' => SMOPT_REFRESH_NONE
338  );
339 
340  $optvals[SMOPT_GRP_MESSAGE][] = array(
341  'name' => 'body_quote',
342  'caption' => _("Prefix for Original Message when Replying"),
343  'type' => SMOPT_TYPE_STRING,
344  'refresh' => SMOPT_REFRESH_NONE,
345  'size' => SMOPT_SIZE_TINY,
346  'save' => 'save_option_reply_prefix'
347  );
348 
349  $optvals[SMOPT_GRP_MESSAGE][] = array(
350  'name' => 'reply_focus',
351  'caption' => _("Cursor Position when Replying"),
352  'type' => SMOPT_TYPE_STRLIST,
353  'refresh' => SMOPT_REFRESH_NONE,
354  'posvals' => array('' => _("To: field"),
355  'focus' => _("Focus in body"),
356  'select' => _("Select body"),
357  'none' => _("No focus"))
358  );
359 
360  $optvals[SMOPT_GRP_MESSAGE][] = array(
361  'name' => 'internal_date_sort',
362  'caption' => _("Sort by Received Date"),
363  'type' => SMOPT_TYPE_BOOLEAN,
364  'refresh' => SMOPT_REFRESH_ALL,
365  'initial_value' => SMPREF_ON
366  );
367  if ($allow_thread_sort == TRUE) {
368  $optvals[SMOPT_GRP_MESSAGE][] = array(
369  'name' => 'sort_by_ref',
370  'caption' => _("Enable Thread Sort by References Header"),
371  'type' => SMOPT_TYPE_BOOLEAN,
372  'refresh' => SMOPT_REFRESH_ALL
373  );
374  }
375  /* Assemble all this together and return it as our result. */
376  $result = array(
377  'grps' => $optgrps,
378  'vals' => $optvals,
379  'xtra' => $onLoadScript
380  );
381  return ($result);
382 }
383 
384 /******************************************************************/
386 /******************************************************************/
387 
392 function save_option_theme($option) {
393  global $theme;
394 
395  /* Do checking to make sure $new_theme is in the array. */
396  $theme_in_array = false;
397  for ($i = 0; $i < count($theme); ++$i) {
398  if ($theme[$i]['PATH'] == $option->new_value) {
399  $theme_in_array = true;
400  break;
401  }
402  }
403 
404  if (!$theme_in_array) {
405  $option->new_value = '';
406  }
407 
408  /* Save the option like normal. */
409  save_option($option);
410 }
411 
416  global $data_dir, $username;
417 
418  sqGetGlobalVar('new_javascript_setting', $new_javascript_setting);
419 
420  // Set javascript either on or off.
421  if ($new_javascript_setting == SMPREF_JS_AUTODETECT) {
422  if ($option->new_value == SMPREF_JS_ON) {
423  setPref($data_dir, $username, 'javascript_on', SMPREF_JS_ON);
424  } else {
425  setPref($data_dir, $username, 'javascript_on', SMPREF_JS_OFF);
426  }
427  } else {
428  setPref($data_dir, $username, 'javascript_on', $new_javascript_setting);
429  }
430 }
431 
432 function save_option_reply_prefix($option) {
433  global $data_dir, $username, $new_javascript_setting;
434 
435  // save as "NONE" if it was blanked out
436  //
437  if (empty($option->new_value)) $option->new_value = 'NONE';
438 
439 
440  // Save the option like normal.
441  //
442  save_option($option);
443 
444 }
445 
$default_use_mdn
$default_use_mdn
Definition: config_default.php:575
save_option_javascript_autodetect
save_option_javascript_autodetect($option)
Definition: display.php:415
$data_dir
$data_dir
Definition: config_default.php:499
$js_autodetect_results
$js_autodetect_results
Definition: redirect.php:147
SMOPT_TYPE_HIDDEN
const SMOPT_TYPE_HIDDEN
Definition: options.php:26
setPref
setPref($data_dir, $username, $string, $set_to)
Definition: db_prefs.php:352
SMPREF_JS_ON
const SMPREF_JS_ON
Definition: constants.php:53
$username
global $username
Definition: validate.php:55
$theme
$theme[0]['PATH']
Definition: config_default.php:702
save_option_theme
save_option_theme($option)
Definition: display.php:392
SMOPT_GRP_MAILBOX
const SMOPT_GRP_MAILBOX
Definition: display.php:16
SMPREF_LOC_BOTTOM
const SMPREF_LOC_BOTTOM
Definition: constants.php:34
$languages
global $languages
Definition: i18n.php:774
save_option_reply_prefix
save_option_reply_prefix($option)
Definition: display.php:432
SMOPT_SIZE_TINY
const SMOPT_SIZE_TINY
Definition: options.php:49
SMPREF_LOC_TOP
const SMPREF_LOC_TOP
Definition: constants.php:32
SMPREF_JS_OFF
const SMPREF_JS_OFF
Definition: constants.php:52
$allow_thread_sort
$allow_thread_sort
Definition: config_default.php:615
SMOPT_REFRESH_ALL
const SMOPT_REFRESH_ALL
Definition: options.php:46
SMOPT_TYPE_INTEGER
const SMOPT_TYPE_INTEGER
Definition: options.php:23
load_optpage_data_display
load_optpage_data_display()
Definition: display.php:32
SMOPT_TYPE_STRING
const SMOPT_TYPE_STRING
Definition: options.php:20
SMPREF_JS_AUTODETECT
const SMPREF_JS_AUTODETECT
Definition: constants.php:54
SM_PATH
const SM_PATH
Definition: decrypt_headers.php:16
$language_values
$language_values
Definition: defines.php:37
_
_($str)
Definition: gettext.php:160
SMOPT_GRP_GENERAL
const SMOPT_GRP_GENERAL
Definition: display.php:15
SMOPT_REFRESH_NONE
const SMOPT_REFRESH_NONE
Definition: options.php:44
SMOPT_GRP_MESSAGE
const SMOPT_GRP_MESSAGE
Definition: display.php:17
SMOPT_TYPE_STRLIST
const SMOPT_TYPE_STRLIST
Definition: options.php:21
SMOPT_TYPE_BOOLEAN
const SMOPT_TYPE_BOOLEAN
Definition: options.php:25
$squirrelmail_language
global $squirrelmail_language
Definition: i18n.php:774
save_option
save_option($option)
Definition: options.php:847
SMPREF_ON
const SMPREF_ON
Definition: constants.php:28
$compose_new_win
$compose_new_win
Definition: load_prefs.php:251
SMPREF_LOC_BETWEEN
const SMPREF_LOC_BETWEEN
Definition: constants.php:33