source: subversion/trunk/roundcubemail/program/steps/settings/func.inc @ 4429

Last change on this file since 4429 was 4429, checked in by alec, 2 years ago
  • Fix setting timezone in Preferences (#1487705)
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 29.8 KB
Line 
1<?php
2
3/*
4 +-----------------------------------------------------------------------+
5 | program/steps/settings/func.inc                                       |
6 |                                                                       |
7 | This file is part of the Roundcube Webmail client                     |
8 | Copyright (C) 2005-2007, The Roundcube Dev Team                       |
9 | Licensed under the GNU GPL                                            |
10 |                                                                       |
11 | PURPOSE:                                                              |
12 |   Provide functionality for user's settings & preferences             |
13 |                                                                       |
14 +-----------------------------------------------------------------------+
15 | Author: Thomas Bruederli <roundcube@gmail.com>                        |
16 +-----------------------------------------------------------------------+
17
18 $Id$
19
20*/
21
22if (!$OUTPUT->ajax_call)
23  $OUTPUT->set_pagetitle(rcube_label('preferences'));
24
25
26// similar function as /steps/settings/identities.inc::rcmail_identity_frame()
27function rcmail_preferences_frame($attrib)
28{
29  global $OUTPUT;
30
31  if (!$attrib['id'])
32    $attrib['id'] = 'rcmprefsframe';
33
34  $attrib['name'] = $attrib['id'];
35
36  $OUTPUT->set_env('contentframe', $attrib['name']);
37  $OUTPUT->set_env('blankpage', $attrib['src'] ? $OUTPUT->abs_url($attrib['src']) : 'program/blank.gif');
38
39  return html::iframe($attrib);
40}
41
42
43function rcmail_sections_list($attrib)
44{
45  global $RCMAIL;
46
47  // add id to message list table if not specified
48  if (!strlen($attrib['id']))
49    $attrib['id'] = 'rcmsectionslist';
50
51  list($list, $cols) = rcmail_user_prefs();
52
53  // create XHTML table
54  $out = rcube_table_output($attrib, $list, $cols, 'id');
55
56  // set client env
57  $RCMAIL->output->add_gui_object('sectionslist', $attrib['id']);
58  $RCMAIL->output->include_script('list.js');
59
60  return $out;
61}
62
63
64function rcmail_identities_list($attrib)
65{
66  global $OUTPUT, $USER, $RCMAIL;
67
68  // add id to message list table if not specified
69  if (!strlen($attrib['id']))
70    $attrib['id'] = 'rcmIdentitiesList';
71
72  // get identities list and define 'mail' column
73  $list = $USER->list_identities();
74  foreach ($list as $idx => $row)
75    $list[$idx]['mail'] = trim($row['name'] . ' <' . idn_to_utf8($row['email']) .'>');
76
77  // get all identites from DB and define list of cols to be displayed
78  $plugin = $RCMAIL->plugins->exec_hook('identities_list', array(
79    'list' => $list,
80    'cols' => array('mail')));
81
82  // @TODO: use <UL> instead of <TABLE> for identities list
83  // create XHTML table
84  $out = rcube_table_output($attrib, $plugin['list'], $plugin['cols'], 'identity_id');
85
86  // set client env
87  $OUTPUT->add_gui_object('identitieslist', $attrib['id']);
88
89  return $out;
90}
91
92
93// similar function as in /steps/addressbook/edit.inc
94function get_form_tags($attrib, $action, $id = null, $hidden = null)
95{
96  global $EDIT_FORM, $RCMAIL;
97
98  $form_start = $form_end = '';
99
100  if (empty($EDIT_FORM)) {
101    $request_key = $action . (isset($id) ? '.'.$id : '');
102    $form_start = $RCMAIL->output->request_form(array(
103          'name'    => 'form',
104          'method'  => 'post',
105          'task'    => $RCMAIL->task,
106          'action'  => $action,
107          'request' => $request_key,
108          'noclose' => true
109        ) + $attrib);
110
111    if (is_array($hidden)) {
112      $hiddenfields = new html_hiddenfield($hidden);
113      $form_start .= $hiddenfields->show();
114    }
115
116    $form_end = !strlen($attrib['form']) ? '</form>' : '';
117
118    $EDIT_FORM = !empty($attrib['form']) ? $attrib['form'] : 'form';
119    $RCMAIL->output->add_gui_object('editform', $EDIT_FORM);
120  }
121
122  return array($form_start, $form_end);
123}
124
125
126function rcmail_user_prefs($current=null)
127{
128  global $RCMAIL;
129
130  $sections['general'] = array('id' => 'general', 'section' => rcube_label('uisettings'));
131  $sections['mailbox'] = array('id' => 'mailbox', 'section' => rcube_label('mailboxview'));
132  $sections['compose'] = array('id' => 'compose', 'section' => rcube_label('messagescomposition'));
133  $sections['mailview'] = array('id' => 'mailview','section' => rcube_label('messagesdisplaying'));
134  $sections['folders'] = array('id' => 'folders', 'section' => rcube_label('specialfolders'));
135  $sections['server'] = array('id' => 'server',  'section' => rcube_label('serversettings'));
136
137  // hook + define list cols
138  $plugin = $RCMAIL->plugins->exec_hook('preferences_sections_list',
139        array('list' => $sections, 'cols' => array('section')));
140
141  $sections = $plugin['list'];
142
143  $config = $RCMAIL->config->all();
144  $no_override = array_flip($RCMAIL->config->get('dont_override', array()));
145
146  foreach ($sections as $idx => $sect) {
147
148    if ($current && $sect['id'] != $current)
149      continue;
150
151    $blocks = array();
152
153    switch ($sect['id']) {
154    // general
155    case 'general':
156
157    $blocks = array(
158      'main' => array('name' => Q(rcube_label('mainoptions'))),
159      'list' => array('name' => Q(rcube_label('listoptions'))),
160    );
161
162    // language selection
163    if (!isset($no_override['language'])) {
164      $a_lang = $RCMAIL->list_languages();
165      asort($a_lang);
166
167      $field_id = 'rcmfd_lang';
168      $select_lang = new html_select(array('name' => '_language', 'id' => $field_id));
169      $select_lang->add(array_values($a_lang), array_keys($a_lang));
170
171      $blocks['main']['options']['language'] = array(
172        'title' => html::label($field_id, Q(rcube_label('language'))),
173        'content' => $select_lang->show($RCMAIL->user->language),
174      );
175    }
176
177    // show page size selection
178    if (!isset($no_override['timezone'])) {
179      $field_id = 'rcmfd_timezone';
180      $select_timezone = new html_select(array('name' => '_timezone', 'id' => $field_id, 'onchange' => "document.getElementById('rcmfd_dst').disabled=this.selectedIndex==0"));
181      $select_timezone->add(rcube_label('autodetect'), 'auto');
182      $select_timezone->add('(GMT -11:00) Midway Island, Samoa', '-11');
183      $select_timezone->add('(GMT -10:00) Hawaii', '-10');
184      $select_timezone->add('(GMT -9:30) Marquesas Islands', '-9.5');
185      $select_timezone->add('(GMT -9:00) Alaska', '-9');
186      $select_timezone->add('(GMT -8:00) Pacific Time (US/Canada)', '-8');
187      $select_timezone->add('(GMT -7:00) Mountain Time (US/Canada)', '-7');
188      $select_timezone->add('(GMT -6:00) Central Time (US/Canada), Mexico City', '-6');
189      $select_timezone->add('(GMT -5:00) Eastern Time (US/Canada), Bogota, Lima', '-5');
190      $select_timezone->add('(GMT -4:30) Caracas', '-4.5');
191      $select_timezone->add('(GMT -4:00) Atlantic Time (Canada), La Paz', '-4');
192      $select_timezone->add('(GMT -3:30) Nfld Time (Canada), Nfld, S. Labador', '-3.5');
193      $select_timezone->add('(GMT -3:00) Brazil, Buenos Aires, Georgetown', '-3');
194      $select_timezone->add('(GMT -2:00) Mid-Atlantic', '-2');
195      $select_timezone->add('(GMT -1:00) Azores, Cape Verde Islands', '-1');
196      $select_timezone->add('(GMT) Western Europe, London, Lisbon, Casablanca', '0');
197      $select_timezone->add('(GMT +1:00) Central European Time', '1');
198      $select_timezone->add('(GMT +2:00) EET: Tallinn, Helsinki, Kaliningrad, South Africa', '2');
199      $select_timezone->add('(GMT +3:00) Baghdad, Kuwait, Riyadh, Moscow, Nairobi', '3');
200      $select_timezone->add('(GMT +3:30) Tehran', '3.5');
201      $select_timezone->add('(GMT +4:00) Abu Dhabi, Muscat, Baku, Tbilisi', '4');
202      $select_timezone->add('(GMT +4:30) Kabul', '4.5');
203      $select_timezone->add('(GMT +5:00) Ekaterinburg, Islamabad, Karachi', '5');
204      $select_timezone->add('(GMT +5:30) Chennai, Kolkata, Mumbai, New Delhi', '5.5');
205      $select_timezone->add('(GMT +5:45) Kathmandu', '5.75');
206      $select_timezone->add('(GMT +6:00) Almaty, Dhaka, Colombo', '6');
207      $select_timezone->add('(GMT +6:30) Cocos Islands, Myanmar', '6.5');
208      $select_timezone->add('(GMT +7:00) Bangkok, Hanoi, Jakarta', '7');
209      $select_timezone->add('(GMT +8:00) Beijing, Perth, Singapore, Taipei', '8');
210      $select_timezone->add('(GMT +8:45) Caiguna, Eucla, Border Village', '8.75');
211      $select_timezone->add('(GMT +9:00) Tokyo, Seoul, Yakutsk', '9');
212      $select_timezone->add('(GMT +9:30) Adelaide, Darwin', '9.5');
213      $select_timezone->add('(GMT +10:00) EAST/AEST: Sydney, Guam, Vladivostok', '10');
214      $select_timezone->add('(GMT +10:30) New South Wales', '10.5');
215      $select_timezone->add('(GMT +11:00) Magadan, Solomon Islands', '11');
216      $select_timezone->add('(GMT +11:30) Norfolk Island', '11.5');
217      $select_timezone->add('(GMT +12:00) Auckland, Wellington, Kamchatka', '12');
218      $select_timezone->add('(GMT +12:45) Chatham Islands', '12.75');
219      $select_timezone->add('(GMT +13:00) Tonga, Pheonix Islands', '13');
220      $select_timezone->add('(GMT +14:00) Kiribati', '14');
221
222      $blocks['main']['options']['timezone'] = array(
223        'title' => html::label($field_id, Q(rcube_label('timezone'))),
224        'content' => $select_timezone->show((string)$config['timezone']),
225      );
226    }
227
228    // daylight savings
229    if (!isset($no_override['dst_active'])) {
230      $field_id = 'rcmfd_dst';
231      $input_dst = new html_checkbox(array('name' => '_dst_active', 'id' => $field_id, 'value' => 1, 'disabled' => ($config['timezone'] === 'auto')));
232
233      $blocks['main']['options']['dstactive'] = array(
234        'title' => html::label($field_id, Q(rcube_label('dstactive'))),
235        'content' => $input_dst->show($config['dst_active']),
236      );
237    }
238
239    // MM: Show checkbox for toggling 'pretty dates'
240    if (!isset($no_override['prettydate'])) {
241      $field_id = 'rcmfd_prettydate';
242      $input_prettydate = new html_checkbox(array('name' => '_pretty_date', 'id' => $field_id, 'value' => 1));
243
244      $blocks['main']['options']['prettydate'] = array(
245        'title' => html::label($field_id, Q(rcube_label('prettydate'))),
246        'content' => $input_prettydate->show($config['prettydate']?1:0),
247      );
248    }
249
250    // show page size selection
251    if (!isset($no_override['pagesize'])) {
252      $field_id = 'rcmfd_pgsize';
253      $input_pagesize = new html_inputfield(array('name' => '_pagesize', 'id' => $field_id, 'size' => 5));
254
255      $blocks['list']['options']['pagesize'] = array(
256        'title' => html::label($field_id, Q(rcube_label('pagesize'))),
257        'content' => $input_pagesize->show($config['pagesize']),
258      );
259    }
260
261    // show drop-down for available skins
262    if (!isset($no_override['skin'])) {
263      $skins = rcmail_get_skins();
264
265      if (count($skins) > 1) {
266        $field_id = 'rcmfd_skin';
267        $input_skin = new html_select(array('name'=>'_skin', 'id'=>$field_id));
268
269        foreach($skins as $skin)
270          $input_skin->add($skin, $skin);
271
272        $blocks['main']['options']['skin'] = array(
273          'title' => html::label($field_id, Q(rcube_label('skin'))),
274          'content' => $input_skin->show($config['skin']),
275        );
276      }
277    }
278
279    break;
280
281    // Mailbox view (mail screen)
282    case 'mailbox':
283
284    $blocks = array(
285      'main' => array('name' => Q(rcube_label('mainoptions'))),
286      'new_message' => array('name' => Q(rcube_label('newmessage'))),
287    );
288
289    // show config parameter for preview pane
290    if (!isset($no_override['preview_pane'])) {
291      $field_id = 'rcmfd_preview';
292      $input_preview = new html_checkbox(array('name' => '_preview_pane', 'id' => $field_id, 'value' => 1,
293        'onchange' => JS_OBJECT_NAME.'.toggle_preview_pane(this)'));
294
295      $blocks['main']['options']['preview_pane'] = array(
296        'title' => html::label($field_id, Q(rcube_label('previewpane'))),
297        'content' => $input_preview->show($config['preview_pane']?1:0),
298      );
299    }
300
301    // show config parameter for preview pane auto mark as read delay
302    if (!isset($no_override['preview_pane_mark_read'])) {
303      // apply default if config option is not set at all
304      $config['preview_pane_mark_read'] = $RCMAIL->config->get('preview_pane_mark_read', 0);
305
306      $field_id = 'rcmfd_preview_pane_mark_read';
307      $select_delay = new html_select(array('name' => '_preview_pane_mark_read', 'id' => $field_id,
308        'disabled' => $config['preview_pane']?0:1));
309
310      $select_delay->add(rcube_label('never'), '-1');
311      $select_delay->add(rcube_label('immediately'), 0);
312      foreach(array(5, 10, 20, 30) as $sec)
313        $select_delay->add(rcube_label(array('name' => 'afternseconds', 'vars' => array('n' => $sec))), $sec);
314
315      $blocks['main']['options']['preview_pane_mark_read'] = array(
316        'title' => html::label($field_id, Q(rcube_label('previewpanemarkread'))),
317        'content' => $select_delay->show(intval($config['preview_pane_mark_read'])),
318      );
319    }
320
321    if (!isset($no_override['mdn_requests'])) {
322      $field_id = 'rcmfd_mdn_requests';
323      $select_mdn_requests = new html_select(array('name' => '_mdn_requests', 'id' => $field_id));
324      $select_mdn_requests->add(rcube_label('askuser'), 0);
325      $select_mdn_requests->add(rcube_label('autosend'), 1);
326      $select_mdn_requests->add(rcube_label('autosendknown'), 3);
327      $select_mdn_requests->add(rcube_label('autosendknownignore'), 4);
328      $select_mdn_requests->add(rcube_label('ignore'), 2);
329
330      $blocks['main']['options']['mdn_requests'] = array(
331        'title' => html::label($field_id, Q(rcube_label('mdnrequests'))),
332        'content' => $select_mdn_requests->show($config['mdn_requests']),
333      );
334    }
335
336    $RCMAIL->imap_connect();
337    $threading_supported = $RCMAIL->imap->get_capability('THREAD');
338
339    if (!isset($no_override['autoexpand_threads']) && $threading_supported) {
340      $field_id = 'rcmfd_autoexpand_threads';
341      $select_autoexpand_threads = new html_select(array('name' => '_autoexpand_threads', 'id' => $field_id));
342      $select_autoexpand_threads->add(rcube_label('never'), 0);
343      $select_autoexpand_threads->add(rcube_label('do_expand'), 1);
344      $select_autoexpand_threads->add(rcube_label('expand_only_unread'), 2);
345
346      $blocks['main']['options']['autoexpand_threads'] = array(
347        'title' => html::label($field_id, Q(rcube_label('autoexpand_threads'))),
348        'content' => $select_autoexpand_threads->show($config['autoexpand_threads']),
349      );
350    }
351
352    if (!isset($no_override['focus_on_new_message'])) {
353      $field_id = 'rcmfd_focus_on_new_message';
354      $input_focus_on_new_message = new html_checkbox(array('name' => '_focus_on_new_message', 'id' => $field_id, 'value' => 1));
355
356      $blocks['new_message']['options']['focus_on_new_message'] = array(
357        'title' => html::label($field_id, Q(rcube_label('focusonnewmessage'))),
358        'content' => $input_focus_on_new_message->show($config['focus_on_new_message']?1:0),
359      );
360    }
361
362    if (!isset($no_override['keep_alive'])) {
363      $field_id = 'rcmfd_keep_alive';
364      $select_keep_alive = new html_select(array('name' => '_keep_alive', 'id' => $field_id));
365
366      foreach(array(1, 3, 5, 10, 15, 30, 60) as $min)
367        if((!$config['min_keep_alive'] || $config['min_keep_alive'] <= $min * 60)
368            && (!$config['session_lifetime'] || $config['session_lifetime'] > $min)) {
369          $select_keep_alive->add(rcube_label(array('name' => 'everynminutes', 'vars' => array('n' => $min))), $min);
370        }
371
372      $blocks['new_message']['options']['keep_alive'] = array(
373        'title' => html::label($field_id, Q(rcube_label('keepalive'))),
374        'content' => $select_keep_alive->show($config['keep_alive']/60),
375      );
376    }
377
378    if (!isset($no_override['check_all_folders'])) {
379      $field_id = 'rcmfd_check_all_folders';
380      $input_check_all = new html_checkbox(array('name' => '_check_all_folders', 'id' => $field_id, 'value' => 1));
381
382      $blocks['new_message']['options']['check_all_folders'] = array(
383        'title' => html::label($field_id, Q(rcube_label('checkallfolders'))),
384        'content' => $input_check_all->show($config['check_all_folders']?1:0),
385      );
386    }
387
388    break;
389
390    // Message viewing
391    case 'mailview':
392
393    $blocks = array(
394      'main' => array('name' => Q(rcube_label('mainoptions'))),
395    );
396
397    // show checkbox for HTML/plaintext messages
398    if (!isset($no_override['prefer_html'])) {
399      $field_id = 'rcmfd_htmlmsg';
400      $input_preferhtml = new html_checkbox(array('name' => '_prefer_html', 'id' => $field_id, 'value' => 1,
401        'onchange' => JS_OBJECT_NAME.'.toggle_prefer_html(this)'));
402
403      $blocks['main']['options']['prefer_html'] = array(
404        'title' => html::label($field_id, Q(rcube_label('preferhtml'))),
405        'content' => $input_preferhtml->show($config['prefer_html']?1:0),
406      );
407    }
408
409    if (!isset($no_override['default_charset'])) {
410      $field_id = 'rcmfd_default_charset';
411
412      $blocks['main']['options']['default_charset'] = array(
413        'title' => html::label($field_id, Q(rcube_label('defaultcharset'))),
414        'content' => $RCMAIL->output->charset_selector(array(
415          'name' => '_default_charset', 'selected' => $config['default_charset']
416          ))
417      );
418    }
419
420    if (!isset($no_override['show_images'])) {
421      $field_id = 'rcmfd_show_images';
422      $input_show_images = new html_select(array('name' => '_show_images', 'id' => $field_id));
423      $input_show_images->add(rcube_label('never'), 0);
424      $input_show_images->add(rcube_label('fromknownsenders'), 1);
425      $input_show_images->add(rcube_label('always'), 2);
426
427      $blocks['main']['options']['show_images'] = array(
428        'title' => html::label($field_id, Q(rcube_label('showremoteimages'))),
429        'content' => $input_show_images->show($config['show_images']),
430      );
431    }
432
433    if (!isset($no_override['inline_images'])) {
434      $field_id = 'rcmfd_inline_images';
435      $input_inline_images = new html_checkbox(array('name' => '_inline_images', 'id' => $field_id, 'value' => 1));
436
437      $blocks['main']['options']['inline_images'] = array(
438        'title' => html::label($field_id, Q(rcube_label('showinlineimages'))),
439        'content' => $input_inline_images->show($config['inline_images']?1:0),
440      );
441    }
442
443    // "display after delete" checkbox
444    if (!isset($no_override['display_next'])) {
445      $field_id = 'rcmfd_displaynext';
446      $input_displaynext = new html_checkbox(array('name' => '_display_next', 'id' => $field_id, 'value' => 1));
447
448      $blocks['main']['options']['display_next'] = array(
449        'title' => html::label($field_id, Q(rcube_label('displaynext'))),
450        'content' => $input_displaynext->show($config['display_next']?1:0),
451      );
452    }
453
454    break;
455
456    // Mail composition
457    case 'compose':
458
459    $blocks = array(
460      'main' => array('name' => Q(rcube_label('mainoptions'))),
461      'sig' => array('name' => Q(rcube_label('signatureoptions'))),
462    );
463
464    // Show checkbox for HTML Editor
465    if (!isset($no_override['htmleditor'])) {
466      $field_id = 'rcmfd_htmleditor';
467      $select_htmleditor = new html_select(array('name' => '_htmleditor', 'id' => $field_id));
468      $select_htmleditor->add(rcube_label('never'), 0);
469      $select_htmleditor->add(rcube_label('always'), 1);
470      $select_htmleditor->add(rcube_label('htmlonreply'), 2);
471
472      $blocks['main']['options']['htmleditor'] = array(
473        'title' => html::label($field_id, Q(rcube_label('htmleditor'))),
474        'content' => $select_htmleditor->show(intval($config['htmleditor'])),
475      );
476    }
477
478    if (!isset($no_override['draft_autosave'])) {
479      $field_id = 'rcmfd_autosave';
480      $select_autosave = new html_select(array('name' => '_draft_autosave', 'id' => $field_id, 'disabled' => empty($config['drafts_mbox'])));
481      $select_autosave->add(rcube_label('never'), 0);
482      foreach (array(1, 3, 5, 10) as $i => $min)
483        $select_autosave->add(rcube_label(array('name' => 'everynminutes', 'vars' => array('n' => $min))), $min*60);
484
485      $blocks['main']['options']['draft_autosave'] = array(
486        'title' => html::label($field_id, Q(rcube_label('autosavedraft'))),
487        'content' => $select_autosave->show($config['draft_autosave']),
488      );
489    }
490
491    if (!isset($no_override['mime_param_folding'])) {
492      $field_id = 'rcmfd_param_folding';
493      $select_param_folding = new html_select(array('name' => '_mime_param_folding', 'id' => $field_id));
494      $select_param_folding->add(rcube_label('2231folding'), 0);
495      $select_param_folding->add(rcube_label('miscfolding'), 1);
496      $select_param_folding->add(rcube_label('2047folding'), 2);
497
498      $blocks['main']['options']['mime_param_folding'] = array(
499        'advanced' => true,
500        'title' => html::label($field_id, Q(rcube_label('mimeparamfolding'))),
501        'content' => $select_param_folding->show($config['mime_param_folding']),
502      );
503    }
504
505    if (!isset($no_override['force_7bit'])) {
506      $field_id = 'rcmfd_force_7bit';
507      $input_7bit = new html_checkbox(array('name' => '_force_7bit', 'id' => $field_id, 'value' => 1));
508
509      $blocks['main']['options']['force_7bit'] = array(
510        'title' => html::label($field_id, Q(rcube_label('force7bit'))),
511        'content' => $input_7bit->show($config['force_7bit']?1:0),
512      );
513    }
514
515    if (!isset($no_override['mdn_default'])) {
516      $field_id = 'rcmfd_mdn_default';
517      $input_mdn = new html_checkbox(array('name' => '_mdn_default', 'id' => $field_id, 'value' => 1));
518
519      $blocks['main']['options']['mdn_default'] = array(
520        'title' => html::label($field_id, Q(rcube_label('reqmdn'))),
521        'content' => $input_mdn->show($config['mdn_default']?1:0),
522      );
523    }
524
525    if (!isset($no_override['dsn_default'])) {
526      $field_id = 'rcmfd_dsn_default';
527      $input_dsn = new html_checkbox(array('name' => '_dsn_default', 'id' => $field_id, 'value' => 1));
528
529      $blocks['main']['options']['dsn_default'] = array(
530        'title' => html::label($field_id, Q(rcube_label('reqdsn'))),
531        'content' => $input_dsn->show($config['dsn_default']?1:0),
532      );
533    }
534
535    if (!isset($no_override['reply_same_folder'])) {
536      $field_id = 'rcmfd_reply_same_folder';
537      $input_reply_same_folder = new html_checkbox(array('name' => '_reply_same_folder', 'id' => $field_id, 'value' => 1));
538
539      $blocks['main']['options']['reply_same_folder'] = array(
540        'title' => html::label($field_id, Q(rcube_label('replysamefolder'))),
541        'content' => $input_reply_same_folder->show($config['reply_same_folder']?1:0),
542      );
543    }
544
545    if (!isset($no_override['top_posting'])) {
546      $field_id = 'rcmfd_top_posting';
547      $select_replymode = new html_select(array('name' => '_top_posting', 'id' => $field_id, 'onchange' => "\$('#rcmfd_sig_above').attr('disabled',this.selectedIndex==0)"));
548      $select_replymode->add(rcube_label('replybottomposting'), 0);
549      $select_replymode->add(rcube_label('replytopposting'), 1);
550
551      $blocks['main']['options']['top_posting'] = array(
552        'title' => html::label($field_id, Q(rcube_label('whenreplying'))),
553        'content' => $select_replymode->show($config['top_posting']?1:0),
554      );
555    }
556
557    if (!isset($no_override['show_sig'])) {
558      $field_id = 'rcmfd_show_sig';
559      $select_show_sig = new html_select(array('name' => '_show_sig', 'id' => $field_id));
560      $select_show_sig->add(rcube_label('never'), 0);
561      $select_show_sig->add(rcube_label('always'), 1);
562      $select_show_sig->add(rcube_label('newmessageonly'), 2);
563      $select_show_sig->add(rcube_label('replyandforwardonly'), 3);
564
565      $blocks['sig']['options']['show_sig'] = array(
566        'title' => html::label($field_id, Q(rcube_label('autoaddsignature'))),
567        'content' => $select_show_sig->show($RCMAIL->config->get('show_sig', 1)),
568      );
569    }
570
571    if (!isset($no_override['sig_above'])) {
572      $field_id = 'rcmfd_sig_above';
573      $select_sigabove = new html_select(array('name' => '_sig_above', 'id' => $field_id, 'disabled' => !$config['top_posting']));
574      $select_sigabove->add(rcube_label('belowquote'), 0);
575      $select_sigabove->add(rcube_label('abovequote'), 1);
576
577      $blocks['sig']['options']['sig_above'] = array(
578        'title' => html::label($field_id, Q(rcube_label('replysignaturepos'))),
579        'content' => $select_sigabove->show($config['sig_above']?1:0),
580      );
581    }
582
583    if (!isset($no_override['strip_existing_sig'])) {
584      $field_id = 'rcmfd_strip_existing_sig';
585      $input_stripexistingsig = new html_checkbox(array('name' => '_strip_existing_sig', 'id' => $field_id, 'value' => 1));
586
587      $blocks['sig']['options']['strip_existing_sig'] = array(
588        'title' => html::label($field_id, Q(rcube_label('replyremovesignature'))),
589        'content' => $input_stripexistingsig->show($config['strip_existing_sig']?1:0),
590      );
591    }
592
593    break;
594
595    // Special IMAP folders
596    case 'folders':
597
598    $blocks = array(
599      'main' => array('name' => Q(rcube_label('mainoptions'))),
600    );
601
602    // Configure special folders
603    if (!isset($no_override['default_imap_folders'])) {
604
605      $RCMAIL->imap_connect();
606
607      // load folders list only when needed
608      if ($current) {
609        $select = rcmail_mailbox_select(array('noselection' => '---', 'realnames' => true,
610          'maxlength' => 30, 'exceptions' => array('INBOX')));
611      }
612      else // dummy select
613        $select = new html_select();
614
615      if (!isset($no_override['drafts_mbox']))
616        $blocks['main']['options']['drafts_mbox'] = array(
617          'title' => Q(rcube_label('drafts')),
618          'content' => $select->show($config['drafts_mbox'], array('name' => "_drafts_mbox")),
619        );
620
621      if (!isset($no_override['sent_mbox']))
622        $blocks['main']['options']['sent_mbox'] = array(
623          'title' => Q(rcube_label('sent')),
624          'content' => $select->show($config['sent_mbox'], array('name' => "_sent_mbox")),
625        );
626
627      if (!isset($no_override['junk_mbox']))
628        $blocks['main']['options']['junk_mbox'] = array(
629          'title' => Q(rcube_label('junk')),
630          'content' => $select->show($config['junk_mbox'], array('name' => "_junk_mbox")),
631        );
632
633      if (!isset($no_override['trash_mbox']))
634        $blocks['main']['options']['trash_mbox'] = array(
635          'title' => Q(rcube_label('trash')),
636          'content' => $select->show($config['trash_mbox'], array('name' => "_trash_mbox")),
637        );
638    }
639
640    break;
641
642    // Server settings
643    case 'server':
644
645    $blocks = array(
646      'main' => array('name' => Q(rcube_label('mainoptions'))),
647      'maintenance' => array('name' => Q(rcube_label('maintenance'))),
648    );
649
650    if (!isset($no_override['read_when_deleted'])) {
651      $field_id = 'rcmfd_read_deleted';
652      $input_readdeleted = new html_checkbox(array('name' => '_read_when_deleted', 'id' => $field_id, 'value' => 1));
653
654      $blocks['main']['options']['read_when_deleted'] = array(
655        'title' => html::label($field_id, Q(rcube_label('readwhendeleted'))),
656        'content' => $input_readdeleted->show($config['read_when_deleted']?1:0),
657      );
658    }
659
660    if (!isset($no_override['flag_for_deletion'])) {
661      $field_id = 'rcmfd_flag_for_deletion';
662      $input_flagfordeletion = new html_checkbox(array('name' => '_flag_for_deletion', 'id' => $field_id, 'value' => 1));
663
664      $blocks['main']['options']['flag_for_deletion'] = array(
665        'title' => html::label($field_id, Q(rcube_label('flagfordeletion'))),
666        'content' => $input_flagfordeletion->show($config['flag_for_deletion']?1:0),
667      );
668    }
669
670    // don't show deleted messages
671    if (!isset($no_override['skip_deleted'])) {
672      $field_id = 'rcmfd_skip_deleted';
673      $input_purge = new html_checkbox(array('name' => '_skip_deleted', 'id' => $field_id, 'value' => 1));
674
675      $blocks['main']['options']['skip_deleted'] = array(
676        'title' => html::label($field_id, Q(rcube_label('skipdeleted'))),
677        'content' => $input_purge->show($config['skip_deleted']?1:0),
678      );
679    }
680
681    if (!isset($no_override['delete_always'])) {
682      $field_id = 'rcmfd_delete_always';
683      $input_delete_always = new html_checkbox(array('name' => '_delete_always', 'id' => $field_id, 'value' => 1));
684
685      $blocks['main']['options']['delete_always'] = array(
686        'title' => html::label($field_id, Q(rcube_label('deletealways'))),
687        'content' => $input_delete_always->show($config['delete_always']?1:0),
688      );
689    }
690
691    // Trash purging on logout
692    if (!isset($no_override['logout_purge'])) {
693      $field_id = 'rcmfd_logout_purge';
694      $input_purge = new html_checkbox(array('name' => '_logout_purge', 'id' => $field_id, 'value' => 1));
695
696      $blocks['maintenance']['options']['logout_purge'] = array(
697        'title' => html::label($field_id, Q(rcube_label('logoutclear'))),
698        'content' => $input_purge->show($config['logout_purge']?1:0),
699      );
700    }
701
702    // INBOX compacting on logout
703    if (!isset($no_override['logout_expunge'])) {
704      $field_id = 'rcmfd_logout_expunge';
705      $input_expunge = new html_checkbox(array('name' => '_logout_expunge', 'id' => $field_id, 'value' => 1));
706
707      $blocks['maintenance']['options']['logout_expunge'] = array(
708        'title' => html::label($field_id, Q(rcube_label('logoutcompact'))),
709        'content' => $input_expunge->show($config['logout_expunge']?1:0),
710      );
711    }
712
713    break;
714    }
715
716    $data = $RCMAIL->plugins->exec_hook('preferences_list', array('section' => $sect['id'], 'blocks' => $blocks));
717    $found = false;
718
719    // create output
720    foreach ($data['blocks'] as $block) {
721      if (!empty($block['content']) || !empty($block['options'])) {
722        $found = true;
723            break;
724      }
725    }
726
727    if (!$found)
728      unset($sections[$idx]);
729    else
730      $sections[$idx]['blocks'] = $data['blocks'];
731  }
732
733  return array($sections, $plugin['cols']);
734}
735
736
737function rcmail_get_skins()
738{
739  $path = 'skins';
740  $skins = array();
741
742  $dir = opendir($path);
743
744  if (!$dir)
745        return false;
746
747  while (($file = readdir($dir)) !== false)
748  {
749    $filename = $path.'/'.$file;
750    if (!preg_match('/^\./', $file) && is_dir($filename) && is_readable($filename))
751      $skins[] = $file;
752  }
753
754  closedir($dir);
755
756  return $skins;
757}
758
759// register UI objects
760$OUTPUT->add_handlers(array(
761  'prefsframe' => 'rcmail_preferences_frame',
762  'sectionslist' => 'rcmail_sections_list',
763  'identitieslist' => 'rcmail_identities_list',
764));
765
766// register action aliases
767$RCMAIL->register_action_map(array(
768    'folders'       => 'folders.inc',
769    'rename-folder' => 'folders.inc',
770    'delete-folder' => 'folders.inc',
771    'subscribe'     => 'folders.inc',
772    'unsubscribe'   => 'folders.inc',
773    'purge'         => 'folders.inc',
774    'folder-size'   => 'folders.inc',
775    'add-identity'  => 'edit_identity.inc',
776));
Note: See TracBrowser for help on using the repository browser.