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

Last change on this file since 1796 was 1796, checked in by thomasb, 5 years ago

Redesign of the identities settings + add config option to disable multiple identities

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 15.5 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
26function rcmail_user_prefs_form($attrib)
27{
28  global $RCMAIL;
29  $config = $RCMAIL->config->all();
30
31  $no_override = is_array($config['dont_override']) ? array_flip($config['dont_override']) : array();
32
33  // add some labels to client
34  rcube_add_label('nopagesizewarning');
35 
36  list($form_start, $form_end) = get_form_tags($attrib, 'save-prefs');
37  unset($attrib['form']);
38
39  $out = $form_start;
40  $table = new html_table(array('cols' => 2));
41
42  // show language selection
43  if (!isset($no_override['language'])) {
44    $a_lang = $RCMAIL->list_languages();
45    asort($a_lang);
46 
47    $field_id = 'rcmfd_lang';
48    $select_lang = new html_select(array('name' => '_language', 'id' => $field_id));
49    $select_lang->add(array_values($a_lang), array_keys($a_lang));
50 
51    $table->add('title', html::label($field_id, Q(rcube_label('language'))));
52    $table->add(null, $select_lang->show($config['language']));
53  }
54
55
56  // show page size selection
57  if (!isset($no_override['timezone'])) {
58    $field_id = 'rcmfd_timezone';
59    $select_timezone = new html_select(array('name' => '_timezone', 'id' => $field_id, 'onchange' => "document.getElementById('rcmfd_dst').disabled=this.selectedIndex==0"));
60    $select_timezone->add(rcube_label('autodetect'), 'auto');
61    $select_timezone->add('(GMT -11:00) Midway Island, Samoa', '-11');
62    $select_timezone->add('(GMT -10:00) Hawaii', '-10');
63    $select_timezone->add('(GMT -9:30) Marquesas Islands', '-9.5');
64    $select_timezone->add('(GMT -9:00) Alaska', '-9');
65    $select_timezone->add('(GMT -8:00) Pacific Time (US/Canada)', '-8');
66    $select_timezone->add('(GMT -7:00) Mountain Time (US/Canada)', '-7');
67    $select_timezone->add('(GMT -6:00) Central Time (US/Canada), Mexico City', '-6');
68    $select_timezone->add('(GMT -5:00) Eastern Time (US/Canada), Bogota, Lima', '-5');
69    $select_timezone->add('(GMT -4:30) Caracas', '-4.5');
70    $select_timezone->add('(GMT -4:00) Atlantic Time (Canada), La Paz', '-4');
71    $select_timezone->add('(GMT -3:30) Nfld Time (Canada), Nfld, S. Labador', '-3.5');
72    $select_timezone->add('(GMT -3:00) Brazil, Buenos Aires, Georgetown', '-3');
73    $select_timezone->add('(GMT -2:00) Mid-Atlantic', '-2');
74    $select_timezone->add('(GMT -1:00) Azores, Cape Verde Islands', '-1');
75    $select_timezone->add('(GMT) Western Europe, London, Lisbon, Casablanca', '0');
76    $select_timezone->add('(GMT +1:00) Central European Time', '1');
77    $select_timezone->add('(GMT +2:00) EET: Kaliningrad, South Africa', '2');
78    $select_timezone->add('(GMT +3:00) Baghdad, Kuwait, Riyadh, Moscow, Nairobi', '3');
79    $select_timezone->add('(GMT +3:30) Tehran', '3.5');
80    $select_timezone->add('(GMT +4:00) Abu Dhabi, Muscat, Baku, Tbilisi', '4');
81    $select_timezone->add('(GMT +4:30) Kabul', '4.5');
82    $select_timezone->add('(GMT +5:00) Ekaterinburg, Islamabad, Karachi', '5');
83    $select_timezone->add('(GMT +5:30) Chennai, Kolkata, Mumbai, New Delhi', '5.5');
84    $select_timezone->add('(GMT +5:45) Kathmandu', '5.75');
85    $select_timezone->add('(GMT +6:00) Almaty, Dhaka, Colombo', '6');
86    $select_timezone->add('(GMT +6:30) Cocos Islands, Myanmar', '6.5');
87    $select_timezone->add('(GMT +7:00) Bangkok, Hanoi, Jakarta', '7');
88    $select_timezone->add('(GMT +8:00) Beijing, Perth, Singapore, Taipei', '8');
89    $select_timezone->add('(GMT +8:45) Caiguna, Eucla, Border Village', '8.75');
90    $select_timezone->add('(GMT +9:00) Tokyo, Seoul, Yakutsk', '9');
91    $select_timezone->add('(GMT +9:30) Adelaide, Darwin', '9.5');
92    $select_timezone->add('(GMT +10:00) EAST/AEST: Sydney, Guam, Vladivostok', '10');
93    $select_timezone->add('(GMT +10:30) New South Wales', '10.5');
94    $select_timezone->add('(GMT +11:00) Magadan, Solomon Islands', '11');
95    $select_timezone->add('(GMT +11:30) Norfolk Island', '11.5');
96    $select_timezone->add('(GMT +12:00) Auckland, Wellington, Kamchatka', '12');
97    $select_timezone->add('(GMT +12:45) Chatham Islands', '12.75');
98    $select_timezone->add('(GMT +13:00) Tonga, Pheonix Islands', '13');
99    $select_timezone->add('(GMT +14:00) Kiribati', '14');
100 
101    $table->add('title', html::label($field_id, Q(rcube_label('timezone'))));
102    $table->add(null, $select_timezone->show((string)$config['timezone']));
103  }
104
105  // daylight savings
106  if (!isset($no_override['dst_active'])) {
107    $field_id = 'rcmfd_dst';
108    $input_dst = new html_checkbox(array('name' => '_dst_active', 'id' => $field_id, 'value' => 1, 'disabled' => ($config['timezone'] === 'auto')));
109   
110    $table->add('title', html::label($field_id, Q(rcube_label('dstactive'))));
111    $table->add(null, $input_dst->show($config['dst_active']));
112  }
113
114  // MM: Show checkbox for toggling 'pretty dates'
115  if (!isset($no_override['prettydate'])) {
116    $field_id = 'rcmfd_prettydate';
117    $input_prettydate = new html_checkbox(array('name' => '_pretty_date', 'id' => $field_id, 'value' => 1));
118
119    $table->add('title', html::label($field_id, Q(rcube_label('prettydate'))));
120    $table->add(null, $input_prettydate->show($config['prettydate']?1:0));
121  }
122
123  // show page size selection
124  if (!isset($no_override['pagesize'])) {
125    $field_id = 'rcmfd_pgsize';
126    $input_pagesize = new html_inputfield(array('name' => '_pagesize', 'id' => $field_id, 'size' => 5));
127
128    $table->add('title', html::label($field_id, Q(rcube_label('pagesize'))));
129    $table->add(null, $input_pagesize->show($config['pagesize']));
130  }
131
132  // show drop-down for available skins
133  if (!isset($no_override['skin'])) {
134    $skins = rcmail_get_skins();
135
136    if (count($skins) > 1) {
137      $field_id = 'rcmfd_skin';
138      $input_skin = new html_select(array('name'=>'_skin', 'id'=>$field_id));
139     
140      foreach($skins as $skin)
141        $input_skin->add($skin, $skin);
142
143      $table->add('title', html::label($field_id, Q(rcube_label('skin'))));
144      $table->add(null, $input_skin->show($config['skin']));
145    }
146  }
147
148  $out .= html::tag('fieldset', null, html::tag('legend', null, Q(rcube_label('uisettings'))) . $table->show($attrib));
149 
150  $table = new html_table(array('cols' => 2));
151
152  // show config parameter for preview pane
153  if (!isset($no_override['preview_pane'])) {
154    $field_id = 'rcmfd_preview';
155    $input_preview = new html_checkbox(array('name' => '_preview_pane', 'id' => $field_id, 'value' => 1));
156   
157    $table->add('title', html::label($field_id, Q(rcube_label('previewpane'))));
158    $table->add(null, $input_preview->show($config['preview_pane']?1:0));
159  }
160
161  if (!isset($no_override['mdn_requests'])) {
162    $field_id = 'rcmfd_mdn_requests';
163    $select_mdn_requests = new html_select(array('name' => '_mdn_requests', 'id' => $field_id));
164    $select_mdn_requests->add(rcube_label('askuser'), 0);
165    $select_mdn_requests->add(rcube_label('autosend'), 1);
166    $select_mdn_requests->add(rcube_label('ignore'), 2);
167
168    $table->add('title', html::label($field_id, Q(rcube_label('mdnrequests'))));
169    $table->add(null, $select_mdn_requests->show($config['mdn_requests']));
170  }
171
172  $out .= html::tag('fieldset', null, html::tag('legend', null, Q(rcube_label('mailboxview'))) . $table->show($attrib));
173
174  $table = new html_table(array('cols' => 2));
175
176  // show checkbox for HTML/plaintext messages
177  if (!isset($no_override['prefer_html'])) {
178    $field_id = 'rcmfd_htmlmsg';
179    $input_preferhtml = new html_checkbox(array('name' => '_prefer_html', 'id' => $field_id, 'value' => 1,
180      'onchange' => JS_OBJECT_NAME.'.toggle_prefer_html(this)'));
181
182    $table->add('title', html::label($field_id, Q(rcube_label('preferhtml'))));
183    $table->add(null, $input_preferhtml->show($config['prefer_html']?1:0));
184  }
185
186  // show checkbox for displaying images from people in the addressbook
187  if (!isset($no_override['addrbook_show_images'])) {
188    $field_id = 'rcmfd_addrbook_show_images';
189    $input_addrbook_show_images = new html_checkbox(array('name' => '_addrbook_show_images', 'id' => $field_id,
190      'value' => 1, 'disabled' => $config['prefer_html']?0:1));
191
192    $table->add('title', html::label($field_id, Q(rcube_label('showknownimages'))));
193    $table->add(null, $input_addrbook_show_images->show($config['addrbook_show_images']?1:0));
194  }
195
196  if (!isset($no_override['inline_images'])) {
197    $field_id = 'rcmfd_inline_images';
198    $input_inline_images = new html_checkbox(array('name' => '_inline_images', 'id' => $field_id, 'value' => 1));
199
200    $table->add('title', html::label($field_id, Q(rcube_label('showinlineimages'))));
201    $table->add(null, $input_inline_images->show($config['inline_images']?1:0));
202  }
203
204  $out .= html::tag('fieldset', null, html::tag('legend', null, Q(rcube_label('messagesdisplaying'))) . $table->show($attrib));
205 
206  $table = new html_table(array('cols' => 2));
207
208  // Show checkbox for HTML Editor
209  if (!isset($no_override['htmleditor'])) {
210    $field_id = 'rcmfd_htmleditor';
211    $input_htmleditor = new html_checkbox(array('name' => '_htmleditor', 'id' => $field_id, 'value' => 1));
212   
213    $table->add('title', html::label($field_id, Q(rcube_label('htmleditor'))));
214    $table->add(null, $input_htmleditor->show($config['htmleditor']?1:0));
215  }
216                 
217  if (!isset($no_override['draft_autosave'])) {
218    $field_id = 'rcmfd_autosave';
219    $select_autosave = new html_select(array('name' => '_draft_autosave', 'id' => $field_id, 'disabled' => empty($config['drafts_mbox'])));
220    $select_autosave->add(rcube_label('never'), 0);
221    foreach (array(3, 5, 10) as $i => $min)
222      $select_autosave->add(rcube_label(array('name' => 'everynminutes', 'vars' => array('n' => $min))), $min*60);
223
224    $table->add('title', html::label($field_id, Q(rcube_label('autosavedraft'))));
225    $table->add(null, $select_autosave->show($config['draft_autosave']));
226  }
227
228  $out .= html::tag('fieldset', null, html::tag('legend', null, Q(rcube_label('messagescomposition'))) . $table->show($attrib));
229
230  // Configure special folders
231  if (!isset($no_override['default_imap_folders'])) {
232    $RCMAIL->imap_init(true);
233    $select = rcmail_mailbox_select(array('noselection' => '---', 'realnames' => true, 'maxlength' => 30));
234   
235    $table = new html_table(array('cols' => 2));
236
237    $table->add('title', Q(rcube_label('drafts')));
238    $table->add(null, $select->show($config['drafts_mbox'], array('name' => "_drafts_mbox", 'onchange' => "document.getElementById('rcmfd_autosave').disabled=this.selectedIndex==0")));
239   
240    $table->add('title', Q(rcube_label('sent')));
241    $table->add(null, $select->show($config['sent_mbox'], array('name' => "_sent_mbox")));
242   
243    $table->add('title', Q(rcube_label('junk')));
244    $table->add(null, $select->show($config['junk_mbox'], array('name' => "_junk_mbox")));
245   
246    $table->add('title', Q(rcube_label('trash')));
247    $table->add(null, $select->show($config['trash_mbox'], array('name' => "_trash_mbox")));
248   
249    $out .= html::tag('fieldset', null, html::tag('legend', null, Q(rcube_label('specialfolders'))) . $table->show($attrib));
250  }
251
252  $table = new html_table(array('cols' => 2));
253
254  if (!isset($no_override['read_when_deleted'])) {
255    $field_id = 'rcmfd_read_deleted';
256    $input_readdeleted = new html_checkbox(array('name' => '_read_when_deleted', 'id' => $field_id, 'value' => 1));
257   
258    $table->add('title', html::label($field_id, Q(rcube_label('readwhendeleted'))));
259    $table->add(null, $input_readdeleted->show($config['read_when_deleted']?1:0));
260  }
261
262  if (!isset($no_override['flag_for_deletion'])) {
263    $field_id = 'rcmfd_flag_for_deletion';
264    $input_flagfordeletion = new html_checkbox(array('name' => '_flag_for_deletion', 'id' => $field_id, 'value' => 1));
265   
266    $table->add('title', html::label($field_id, Q(rcube_label('flagfordeletion'))));
267    $table->add(null, $input_flagfordeletion->show($config['flag_for_deletion']?1:0));
268  }
269
270  // Trash purging on logout
271  if (!isset($no_override['logout_purge'])) {
272    $field_id = 'rcmfd_logout_purge';
273    $input_purge = new html_checkbox(array('name' => '_logout_purge', 'id' => $field_id, 'value' => 1));
274   
275    $table->add('title', html::label($field_id, Q(rcube_label('logoutclear'))));
276    $table->add(null, $input_purge->show($config['logout_purge']?1:0));
277  }
278
279  // INBOX compacting on logout
280  if (!isset($no_override['logout_expunge'])) {
281    $field_id = 'rcmfd_logout_expunge';
282    $input_expunge = new html_checkbox(array('name' => '_logout_expunge', 'id' => $field_id, 'value' => 1));
283
284    $table->add('title', html::label($field_id, Q(rcube_label('logoutcompact'))));
285    $table->add(null, $input_expunge->show($config['logout_expunge']?1:0));
286  }
287
288  $out .= html::tag('fieldset', null, html::tag('legend', null, Q(rcube_label('serversettings'))) . $table->show($attrib));
289
290  return $out . $form_end;
291  }
292
293
294
295function rcmail_identities_list($attrib)
296  {
297  global $OUTPUT, $USER;
298
299  // add id to message list table if not specified
300  if (!strlen($attrib['id']))
301    $attrib['id'] = 'rcmIdentitiesList';
302
303  // define list of cols to be displayed
304  $a_show_cols = array('name', 'email');
305
306  // create XHTML table 
307  $out = rcube_table_output($attrib, $USER->list_identities(), $a_show_cols, 'identity_id');
308 
309  // set client env
310  $OUTPUT->add_gui_object('identitieslist', $attrib['id']);
311
312  return $out;
313  }
314
315
316
317// similar function as in /steps/addressbook/edit.inc
318function get_form_tags($attrib, $action, $add_hidden=array())
319  {
320  global $EDIT_FORM, $RCMAIL;
321
322  $form_start = '';
323  if (!strlen($EDIT_FORM))
324    {
325    $hiddenfields = new html_hiddenfield(array('name' => '_task', 'value' => $RCMAIL->task));
326    $hiddenfields->add(array('name' => '_action', 'value' => $action));
327   
328    if ($add_hidden)
329      $hiddenfields->add($add_hidden);
330   
331    $form_start = !strlen($attrib['form']) ? $RCMAIL->output->form_tag(array('name' => "form", 'method' => "post")) : '';
332    $form_start .= $hiddenfields->show();
333    }
334   
335  $form_end = (!strlen($EDIT_FORM) && !strlen($attrib['form'])) ? '</form>' : '';
336  $form_name = strlen($attrib['form']) ? $attrib['form'] : 'form';
337
338  if (!strlen($EDIT_FORM))
339    $RCMAIL->output->add_gui_object('editform', $form_name);
340 
341  $EDIT_FORM = $form_name;
342
343  return array($form_start, $form_end);
344  }
345
346function rcmail_get_skins()
347  {
348  $path = 'skins';
349  $skins = array();
350
351  $dir = opendir($path);
352 
353  if (!$dir)
354        return false;
355 
356  while (($file = readdir($dir)) !== false)
357    {
358    $filename = $path.'/'.$file;
359    if (is_dir($filename) && is_readable($filename)
360        && !in_array($file, array('.', '..', '.svn')))
361      $skins[] = $file;
362    }
363
364  closedir($dir);
365
366  return $skins;
367  }
368
369$OUTPUT->set_env('multiple_identities', $RCMAIL->config->get('multiple_identities', true));
370
371// register UI objects
372$OUTPUT->add_handlers(array(
373  'userprefs' => 'rcmail_user_prefs_form',
374  'identitieslist' => 'rcmail_identities_list',
375  'itentitieslist' => 'rcmail_identities_list'  // keep this for backward compatibility
376));
377
378
379?>
Note: See TracBrowser for help on using the repository browser.