source: github/program/steps/settings/func.inc @ f8e8af7

HEADcourier-fixdev-browser-capabilitiespdorelease-0.6release-0.7release-0.8
Last change on this file since f8e8af7 was f8e8af7, checked in by alecpl <alec@…>, 3 years ago
  • Settings block (fieldset) can have any content (not only a table with hardcoded structure)
  • Property mode set to 100644
File size: 28.0 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, RoundCube Dev. - Switzerland                 |
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'] . ' <' . $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('ignore'), 2);
327
328      $blocks['main']['options']['mdn_requests'] = array(
329        'title' => html::label($field_id, Q(rcube_label('mdnrequests'))),
330        'content' => $select_mdn_requests->show($config['mdn_requests']),
331      );
332    }
333
334    $RCMAIL->imap_connect();
335    $threading_supported = $RCMAIL->imap->get_capability('thread=references')
336      || $RCMAIL->imap->get_capability('thread=orderedsubject')
337      || $RCMAIL->imap->get_capability('thread=refs');
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      $input_htmleditor = new html_checkbox(array('name' => '_htmleditor', 'id' => $field_id, 'value' => 1));
468
469      $blocks['main']['options']['htmleditor'] = array(
470        'title' => html::label($field_id, Q(rcube_label('htmleditor'))),
471        'content' => $input_htmleditor->show($config['htmleditor']?1:0),
472      );
473    }
474
475    if (!isset($no_override['draft_autosave'])) {
476      $field_id = 'rcmfd_autosave';
477      $select_autosave = new html_select(array('name' => '_draft_autosave', 'id' => $field_id, 'disabled' => empty($config['drafts_mbox'])));
478      $select_autosave->add(rcube_label('never'), 0);
479      foreach (array(1, 3, 5, 10) as $i => $min)
480        $select_autosave->add(rcube_label(array('name' => 'everynminutes', 'vars' => array('n' => $min))), $min*60);
481
482      $blocks['main']['options']['draft_autosave'] = array(
483        'title' => html::label($field_id, Q(rcube_label('autosavedraft'))),
484        'content' => $select_autosave->show($config['draft_autosave']),
485      );
486    }
487
488    if (!isset($no_override['mime_param_folding'])) {
489      $field_id = 'rcmfd_param_folding';
490      $select_param_folding = new html_select(array('name' => '_mime_param_folding', 'id' => $field_id));
491      $select_param_folding->add(rcube_label('2231folding'), 0);
492      $select_param_folding->add(rcube_label('miscfolding'), 1);
493      $select_param_folding->add(rcube_label('2047folding'), 2);
494
495      $blocks['main']['options']['mime_param_folding'] = array(
496        'advanced' => true,
497        'title' => html::label($field_id, Q(rcube_label('mimeparamfolding'))),
498        'content' => $select_param_folding->show($config['mime_param_folding']),
499      );
500    }
501
502    if (!isset($no_override['force_7bit'])) {
503      $field_id = 'rcmfd_force_7bit';
504      $input_7bit = new html_checkbox(array('name' => '_force_7bit', 'id' => $field_id, 'value' => 1));
505
506      $blocks['main']['options']['force_7bit'] = array(
507        'title' => html::label($field_id, Q(rcube_label('force7bit'))),
508        'content' => $input_7bit->show($config['force_7bit']?1:0),
509      );
510    }
511
512    if (!isset($no_override['top_posting'])) {
513      $field_id = 'rcmfd_top_posting';
514      $select_replymode = new html_select(array('name' => '_top_posting', 'id' => $field_id, 'onchange' => "\$('#rcmfd_sig_above').attr('disabled',this.selectedIndex==0)"));
515      $select_replymode->add(rcube_label('replybottomposting'), 0);
516      $select_replymode->add(rcube_label('replytopposting'), 1);
517
518      $blocks['main']['options']['top_posting'] = array(
519        'title' => html::label($field_id, Q(rcube_label('whenreplying'))),
520        'content' => $select_replymode->show($config['top_posting']?1:0),
521      );
522    }
523
524    if (!isset($no_override['show_sig'])) {
525      $field_id = 'rcmfd_show_sig';
526      $select_show_sig = new html_select(array('name' => '_show_sig', 'id' => $field_id));
527      $select_show_sig->add(rcube_label('never'), 0);
528      $select_show_sig->add(rcube_label('always'), 1);
529      $select_show_sig->add(rcube_label('newmessageonly'), 2);
530      $select_show_sig->add(rcube_label('replyandforwardonly'), 3);
531
532      $blocks['sig']['options']['show_sig'] = array(
533        'title' => html::label($field_id, Q(rcube_label('autoaddsignature'))),
534        'content' => $select_show_sig->show($RCMAIL->config->get('show_sig', 1)),
535      );
536    }
537
538    if (!isset($no_override['sig_above'])) {
539      $field_id = 'rcmfd_sig_above';
540      $select_sigabove = new html_select(array('name' => '_sig_above', 'id' => $field_id, 'disabled' => !$config['top_posting']));
541      $select_sigabove->add(rcube_label('belowquote'), 0);
542      $select_sigabove->add(rcube_label('abovequote'), 1);
543
544      $blocks['sig']['options']['sig_above'] = array(
545        'title' => html::label($field_id, Q(rcube_label('replysignaturepos'))),
546        'content' => $select_sigabove->show($config['sig_above']?1:0),
547      );
548    }
549
550    if (!isset($no_override['strip_existing_sig'])) {
551      $field_id = 'rcmfd_strip_existing_sig';
552      $input_stripexistingsig = new html_checkbox(array('name' => '_strip_existing_sig', 'id' => $field_id, 'value' => 1));
553
554      $blocks['sig']['options']['strip_existing_sig'] = array(
555        'title' => html::label($field_id, Q(rcube_label('replyremovesignature'))),
556        'content' => $input_stripexistingsig->show($config['strip_existing_sig']?1:0),
557      );
558    }
559
560    break;
561
562    // Special IMAP folders
563    case 'folders':
564
565    $blocks = array(
566      'main' => array('name' => Q(rcube_label('mainoptions'))),
567    );
568
569    // Configure special folders
570    if (!isset($no_override['default_imap_folders'])) {
571
572      $RCMAIL->imap_connect();
573
574      // load folders list only when needed
575      if ($current) {
576        $select = rcmail_mailbox_select(array('noselection' => '---', 'realnames' => true,
577          'maxlength' => 30, 'exceptions' => array('INBOX')));
578      }
579      else // dummy select
580        $select = new html_select();
581
582      if (!isset($no_override['drafts_mbox']))
583        $blocks['main']['options']['drafts_mbox'] = array(
584          'title' => Q(rcube_label('drafts')),
585          'content' => $select->show($config['drafts_mbox'], array('name' => "_drafts_mbox")),
586        );
587
588      if (!isset($no_override['sent_mbox']))
589        $blocks['main']['options']['sent_mbox'] = array(
590          'title' => Q(rcube_label('sent')),
591          'content' => $select->show($config['sent_mbox'], array('name' => "_sent_mbox")),
592        );
593
594      if (!isset($no_override['junk_mbox']))
595        $blocks['main']['options']['junk_mbox'] = array(
596          'title' => Q(rcube_label('junk')),
597          'content' => $select->show($config['junk_mbox'], array('name' => "_junk_mbox")),
598        );
599
600      if (!isset($no_override['trash_mbox']))
601        $blocks['main']['options']['trash_mbox'] = array(
602          'title' => Q(rcube_label('trash')),
603          'content' => $select->show($config['trash_mbox'], array('name' => "_trash_mbox")),
604        );
605    }
606
607    break;
608
609    // Server settings
610    case 'server':
611
612    $blocks = array(
613      'main' => array('name' => Q(rcube_label('mainoptions'))),
614      'maintenance' => array('name' => Q(rcube_label('maintenance'))),
615    );
616
617    if (!isset($no_override['read_when_deleted'])) {
618      $field_id = 'rcmfd_read_deleted';
619      $input_readdeleted = new html_checkbox(array('name' => '_read_when_deleted', 'id' => $field_id, 'value' => 1));
620
621      $blocks['main']['options']['read_when_deleted'] = array(
622        'title' => html::label($field_id, Q(rcube_label('readwhendeleted'))),
623        'content' => $input_readdeleted->show($config['read_when_deleted']?1:0),
624      );
625    }
626
627    if (!isset($no_override['flag_for_deletion'])) {
628      $field_id = 'rcmfd_flag_for_deletion';
629      $input_flagfordeletion = new html_checkbox(array('name' => '_flag_for_deletion', 'id' => $field_id, 'value' => 1));
630
631      $blocks['main']['options']['flag_for_deletion'] = array(
632        'title' => html::label($field_id, Q(rcube_label('flagfordeletion'))),
633        'content' => $input_flagfordeletion->show($config['flag_for_deletion']?1:0),
634      );
635    }
636
637    // don't show deleted messages
638    if (!isset($no_override['skip_deleted'])) {
639      $field_id = 'rcmfd_skip_deleted';
640      $input_purge = new html_checkbox(array('name' => '_skip_deleted', 'id' => $field_id, 'value' => 1));
641
642      $blocks['main']['options']['skip_deleted'] = array(
643        'title' => html::label($field_id, Q(rcube_label('skipdeleted'))),
644        'content' => $input_purge->show($config['skip_deleted']?1:0),
645      );
646    }
647
648    if (!isset($no_override['delete_always'])) {
649      $field_id = 'rcmfd_delete_always';
650      $input_delete_always = new html_checkbox(array('name' => '_delete_always', 'id' => $field_id, 'value' => 1));
651
652      $blocks['main']['options']['delete_always'] = array(
653        'title' => html::label($field_id, Q(rcube_label('deletealways'))),
654        'content' => $input_delete_always->show($config['delete_always']?1:0),
655      );
656    }
657
658    // Trash purging on logout
659    if (!isset($no_override['logout_purge'])) {
660      $field_id = 'rcmfd_logout_purge';
661      $input_purge = new html_checkbox(array('name' => '_logout_purge', 'id' => $field_id, 'value' => 1));
662
663      $blocks['maintenance']['options']['logout_purge'] = array(
664        'title' => html::label($field_id, Q(rcube_label('logoutclear'))),
665        'content' => $input_purge->show($config['logout_purge']?1:0),
666      );
667    }
668
669    // INBOX compacting on logout
670    if (!isset($no_override['logout_expunge'])) {
671      $field_id = 'rcmfd_logout_expunge';
672      $input_expunge = new html_checkbox(array('name' => '_logout_expunge', 'id' => $field_id, 'value' => 1));
673
674      $blocks['maintenance']['options']['logout_expunge'] = array(
675        'title' => html::label($field_id, Q(rcube_label('logoutcompact'))),
676        'content' => $input_expunge->show($config['logout_expunge']?1:0),
677      );
678    }
679
680    break;
681    }
682
683    $data = $RCMAIL->plugins->exec_hook('preferences_list', array('section' => $sect['id'], 'blocks' => $blocks));
684    $found = false;
685
686    // create output
687    foreach ($data['blocks'] as $block) {
688      if (!empty($block['content']) || !empty($block['options'])) {
689        $found = true;
690            break;
691      }
692    }
693
694    if (!$found)
695      unset($sections[$idx]);
696    else
697      $sections[$idx]['blocks'] = $data['blocks'];
698  }
699
700  return array($sections, $plugin['cols']);
701}
702
703
704function rcmail_get_skins()
705{
706  $path = 'skins';
707  $skins = array();
708
709  $dir = opendir($path);
710
711  if (!$dir)
712        return false;
713
714  while (($file = readdir($dir)) !== false)
715  {
716    $filename = $path.'/'.$file;
717    if (!preg_match('/^\./', $file) && is_dir($filename) && is_readable($filename))
718      $skins[] = $file;
719  }
720
721  closedir($dir);
722
723  return $skins;
724}
725
726
727// register UI objects
728$OUTPUT->add_handlers(array(
729  'prefsframe' => 'rcmail_preferences_frame',
730  'sectionslist' => 'rcmail_sections_list',
731  'identitieslist' => 'rcmail_identities_list',
732));
733
Note: See TracBrowser for help on using the repository browser.