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

Last change on this file since 4860 was 4860, checked in by alec, 2 years ago
  • Improved namespace roots handling in folder manager
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 33.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'] . ' <' . rcube_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['addressbook'] = array('id' => 'addressbook','section' => rcube_label('addressbook'));
135  $sections['folders'] = array('id' => 'folders', 'section' => rcube_label('specialfolders'));
136  $sections['server'] = array('id' => 'server',  'section' => rcube_label('serversettings'));
137
138  // hook + define list cols
139  $plugin = $RCMAIL->plugins->exec_hook('preferences_sections_list',
140        array('list' => $sections, 'cols' => array('section')));
141
142  $sections = $plugin['list'];
143
144  $config = $RCMAIL->config->all();
145  $no_override = array_flip($RCMAIL->config->get('dont_override', array()));
146
147  foreach ($sections as $idx => $sect) {
148
149    if ($current && $sect['id'] != $current)
150      continue;
151
152    $blocks = array();
153
154    switch ($sect['id']) {
155    // general
156    case 'general':
157
158    $blocks = array(
159      'main' => array('name' => Q(rcube_label('mainoptions'))),
160      'list' => array('name' => Q(rcube_label('listoptions'))),
161    );
162
163    // language selection
164    if (!isset($no_override['language'])) {
165      $a_lang = $RCMAIL->list_languages();
166      asort($a_lang);
167
168      $field_id = 'rcmfd_lang';
169      $select_lang = new html_select(array('name' => '_language', 'id' => $field_id));
170      $select_lang->add(array_values($a_lang), array_keys($a_lang));
171
172      $blocks['main']['options']['language'] = array(
173        'title' => html::label($field_id, Q(rcube_label('language'))),
174        'content' => $select_lang->show($RCMAIL->user->language),
175      );
176    }
177
178    // show page size selection
179    if (!isset($no_override['timezone'])) {
180      $field_id = 'rcmfd_timezone';
181      $select_timezone = new html_select(array('name' => '_timezone', 'id' => $field_id, 'onchange' => "document.getElementById('rcmfd_dst').disabled=this.selectedIndex==0"));
182      $select_timezone->add(rcube_label('autodetect'), 'auto');
183      $select_timezone->add('(GMT -11:00) Midway Island, Samoa', '-11');
184      $select_timezone->add('(GMT -10:00) Hawaii', '-10');
185      $select_timezone->add('(GMT -9:30) Marquesas Islands', '-9.5');
186      $select_timezone->add('(GMT -9:00) Alaska', '-9');
187      $select_timezone->add('(GMT -8:00) Pacific Time (US/Canada)', '-8');
188      $select_timezone->add('(GMT -7:00) Mountain Time (US/Canada)', '-7');
189      $select_timezone->add('(GMT -6:00) Central Time (US/Canada), Mexico City', '-6');
190      $select_timezone->add('(GMT -5:00) Eastern Time (US/Canada), Bogota, Lima', '-5');
191      $select_timezone->add('(GMT -4:30) Caracas', '-4.5');
192      $select_timezone->add('(GMT -4:00) Atlantic Time (Canada), La Paz', '-4');
193      $select_timezone->add('(GMT -3:30) Nfld Time (Canada), Nfld, S. Labador', '-3.5');
194      $select_timezone->add('(GMT -3:00) Brazil, Buenos Aires, Georgetown', '-3');
195      $select_timezone->add('(GMT -2:00) Mid-Atlantic', '-2');
196      $select_timezone->add('(GMT -1:00) Azores, Cape Verde Islands', '-1');
197      $select_timezone->add('(GMT) Western Europe, London, Lisbon, Casablanca', '0');
198      $select_timezone->add('(GMT +1:00) Central European Time', '1');
199      $select_timezone->add('(GMT +2:00) EET: Tallinn, Helsinki, Kaliningrad, South Africa', '2');
200      $select_timezone->add('(GMT +3:00) Baghdad, Kuwait, Riyadh, Moscow, Nairobi', '3');
201      $select_timezone->add('(GMT +3:30) Tehran', '3.5');
202      $select_timezone->add('(GMT +4:00) Abu Dhabi, Muscat, Baku, Tbilisi', '4');
203      $select_timezone->add('(GMT +4:30) Kabul', '4.5');
204      $select_timezone->add('(GMT +5:00) Ekaterinburg, Islamabad, Karachi', '5');
205      $select_timezone->add('(GMT +5:30) Chennai, Kolkata, Mumbai, New Delhi', '5.5');
206      $select_timezone->add('(GMT +5:45) Kathmandu', '5.75');
207      $select_timezone->add('(GMT +6:00) Almaty, Dhaka, Colombo', '6');
208      $select_timezone->add('(GMT +6:30) Cocos Islands, Myanmar', '6.5');
209      $select_timezone->add('(GMT +7:00) Bangkok, Hanoi, Jakarta', '7');
210      $select_timezone->add('(GMT +8:00) Beijing, Perth, Singapore, Taipei', '8');
211      $select_timezone->add('(GMT +8:45) Caiguna, Eucla, Border Village', '8.75');
212      $select_timezone->add('(GMT +9:00) Tokyo, Seoul, Yakutsk', '9');
213      $select_timezone->add('(GMT +9:30) Adelaide, Darwin', '9.5');
214      $select_timezone->add('(GMT +10:00) EAST/AEST: Sydney, Guam, Vladivostok', '10');
215      $select_timezone->add('(GMT +10:30) New South Wales', '10.5');
216      $select_timezone->add('(GMT +11:00) Magadan, Solomon Islands', '11');
217      $select_timezone->add('(GMT +11:30) Norfolk Island', '11.5');
218      $select_timezone->add('(GMT +12:00) Auckland, Wellington, Kamchatka', '12');
219      $select_timezone->add('(GMT +12:45) Chatham Islands', '12.75');
220      $select_timezone->add('(GMT +13:00) Tonga, Pheonix Islands', '13');
221      $select_timezone->add('(GMT +14:00) Kiribati', '14');
222
223      $blocks['main']['options']['timezone'] = array(
224        'title' => html::label($field_id, Q(rcube_label('timezone'))),
225        'content' => $select_timezone->show((string)$config['timezone']),
226      );
227    }
228
229    // daylight savings
230    if (!isset($no_override['dst_active'])) {
231      $field_id = 'rcmfd_dst';
232      $input_dst = new html_checkbox(array('name' => '_dst_active', 'id' => $field_id, 'value' => 1, 'disabled' => ($config['timezone'] === 'auto')));
233
234      $blocks['main']['options']['dstactive'] = array(
235        'title' => html::label($field_id, Q(rcube_label('dstactive'))),
236        'content' => $input_dst->show($config['dst_active']),
237      );
238    }
239
240    // MM: Show checkbox for toggling 'pretty dates'
241    if (!isset($no_override['prettydate'])) {
242      $field_id = 'rcmfd_prettydate';
243      $input_prettydate = new html_checkbox(array('name' => '_pretty_date', 'id' => $field_id, 'value' => 1));
244
245      $blocks['main']['options']['prettydate'] = array(
246        'title' => html::label($field_id, Q(rcube_label('prettydate'))),
247        'content' => $input_prettydate->show($config['prettydate']?1:0),
248      );
249    }
250
251    // show page size selection
252    if (!isset($no_override['pagesize'])) {
253      $field_id = 'rcmfd_pgsize';
254      $input_pagesize = new html_inputfield(array('name' => '_pagesize', 'id' => $field_id, 'size' => 5));
255
256      $blocks['list']['options']['pagesize'] = array(
257        'title' => html::label($field_id, Q(rcube_label('pagesize'))),
258        'content' => $input_pagesize->show($config['pagesize']),
259      );
260    }
261
262    // show drop-down for available skins
263    if (!isset($no_override['skin'])) {
264      $skins = rcmail_get_skins();
265
266      if (count($skins) > 1) {
267        $field_id = 'rcmfd_skin';
268        $input_skin = new html_select(array('name'=>'_skin', 'id'=>$field_id));
269
270        foreach($skins as $skin)
271          $input_skin->add($skin, $skin);
272
273        $blocks['main']['options']['skin'] = array(
274          'title' => html::label($field_id, Q(rcube_label('skin'))),
275          'content' => $input_skin->show($config['skin']),
276        );
277      }
278    }
279
280    break;
281
282    // Mailbox view (mail screen)
283    case 'mailbox':
284
285    $blocks = array(
286      'main' => array('name' => Q(rcube_label('mainoptions'))),
287      'new_message' => array('name' => Q(rcube_label('newmessage'))),
288    );
289
290    // show config parameter for preview pane
291    if (!isset($no_override['preview_pane'])) {
292      $field_id = 'rcmfd_preview';
293      $input_preview = new html_checkbox(array('name' => '_preview_pane', 'id' => $field_id, 'value' => 1,
294        'onchange' => JS_OBJECT_NAME.'.toggle_preview_pane(this)'));
295
296      $blocks['main']['options']['preview_pane'] = array(
297        'title' => html::label($field_id, Q(rcube_label('previewpane'))),
298        'content' => $input_preview->show($config['preview_pane']?1:0),
299      );
300    }
301
302    // show config parameter for preview pane auto mark as read delay
303    if (!isset($no_override['preview_pane_mark_read'])) {
304      // apply default if config option is not set at all
305      $config['preview_pane_mark_read'] = $RCMAIL->config->get('preview_pane_mark_read', 0);
306
307      $field_id = 'rcmfd_preview_pane_mark_read';
308      $select_delay = new html_select(array('name' => '_preview_pane_mark_read', 'id' => $field_id,
309        'disabled' => $config['preview_pane']?0:1));
310
311      $select_delay->add(rcube_label('never'), '-1');
312      $select_delay->add(rcube_label('immediately'), 0);
313      foreach(array(5, 10, 20, 30) as $sec)
314        $select_delay->add(rcube_label(array('name' => 'afternseconds', 'vars' => array('n' => $sec))), $sec);
315
316      $blocks['main']['options']['preview_pane_mark_read'] = array(
317        'title' => html::label($field_id, Q(rcube_label('previewpanemarkread'))),
318        'content' => $select_delay->show(intval($config['preview_pane_mark_read'])),
319      );
320    }
321
322    if (!isset($no_override['mdn_requests'])) {
323      $field_id = 'rcmfd_mdn_requests';
324      $select_mdn_requests = new html_select(array('name' => '_mdn_requests', 'id' => $field_id));
325      $select_mdn_requests->add(rcube_label('askuser'), 0);
326      $select_mdn_requests->add(rcube_label('autosend'), 1);
327      $select_mdn_requests->add(rcube_label('autosendknown'), 3);
328      $select_mdn_requests->add(rcube_label('autosendknownignore'), 4);
329      $select_mdn_requests->add(rcube_label('ignore'), 2);
330
331      $blocks['main']['options']['mdn_requests'] = array(
332        'title' => html::label($field_id, Q(rcube_label('mdnrequests'))),
333        'content' => $select_mdn_requests->show($config['mdn_requests']),
334      );
335    }
336
337    $RCMAIL->imap_connect();
338    $threading_supported = $RCMAIL->imap->get_capability('THREAD');
339
340    if (!isset($no_override['autoexpand_threads']) && $threading_supported) {
341      $field_id = 'rcmfd_autoexpand_threads';
342      $select_autoexpand_threads = new html_select(array('name' => '_autoexpand_threads', 'id' => $field_id));
343      $select_autoexpand_threads->add(rcube_label('never'), 0);
344      $select_autoexpand_threads->add(rcube_label('do_expand'), 1);
345      $select_autoexpand_threads->add(rcube_label('expand_only_unread'), 2);
346
347      $blocks['main']['options']['autoexpand_threads'] = array(
348        'title' => html::label($field_id, Q(rcube_label('autoexpand_threads'))),
349        'content' => $select_autoexpand_threads->show($config['autoexpand_threads']),
350      );
351    }
352
353    if (!isset($no_override['keep_alive'])) {
354      $field_id = 'rcmfd_keep_alive';
355      $select_keep_alive = new html_select(array('name' => '_keep_alive', 'id' => $field_id));
356
357      foreach(array(1, 3, 5, 10, 15, 30, 60) as $min)
358        if((!$config['min_keep_alive'] || $config['min_keep_alive'] <= $min * 60)
359            && (!$config['session_lifetime'] || $config['session_lifetime'] > $min)) {
360          $select_keep_alive->add(rcube_label(array('name' => 'everynminutes', 'vars' => array('n' => $min))), $min);
361        }
362
363      $blocks['new_message']['options']['keep_alive'] = array(
364        'title' => html::label($field_id, Q(rcube_label('keepalive'))),
365        'content' => $select_keep_alive->show($config['keep_alive']/60),
366      );
367    }
368
369    if (!isset($no_override['check_all_folders'])) {
370      $field_id = 'rcmfd_check_all_folders';
371      $input_check_all = new html_checkbox(array('name' => '_check_all_folders', 'id' => $field_id, 'value' => 1));
372
373      $blocks['new_message']['options']['check_all_folders'] = array(
374        'title' => html::label($field_id, Q(rcube_label('checkallfolders'))),
375        'content' => $input_check_all->show($config['check_all_folders']?1:0),
376      );
377    }
378
379    break;
380
381    // Message viewing
382    case 'mailview':
383
384    $blocks = array(
385      'main' => array('name' => Q(rcube_label('mainoptions'))),
386    );
387
388    // show checkbox for HTML/plaintext messages
389    if (!isset($no_override['prefer_html'])) {
390      $field_id = 'rcmfd_htmlmsg';
391      $input_preferhtml = new html_checkbox(array('name' => '_prefer_html', 'id' => $field_id, 'value' => 1,
392        'onchange' => JS_OBJECT_NAME.'.toggle_prefer_html(this)'));
393
394      $blocks['main']['options']['prefer_html'] = array(
395        'title' => html::label($field_id, Q(rcube_label('preferhtml'))),
396        'content' => $input_preferhtml->show($config['prefer_html']?1:0),
397      );
398    }
399
400    if (!isset($no_override['default_charset'])) {
401      $field_id = 'rcmfd_default_charset';
402
403      $blocks['main']['options']['default_charset'] = array(
404        'title' => html::label($field_id, Q(rcube_label('defaultcharset'))),
405        'content' => $RCMAIL->output->charset_selector(array(
406          'name' => '_default_charset', 'selected' => $config['default_charset']
407          ))
408      );
409    }
410
411    if (!isset($no_override['show_images'])) {
412      $field_id = 'rcmfd_show_images';
413      $input_show_images = new html_select(array('name' => '_show_images', 'id' => $field_id));
414      $input_show_images->add(rcube_label('never'), 0);
415      $input_show_images->add(rcube_label('fromknownsenders'), 1);
416      $input_show_images->add(rcube_label('always'), 2);
417
418      $blocks['main']['options']['show_images'] = array(
419        'title' => html::label($field_id, Q(rcube_label('showremoteimages'))),
420        'content' => $input_show_images->show($config['show_images']),
421      );
422    }
423
424    if (!isset($no_override['inline_images'])) {
425      $field_id = 'rcmfd_inline_images';
426      $input_inline_images = new html_checkbox(array('name' => '_inline_images', 'id' => $field_id, 'value' => 1));
427
428      $blocks['main']['options']['inline_images'] = array(
429        'title' => html::label($field_id, Q(rcube_label('showinlineimages'))),
430        'content' => $input_inline_images->show($config['inline_images']?1:0),
431      );
432    }
433
434    // "display after delete" checkbox
435    if (!isset($no_override['display_next'])) {
436      $field_id = 'rcmfd_displaynext';
437      $input_displaynext = new html_checkbox(array('name' => '_display_next', 'id' => $field_id, 'value' => 1));
438
439      $blocks['main']['options']['display_next'] = array(
440        'title' => html::label($field_id, Q(rcube_label('displaynext'))),
441        'content' => $input_displaynext->show($config['display_next']?1:0),
442      );
443    }
444
445    break;
446
447    // Mail composition
448    case 'compose':
449
450    $blocks = array(
451      'main' => array('name' => Q(rcube_label('mainoptions'))),
452      'sig' => array('name' => Q(rcube_label('signatureoptions'))),
453    );
454
455    // Show checkbox for HTML Editor
456    if (!isset($no_override['htmleditor'])) {
457      $field_id = 'rcmfd_htmleditor';
458      $select_htmleditor = new html_select(array('name' => '_htmleditor', 'id' => $field_id));
459      $select_htmleditor->add(rcube_label('never'), 0);
460      $select_htmleditor->add(rcube_label('always'), 1);
461      $select_htmleditor->add(rcube_label('htmlonreply'), 2);
462
463      $blocks['main']['options']['htmleditor'] = array(
464        'title' => html::label($field_id, Q(rcube_label('htmleditor'))),
465        'content' => $select_htmleditor->show(intval($config['htmleditor'])),
466      );
467    }
468
469    if (!isset($no_override['draft_autosave'])) {
470      $field_id = 'rcmfd_autosave';
471      $select_autosave = new html_select(array('name' => '_draft_autosave', 'id' => $field_id, 'disabled' => empty($config['drafts_mbox'])));
472      $select_autosave->add(rcube_label('never'), 0);
473      foreach (array(1, 3, 5, 10) as $i => $min)
474        $select_autosave->add(rcube_label(array('name' => 'everynminutes', 'vars' => array('n' => $min))), $min*60);
475
476      $blocks['main']['options']['draft_autosave'] = array(
477        'title' => html::label($field_id, Q(rcube_label('autosavedraft'))),
478        'content' => $select_autosave->show($config['draft_autosave']),
479      );
480    }
481
482    if (!isset($no_override['mime_param_folding'])) {
483      $field_id = 'rcmfd_param_folding';
484      $select_param_folding = new html_select(array('name' => '_mime_param_folding', 'id' => $field_id));
485      $select_param_folding->add(rcube_label('2231folding'), 0);
486      $select_param_folding->add(rcube_label('miscfolding'), 1);
487      $select_param_folding->add(rcube_label('2047folding'), 2);
488
489      $blocks['main']['options']['mime_param_folding'] = array(
490        'advanced' => true,
491        'title' => html::label($field_id, Q(rcube_label('mimeparamfolding'))),
492        'content' => $select_param_folding->show($config['mime_param_folding']),
493      );
494    }
495
496    if (!isset($no_override['force_7bit'])) {
497      $field_id = 'rcmfd_force_7bit';
498      $input_7bit = new html_checkbox(array('name' => '_force_7bit', 'id' => $field_id, 'value' => 1));
499
500      $blocks['main']['options']['force_7bit'] = array(
501        'title' => html::label($field_id, Q(rcube_label('force7bit'))),
502        'content' => $input_7bit->show($config['force_7bit']?1:0),
503      );
504    }
505
506    if (!isset($no_override['mdn_default'])) {
507      $field_id = 'rcmfd_mdn_default';
508      $input_mdn = new html_checkbox(array('name' => '_mdn_default', 'id' => $field_id, 'value' => 1));
509
510      $blocks['main']['options']['mdn_default'] = array(
511        'title' => html::label($field_id, Q(rcube_label('reqmdn'))),
512        'content' => $input_mdn->show($config['mdn_default']?1:0),
513      );
514    }
515
516    if (!isset($no_override['dsn_default'])) {
517      $field_id = 'rcmfd_dsn_default';
518      $input_dsn = new html_checkbox(array('name' => '_dsn_default', 'id' => $field_id, 'value' => 1));
519
520      $blocks['main']['options']['dsn_default'] = array(
521        'title' => html::label($field_id, Q(rcube_label('reqdsn'))),
522        'content' => $input_dsn->show($config['dsn_default']?1:0),
523      );
524    }
525
526    if (!isset($no_override['reply_same_folder'])) {
527      $field_id = 'rcmfd_reply_same_folder';
528      $input_reply_same_folder = new html_checkbox(array('name' => '_reply_same_folder', 'id' => $field_id, 'value' => 1));
529
530      $blocks['main']['options']['reply_same_folder'] = array(
531        'title' => html::label($field_id, Q(rcube_label('replysamefolder'))),
532        'content' => $input_reply_same_folder->show($config['reply_same_folder']?1:0),
533      );
534    }
535
536    if (!isset($no_override['top_posting'])) {
537      $field_id = 'rcmfd_top_posting';
538      $select_replymode = new html_select(array('name' => '_top_posting', 'id' => $field_id, 'onchange' => "\$('#rcmfd_sig_above').attr('disabled',this.selectedIndex==0)"));
539      $select_replymode->add(rcube_label('replybottomposting'), 0);
540      $select_replymode->add(rcube_label('replytopposting'), 1);
541
542      $blocks['main']['options']['top_posting'] = array(
543        'title' => html::label($field_id, Q(rcube_label('whenreplying'))),
544        'content' => $select_replymode->show($config['top_posting']?1:0),
545      );
546    }
547
548    if (!isset($no_override['spellcheck_before_send']) && $config['enable_spellcheck']) {
549      $field_id = 'rcmfd_spellcheck_before_send';
550      $input_spellcheck = new html_checkbox(array('name' => '_spellcheck_before_send', 'id' => $field_id, 'value' => 1));
551
552      $blocks['main']['options']['spellcheck_before_send'] = array(
553        'title' => html::label($field_id, Q(rcube_label('spellcheckbeforesend'))),
554        'content' => $input_spellcheck->show($config['spellcheck_before_send']?1:0),
555      );
556    }
557
558    if (!isset($no_override['show_sig'])) {
559      $field_id = 'rcmfd_show_sig';
560      $select_show_sig = new html_select(array('name' => '_show_sig', 'id' => $field_id));
561      $select_show_sig->add(rcube_label('never'), 0);
562      $select_show_sig->add(rcube_label('always'), 1);
563      $select_show_sig->add(rcube_label('newmessageonly'), 2);
564      $select_show_sig->add(rcube_label('replyandforwardonly'), 3);
565
566      $blocks['sig']['options']['show_sig'] = array(
567        'title' => html::label($field_id, Q(rcube_label('autoaddsignature'))),
568        'content' => $select_show_sig->show($RCMAIL->config->get('show_sig', 1)),
569      );
570    }
571
572    if (!isset($no_override['sig_above'])) {
573      $field_id = 'rcmfd_sig_above';
574      $select_sigabove = new html_select(array('name' => '_sig_above', 'id' => $field_id, 'disabled' => !$config['top_posting']));
575      $select_sigabove->add(rcube_label('belowquote'), 0);
576      $select_sigabove->add(rcube_label('abovequote'), 1);
577
578      $blocks['sig']['options']['sig_above'] = array(
579        'title' => html::label($field_id, Q(rcube_label('replysignaturepos'))),
580        'content' => $select_sigabove->show($config['sig_above']?1:0),
581      );
582    }
583
584    if (!isset($no_override['strip_existing_sig'])) {
585      $field_id = 'rcmfd_strip_existing_sig';
586      $input_stripexistingsig = new html_checkbox(array('name' => '_strip_existing_sig', 'id' => $field_id, 'value' => 1));
587
588      $blocks['sig']['options']['strip_existing_sig'] = array(
589        'title' => html::label($field_id, Q(rcube_label('replyremovesignature'))),
590        'content' => $input_stripexistingsig->show($config['strip_existing_sig']?1:0),
591      );
592    }
593
594    break;
595
596
597    // Addressbook config
598    case 'addressbook':
599
600    $blocks = array(
601      'main' => array('name' => Q(rcube_label('mainoptions'))),
602    );
603
604    if (!isset($no_override['default_addressbook'])
605      && ($books = $RCMAIL->get_address_sources(true))
606    ) {
607      $field_id = 'rcmfd_default_addressbook';
608      $select_abook = new html_select(array('name' => '_default_addressbook', 'id' => $field_id));
609
610      foreach ($books as $book) {
611        $select_abook->add($book['name'], $book['id']);
612      }
613
614      $blocks['main']['options']['default_addressbook'] = array(
615        'title' => html::label($field_id, Q(rcube_label('defaultaddressbook'))),
616        'content' => $select_abook->show($config['default_addressbook']),
617      );
618    }
619
620    break;
621
622    // Special IMAP folders
623    case 'folders':
624
625    $blocks = array(
626      'main' => array('name' => Q(rcube_label('mainoptions'))),
627    );
628
629    // Configure special folders
630    if (!isset($no_override['default_imap_folders'])) {
631
632      $RCMAIL->imap_connect();
633
634      // load folders list only when needed
635      if ($current) {
636        $select = rcmail_mailbox_select(array('noselection' => '---', 'realnames' => true,
637          'maxlength' => 30, 'exceptions' => array('INBOX')));
638      }
639      else // dummy select
640        $select = new html_select();
641
642      if (!isset($no_override['drafts_mbox']))
643        $blocks['main']['options']['drafts_mbox'] = array(
644          'title' => Q(rcube_label('drafts')),
645          'content' => $select->show($config['drafts_mbox'], array('name' => "_drafts_mbox")),
646        );
647
648      if (!isset($no_override['sent_mbox']))
649        $blocks['main']['options']['sent_mbox'] = array(
650          'title' => Q(rcube_label('sent')),
651          'content' => $select->show($config['sent_mbox'], array('name' => "_sent_mbox")),
652        );
653
654      if (!isset($no_override['junk_mbox']))
655        $blocks['main']['options']['junk_mbox'] = array(
656          'title' => Q(rcube_label('junk')),
657          'content' => $select->show($config['junk_mbox'], array('name' => "_junk_mbox")),
658        );
659
660      if (!isset($no_override['trash_mbox']))
661        $blocks['main']['options']['trash_mbox'] = array(
662          'title' => Q(rcube_label('trash')),
663          'content' => $select->show($config['trash_mbox'], array('name' => "_trash_mbox")),
664        );
665    }
666
667    break;
668
669    // Server settings
670    case 'server':
671
672    $blocks = array(
673      'main' => array('name' => Q(rcube_label('mainoptions'))),
674      'maintenance' => array('name' => Q(rcube_label('maintenance'))),
675    );
676
677    if (!isset($no_override['read_when_deleted'])) {
678      $field_id = 'rcmfd_read_deleted';
679      $input_readdeleted = new html_checkbox(array('name' => '_read_when_deleted', 'id' => $field_id, 'value' => 1));
680
681      $blocks['main']['options']['read_when_deleted'] = array(
682        'title' => html::label($field_id, Q(rcube_label('readwhendeleted'))),
683        'content' => $input_readdeleted->show($config['read_when_deleted']?1:0),
684      );
685    }
686
687    if (!isset($no_override['flag_for_deletion'])) {
688      $field_id = 'rcmfd_flag_for_deletion';
689      $input_flagfordeletion = new html_checkbox(array('name' => '_flag_for_deletion', 'id' => $field_id, 'value' => 1));
690
691      $blocks['main']['options']['flag_for_deletion'] = array(
692        'title' => html::label($field_id, Q(rcube_label('flagfordeletion'))),
693        'content' => $input_flagfordeletion->show($config['flag_for_deletion']?1:0),
694      );
695    }
696
697    // don't show deleted messages
698    if (!isset($no_override['skip_deleted'])) {
699      $field_id = 'rcmfd_skip_deleted';
700      $input_purge = new html_checkbox(array('name' => '_skip_deleted', 'id' => $field_id, 'value' => 1));
701
702      $blocks['main']['options']['skip_deleted'] = array(
703        'title' => html::label($field_id, Q(rcube_label('skipdeleted'))),
704        'content' => $input_purge->show($config['skip_deleted']?1:0),
705      );
706    }
707
708    if (!isset($no_override['delete_always'])) {
709      $field_id = 'rcmfd_delete_always';
710      $input_delete_always = new html_checkbox(array('name' => '_delete_always', 'id' => $field_id, 'value' => 1));
711
712      $blocks['main']['options']['delete_always'] = array(
713        'title' => html::label($field_id, Q(rcube_label('deletealways'))),
714        'content' => $input_delete_always->show($config['delete_always']?1:0),
715      );
716    }
717
718    // Trash purging on logout
719    if (!isset($no_override['logout_purge'])) {
720      $field_id = 'rcmfd_logout_purge';
721      $input_purge = new html_checkbox(array('name' => '_logout_purge', 'id' => $field_id, 'value' => 1));
722
723      $blocks['maintenance']['options']['logout_purge'] = array(
724        'title' => html::label($field_id, Q(rcube_label('logoutclear'))),
725        'content' => $input_purge->show($config['logout_purge']?1:0),
726      );
727    }
728
729    // INBOX compacting on logout
730    if (!isset($no_override['logout_expunge'])) {
731      $field_id = 'rcmfd_logout_expunge';
732      $input_expunge = new html_checkbox(array('name' => '_logout_expunge', 'id' => $field_id, 'value' => 1));
733
734      $blocks['maintenance']['options']['logout_expunge'] = array(
735        'title' => html::label($field_id, Q(rcube_label('logoutcompact'))),
736        'content' => $input_expunge->show($config['logout_expunge']?1:0),
737      );
738    }
739
740    break;
741    }
742
743    $data = $RCMAIL->plugins->exec_hook('preferences_list', array('section' => $sect['id'], 'blocks' => $blocks));
744    $found = false;
745
746    // create output
747    foreach ($data['blocks'] as $block) {
748      if (!empty($block['content']) || !empty($block['options'])) {
749        $found = true;
750            break;
751      }
752    }
753
754    if (!$found)
755      unset($sections[$idx]);
756    else
757      $sections[$idx]['blocks'] = $data['blocks'];
758  }
759
760  return array($sections, $plugin['cols']);
761}
762
763
764function rcmail_get_skins()
765{
766  $path = 'skins';
767  $skins = array();
768
769  $dir = opendir($path);
770
771  if (!$dir)
772        return false;
773
774  while (($file = readdir($dir)) !== false)
775  {
776    $filename = $path.'/'.$file;
777    if (!preg_match('/^\./', $file) && is_dir($filename) && is_readable($filename))
778      $skins[] = $file;
779  }
780
781  closedir($dir);
782
783  return $skins;
784}
785
786
787function rcmail_folder_options($mailbox)
788{
789    global $RCMAIL;
790
791    $acl             = $RCMAIL->imap->get_capability('ACL');
792    $default_folders = (array) $RCMAIL->config->get('default_imap_folders');
793    $delimiter       = $RCMAIL->imap->get_hierarchy_delimiter();
794    $namespace       = $RCMAIL->imap->get_namespace();
795    $options         = array();
796
797    // check if the folder is a namespace prefix
798    if (!empty($namespace)) {
799        $mbox = $mailbox . $delimiter;
800        foreach ($namespace as $ns) {
801            foreach ($ns as $item) {
802                if ($item[0] === $mbox) {
803                    $options['is_root'] = true;
804                    break;
805                }
806            }
807        }
808    }
809
810    $options['name']      = $mailbox;
811    $options['options']   = $RCMAIL->imap->mailbox_options($mailbox, true);
812    $options['namespace'] = $RCMAIL->imap->mailbox_namespace($mailbox);
813    $options['rights']    = $acl && !$options['is_root'] ? (array)$RCMAIL->imap->my_rights($mailbox) : array();
814    $options['special']   = in_array($mailbox, $default_folders);
815    $options['protected'] = $options['is_root'] || ($options['special'] && $RCMAIL->config->get('protect_default_folders'));
816
817    if (is_array($options['options'])) {
818        foreach ($options['options'] as $opt) {
819            $opt = strtolower($opt);
820            if ($opt == '\noselect' || $opt == '\nonexistent') {
821                $options['noselect'] = true;
822            }
823        }
824    }
825    else {
826        $options['noselect'] = true;
827    }
828
829    if (!empty($options['rights'])) {
830        $options['norename'] = !in_array('x', $options['rights']) &&
831            (!in_array('c', $options['rights']) || !in_array('d', $options['rights']));
832        if (!$options['noselect']) {
833            $options['noselect'] = !in_array('r', $options['rights']);
834        }
835    }
836
837    return $options;
838}
839
840/**
841 * Updates (or creates) folder row in the subscriptions table
842 *
843 * @param string $name      Folder name
844 * @param string $oldname   Old folder name (for update)
845 * @param bool   $subscribe Checks subscription checkbox
846 * @param string $class     CSS class name for folder row
847 */
848function rcmail_update_folder_row($name, $oldname=null, $subscribe=false, $class_name=null)
849{
850    global $IMAP, $CONFIG, $OUTPUT;
851
852    $delimiter    = $IMAP->get_hierarchy_delimiter();
853    $name_utf8    = rcube_charset_convert($name, 'UTF7-IMAP');
854    $protected    = ($CONFIG['protect_default_folders'] == true && in_array($name, $CONFIG['default_imap_folders']));
855
856    $foldersplit  = explode($delimiter, $IMAP->mod_mailbox($name));
857    $level        = count($foldersplit) - 1;
858    $display_name = str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;', $level)
859        . Q($protected ? rcmail_localize_foldername($name) : rcube_charset_convert($foldersplit[$level], 'UTF7-IMAP'));
860
861    if ($oldname === null)
862        $OUTPUT->command('add_folder_row', $name_utf8, $display_name, $protected, $subscribe,
863            false, $class_name);
864    else
865        $OUTPUT->command('replace_folder_row', rcube_charset_convert($oldname, 'UTF7-IMAP'),
866            $name_utf8, $display_name, $protected, $class_name);
867}
868
869
870// register UI objects
871$OUTPUT->add_handlers(array(
872  'prefsframe' => 'rcmail_preferences_frame',
873  'sectionslist' => 'rcmail_sections_list',
874  'identitieslist' => 'rcmail_identities_list',
875));
876
877// register action aliases
878$RCMAIL->register_action_map(array(
879    'folders'       => 'folders.inc',
880    'rename-folder' => 'folders.inc',
881    'delete-folder' => 'folders.inc',
882    'subscribe'     => 'folders.inc',
883    'unsubscribe'   => 'folders.inc',
884    'purge'         => 'folders.inc',
885    'folder-size'   => 'folders.inc',
886    'add-identity'  => 'edit_identity.inc',
887));
Note: See TracBrowser for help on using the repository browser.