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

HEADcourier-fixdev-browser-capabilitiespdorelease-0.6release-0.7release-0.8
Last change on this file since a901aa5 was a901aa5, checked in by alecpl <alec@…>, 5 years ago
  • Added sections (fieldset+label) in Settings interface
  • Property mode set to 100644
File size: 12.0 KB
Line 
1<?php
2
3/*
4 +-----------------------------------------------------------------------+
5 | program/steps/settings/func.inc                                       |
6 |                                                                       |
7 | This file is part of the RoundCube Webmail client                     |
8 | Copyright (C) 2005-2007, RoundCube Dev. - Switzerland                 |
9 | Licensed under the GNU GPL                                            |
10 |                                                                       |
11 | PURPOSE:                                                              |
12 |   Provide functionality for user's settings & preferences             |
13 |                                                                       |
14 +-----------------------------------------------------------------------+
15 | Author: Thomas Bruederli <roundcube@gmail.com>                        |
16 +-----------------------------------------------------------------------+
17
18 $Id$
19
20*/
21
22
23if ($USER->ID)
24  $OUTPUT->set_pagetitle(rcube_label('settingsfor') . " ". $USER->get_username());
25
26
27
28function rcmail_user_prefs_form($attrib)
29  {
30  global $DB, $CONFIG, $sess_user_lang;
31
32  $no_override = is_array($CONFIG['dont_override']) ? array_flip($CONFIG['dont_override']) : array();
33
34  // add some labels to client
35  rcube_add_label('nopagesizewarning');
36 
37  list($form_start, $form_end) = get_form_tags($attrib, 'save-prefs');
38  unset($attrib['form']);
39
40  // allow the following attributes to be added to the <table> tag
41  $attrib_str = create_attrib_string($attrib, array('style', 'class', 'id', 'cellpadding', 'cellspacing', 'border', 'summary'));
42
43  // return the complete edit form as tables
44  $out = "$form_start<fieldset><legend>" . Q(rcube_label('uisettings')) . "</legend>\n<table" . $attrib_str . ">\n\n";
45
46  // show language selection
47  if (!isset($no_override['language']))
48    {
49    $a_lang = rcube_list_languages();
50    asort($a_lang);
51 
52    $field_id = 'rcmfd_lang';
53    $select_lang = new html_select(array('name' => '_language', 'id' => $field_id));
54    $select_lang->add(array_values($a_lang), array_keys($a_lang));
55 
56    $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n",
57                    $field_id,
58                    Q(rcube_label('language')),
59                    $select_lang->show($sess_user_lang));
60    }
61
62
63  // show page size selection
64  if (!isset($no_override['timezone']))
65    {
66    $field_id = 'rcmfd_timezone';
67    $select_timezone = new html_select(array('name' => '_timezone', 'id' => $field_id));
68    $select_timezone->add('(GMT -11:00) Midway Island, Samoa', '-11');
69    $select_timezone->add('(GMT -10:00) Hawaii', '-10');
70    $select_timezone->add('(GMT -9:30) Marquesas Islands', '-9.5');
71    $select_timezone->add('(GMT -9:00) Alaska', '-9');
72    $select_timezone->add('(GMT -8:00) Pacific Time (US/Canada)', '-8');
73    $select_timezone->add('(GMT -7:00) Mountain Time (US/Canada)', '-7');
74    $select_timezone->add('(GMT -6:00) Central Time (US/Canada), Mexico City', '-6');
75    $select_timezone->add('(GMT -5:00) Eastern Time (US/Canada), Bogota, Lima', '-5');
76    $select_timezone->add('(GMT -4:30) Caracas', '-4.5');
77    $select_timezone->add('(GMT -4:00) Atlantic Time (Canada), La Paz', '-4');
78    $select_timezone->add('(GMT -3:30) Nfld Time (Canada), Nfld, S. Labador', '-3.5');
79    $select_timezone->add('(GMT -3:00) Brazil, Buenos Aires, Georgetown', '-3');
80    $select_timezone->add('(GMT -2:00) Mid-Atlantic', '-2');
81    $select_timezone->add('(GMT -1:00) Azores, Cape Verde Islands', '-1');
82    $select_timezone->add('(GMT) Western Europe, London, Lisbon, Casablanca', '0');
83    $select_timezone->add('(GMT +1:00) Central European Time', '1');
84    $select_timezone->add('(GMT +2:00) EET: Kaliningrad, South Africa', '2');
85    $select_timezone->add('(GMT +3:00) Baghdad, Kuwait, Riyadh, Moscow, Nairobi', '3');
86    $select_timezone->add('(GMT +3:30) Tehran', '3.5');
87    $select_timezone->add('(GMT +4:00) Abu Dhabi, Muscat, Baku, Tbilisi', '4');
88    $select_timezone->add('(GMT +4:30) Kabul', '4.5');
89    $select_timezone->add('(GMT +5:00) Ekaterinburg, Islamabad, Karachi', '5');
90    $select_timezone->add('(GMT +5:30) Chennai, Kolkata, Mumbai, New Delhi', '5.5');
91    $select_timezone->add('(GMT +5:45) Kathmandu', '5.75');
92    $select_timezone->add('(GMT +6:00) Almaty, Dhaka, Colombo', '6');
93    $select_timezone->add('(GMT +6:30) Cocos Islands, Myanmar', '6.5');
94    $select_timezone->add('(GMT +7:00) Bangkok, Hanoi, Jakarta', '7');
95    $select_timezone->add('(GMT +8:00) Beijing, Perth, Singapore, Taipei', '8');
96    $select_timezone->add('(GMT +8:45) Caiguna, Eucla, Border Village', '8.75');
97    $select_timezone->add('(GMT +9:00) Tokyo, Seoul, Yakutsk', '9');
98    $select_timezone->add('(GMT +9:30) Adelaide, Darwin', '9.5');
99    $select_timezone->add('(GMT +10:00) EAST/AEST: Sydney, Guam, Vladivostok', '10');
100    $select_timezone->add('(GMT +10:30) New South Wales', '10.5');
101    $select_timezone->add('(GMT +11:00) Magadan, Solomon Islands', '11');
102    $select_timezone->add('(GMT +11:30) Norfolk Island', '11.5');
103    $select_timezone->add('(GMT +12:00) Auckland, Wellington, Kamchatka', '12');
104    $select_timezone->add('(GMT +12:45) Chatham Islands', '12.75');
105    $select_timezone->add('(GMT +13:00) Tonga, Pheonix Islands', '13');
106    $select_timezone->add('(GMT +14:00) Kiribati', '14');
107 
108 
109    $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n",
110                    $field_id,
111                    Q(rcube_label('timezone')),
112                    $select_timezone->show((string)$CONFIG['timezone']));
113    }
114
115  // daylight savings
116  if (!isset($no_override['dst_active']))
117    {
118    $field_id = 'rcmfd_dst';
119    $input_dst = new html_checkbox(array('name' => '_dst_active', 'id' => $field_id, 'value' => 1));
120    $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n",
121                    $field_id,
122                    Q(rcube_label('dstactive')),
123                    $input_dst->show($CONFIG['dst_active']));
124    }
125
126  // show page size selection
127  if (!isset($no_override['pagesize']))
128    {
129    $field_id = 'rcmfd_pgsize';
130    $input_pagesize = new html_inputfield(array('name' => '_pagesize', 'id' => $field_id, 'size' => 5));
131
132    $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n",
133                    $field_id,
134                    Q(rcube_label('pagesize')),
135                    $input_pagesize->show($CONFIG['pagesize']));
136    }
137
138  // MM: Show checkbox for toggling 'pretty dates'
139  if (!isset($no_override['prettydate']))
140    {
141    $field_id = 'rcmfd_prettydate';
142    $input_prettydate = new html_checkbox(array('name' => '_pretty_date', 'id' => $field_id, 'value' => 1));
143
144    $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n",
145                    $field_id,
146                    Q(rcube_label('prettydate')),
147                    $input_prettydate->show($CONFIG['prettydate']?1:0));
148    }
149
150  // show checkbox for HTML/plaintext messages
151  if (!isset($no_override['prefer_html']))
152    {
153    $field_id = 'rcmfd_htmlmsg';
154    $input_pagesize = new html_checkbox(array('name' => '_prefer_html', 'id' => $field_id, 'value' => 1));
155
156    $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n",
157                    $field_id,
158                    Q(rcube_label('preferhtml')),
159                    $input_pagesize->show($CONFIG['prefer_html']?1:0));
160    }
161
162  // Show checkbox for HTML Editor
163  if (!isset($no_override['htmleditor']))
164    {
165    $field_id = 'rcmfd_htmleditor';
166    $input_htmleditor = new html_checkbox(array('name' => '_htmleditor', 'id' => $field_id, 'value' => 1));
167    $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n",
168                    $field_id,
169                    Q(rcube_label('htmleditor')),
170                    $input_htmleditor->show($CONFIG['htmleditor']?1:0));
171    }
172
173  // show config parameter for preview pane
174  if (!isset($no_override['preview_pane']))
175    {
176    $field_id = 'rcmfd_preview';
177    $input_preview = new html_checkbox(array('name' => '_preview_pane', 'id' => $field_id, 'value' => 1));
178    $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n",
179                    $field_id,
180                    Q(rcube_label('previewpane')),
181                    $input_preview->show($CONFIG['preview_pane']?1:0));
182    }
183
184  $out .= "</table></fieldset>\n<fieldset><legend>" . Q(rcube_label('serversettings')) . "</legend>\n<table" . $attrib_str . ">\n\n";
185                 
186  if (!empty($CONFIG['drafts_mbox']) && !isset($no_override['draft_autosave']))
187    {
188    $field_id = 'rcmfd_autosave';
189    $select_autosave = new html_select(array('name' => '_draft_autosave', 'id' => $field_id));
190    $select_autosave->add(rcube_label('never'), 0);
191    foreach (array(3, 5, 10) as $i => $min)
192      $select_autosave->add(rcube_label(array('name' => 'everynminutes', 'vars' => array('n' => $min))), $min*60);
193
194    $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n",
195                    $field_id,
196                    Q(rcube_label('autosavedraft')),
197                    $select_autosave->show($CONFIG['draft_autosave']));
198    }
199
200  // Trash purging on logout
201  if (!isset($no_override['logout_purge']))
202    {
203    $field_id = 'rcmfd_logout_purge';
204    $input_purge = new html_checkbox(array('name' => '_logout_purge', 'id' => $field_id, 'value' => 1));
205    $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n",
206                    $field_id,
207                    Q(rcube_label('logoutclear')),
208                    $input_purge->show($CONFIG['logout_purge']?1:0));
209    }
210
211  // INBOX compacting on logout
212  if (!isset($no_override['logout_expunge']))
213    {
214    $field_id = 'rcmfd_logout_expunge';
215    $input_expunge = new html_checkbox(array('name' => '_logout_expunge', 'id' => $field_id, 'value' => 1));
216    $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n",
217                    $field_id,
218                    Q(rcube_label('logoutcompact')),
219                    $input_expunge->show($CONFIG['logout_expunge']?1:0));
220    }
221
222  $out .= "\n</table></fieldset>$form_end";
223
224  return $out; 
225  }
226
227
228
229function rcmail_identities_list($attrib)
230  {
231  global $OUTPUT, $USER;
232
233  // add id to message list table if not specified
234  if (!strlen($attrib['id']))
235    $attrib['id'] = 'rcmIdentitiesList';
236
237  // define list of cols to be displayed
238  $a_show_cols = array('name', 'email', 'organization', 'reply-to');
239
240  // create XHTML table 
241  $out = rcube_table_output($attrib, $USER->list_identities(), $a_show_cols, 'identity_id');
242 
243  // set client env
244  $OUTPUT->add_gui_object('identitieslist', $attrib['id']);
245
246  return $out;
247  }
248
249
250
251// similar function as in /steps/addressbook/edit.inc
252function get_form_tags($attrib, $action, $add_hidden=array())
253  {
254  global $OUTPUT, $EDIT_FORM, $SESS_HIDDEN_FIELD; 
255
256  $form_start = '';
257  if (!strlen($EDIT_FORM))
258    {
259    $hiddenfields = new html_hiddenfield(array('name' => '_task', 'value' => $GLOBALS['_task']));
260    $hiddenfields->add(array('name' => '_action', 'value' => $action));
261   
262    if ($add_hidden)
263      $hiddenfields->add($add_hidden);
264   
265    if ($_GET['_framed'] || $_POST['_framed'])
266      $hiddenfields->add(array('name' => '_framed', 'value' => 1));
267   
268    $form_start = !strlen($attrib['form']) ? '<form name="form" action="./" method="post">' : '';
269    $form_start .= "\n$SESS_HIDDEN_FIELD\n";
270    $form_start .= $hiddenfields->show();
271    }
272   
273  $form_end = (!strlen($EDIT_FORM) && !strlen($attrib['form'])) ? '</form>' : '';
274  $form_name = strlen($attrib['form']) ? $attrib['form'] : 'form';
275
276  if (!strlen($EDIT_FORM))
277    $OUTPUT->add_gui_object('editform', $form_name);
278 
279  $EDIT_FORM = $form_name;
280
281  return array($form_start, $form_end); 
282  }
283
284
285// register UI objects
286$OUTPUT->add_handlers(array(
287  'userprefs' => 'rcmail_user_prefs_form',
288  'identitieslist' => 'rcmail_identities_list',
289  'itentitieslist' => 'rcmail_identities_list'  // keep this for backward compatibility
290));
291
292
293?>
Note: See TracBrowser for help on using the repository browser.