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

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