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

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