4 +-----------------------------------------------------------------------+
5 | program/steps/settings/func.inc |
7 | This file is part of the RoundCube Webmail client |
8 | Copyright (C) 2005-2007, RoundCube Dev. - Switzerland |
9 | Licensed under the GNU GPL |
12 | Provide functionality for user's settings & preferences |
14 +-----------------------------------------------------------------------+
15 | Author: Thomas Bruederli <roundcube@gmail.com> |
16 +-----------------------------------------------------------------------+
18 $Id: func.inc 2483 2009-05-15 10:22:29Z thomasb $
22 if (!$OUTPUT->ajax_call)
23 $OUTPUT->set_pagetitle(rcube_label('preferences'));
25 function rcmail_user_prefs_form($attrib)
29 $no_override = array_flip($RCMAIL->config->get('dont_override', array()));
30 $blocks = $attrib['parts'] ? preg_split('/[\s,;]+/', strip_quotes($attrib['parts'])) : array('general','mailbox','compose','mailview','folders','server');
32 // add some labels to client
33 $RCMAIL->output->add_label('nopagesizewarning');
35 list($form_start, $form_end) = get_form_tags($attrib, 'save-prefs');
36 unset($attrib['form']);
40 foreach ($blocks as $part)
41 $out .= rcmail_user_prefs_block($part, $no_override, $attrib);
43 return $out . $form_end;
46 function rcmail_user_prefs_block($part, $no_override, $attrib)
49 $config = $RCMAIL->config->all();
53 // General UI settings
55 $table = new html_table(array('cols' => 2));
57 // show language selection
58 if (!isset($no_override['language'])) {
59 $a_lang = $RCMAIL->list_languages();
62 $field_id = 'rcmfd_lang';
63 $select_lang = new html_select(array('name' => '_language', 'id' => $field_id));
64 $select_lang->add(array_values($a_lang), array_keys($a_lang));
66 $table->add('title', html::label($field_id, Q(rcube_label('language'))));
67 $table->add(null, $select_lang->show($RCMAIL->user->language));
70 // show page size selection
71 if (!isset($no_override['timezone'])) {
72 $field_id = 'rcmfd_timezone';
73 $select_timezone = new html_select(array('name' => '_timezone', 'id' => $field_id, 'onchange' => "document.getElementById('rcmfd_dst').disabled=this.selectedIndex==0"));
74 $select_timezone->add(rcube_label('autodetect'), 'auto');
75 $select_timezone->add('(GMT -11:00) Midway Island, Samoa', '-11');
76 $select_timezone->add('(GMT -10:00) Hawaii', '-10');
77 $select_timezone->add('(GMT -9:30) Marquesas Islands', '-9.5');
78 $select_timezone->add('(GMT -9:00) Alaska', '-9');
79 $select_timezone->add('(GMT -8:00) Pacific Time (US/Canada)', '-8');
80 $select_timezone->add('(GMT -7:00) Mountain Time (US/Canada)', '-7');
81 $select_timezone->add('(GMT -6:00) Central Time (US/Canada), Mexico City', '-6');
82 $select_timezone->add('(GMT -5:00) Eastern Time (US/Canada), Bogota, Lima', '-5');
83 $select_timezone->add('(GMT -4:30) Caracas', '-4.5');
84 $select_timezone->add('(GMT -4:00) Atlantic Time (Canada), La Paz', '-4');
85 $select_timezone->add('(GMT -3:30) Nfld Time (Canada), Nfld, S. Labador', '-3.5');
86 $select_timezone->add('(GMT -3:00) Brazil, Buenos Aires, Georgetown', '-3');
87 $select_timezone->add('(GMT -2:00) Mid-Atlantic', '-2');
88 $select_timezone->add('(GMT -1:00) Azores, Cape Verde Islands', '-1');
89 $select_timezone->add('(GMT) Western Europe, London, Lisbon, Casablanca', '0');
90 $select_timezone->add('(GMT +1:00) Central European Time', '1');
91 $select_timezone->add('(GMT +2:00) EET: Tallinn, Helsinki, Kaliningrad, South Africa', '2');
92 $select_timezone->add('(GMT +3:00) Baghdad, Kuwait, Riyadh, Moscow, Nairobi', '3');
93 $select_timezone->add('(GMT +3:30) Tehran', '3.5');
94 $select_timezone->add('(GMT +4:00) Abu Dhabi, Muscat, Baku, Tbilisi', '4');
95 $select_timezone->add('(GMT +4:30) Kabul', '4.5');
96 $select_timezone->add('(GMT +5:00) Ekaterinburg, Islamabad, Karachi', '5');
97 $select_timezone->add('(GMT +5:30) Chennai, Kolkata, Mumbai, New Delhi', '5.5');
98 $select_timezone->add('(GMT +5:45) Kathmandu', '5.75');
99 $select_timezone->add('(GMT +6:00) Almaty, Dhaka, Colombo', '6');
100 $select_timezone->add('(GMT +6:30) Cocos Islands, Myanmar', '6.5');
101 $select_timezone->add('(GMT +7:00) Bangkok, Hanoi, Jakarta', '7');
102 $select_timezone->add('(GMT +8:00) Beijing, Perth, Singapore, Taipei', '8');
103 $select_timezone->add('(GMT +8:45) Caiguna, Eucla, Border Village', '8.75');
104 $select_timezone->add('(GMT +9:00) Tokyo, Seoul, Yakutsk', '9');
105 $select_timezone->add('(GMT +9:30) Adelaide, Darwin', '9.5');
106 $select_timezone->add('(GMT +10:00) EAST/AEST: Sydney, Guam, Vladivostok', '10');
107 $select_timezone->add('(GMT +10:30) New South Wales', '10.5');
108 $select_timezone->add('(GMT +11:00) Magadan, Solomon Islands', '11');
109 $select_timezone->add('(GMT +11:30) Norfolk Island', '11.5');
110 $select_timezone->add('(GMT +12:00) Auckland, Wellington, Kamchatka', '12');
111 $select_timezone->add('(GMT +12:45) Chatham Islands', '12.75');
112 $select_timezone->add('(GMT +13:00) Tonga, Pheonix Islands', '13');
113 $select_timezone->add('(GMT +14:00) Kiribati', '14');
115 $table->add('title', html::label($field_id, Q(rcube_label('timezone'))));
116 $table->add(null, $select_timezone->show((string)$config['timezone']));
120 if (!isset($no_override['dst_active'])) {
121 $field_id = 'rcmfd_dst';
122 $input_dst = new html_checkbox(array('name' => '_dst_active', 'id' => $field_id, 'value' => 1, 'disabled' => ($config['timezone'] === 'auto')));
124 $table->add('title', html::label($field_id, Q(rcube_label('dstactive'))));
125 $table->add(null, $input_dst->show($config['dst_active']));
128 // MM: Show checkbox for toggling 'pretty dates'
129 if (!isset($no_override['prettydate'])) {
130 $field_id = 'rcmfd_prettydate';
131 $input_prettydate = new html_checkbox(array('name' => '_pretty_date', 'id' => $field_id, 'value' => 1));
133 $table->add('title', html::label($field_id, Q(rcube_label('prettydate'))));
134 $table->add(null, $input_prettydate->show($config['prettydate']?1:0));
137 // show page size selection
138 if (!isset($no_override['pagesize'])) {
139 $field_id = 'rcmfd_pgsize';
140 $input_pagesize = new html_inputfield(array('name' => '_pagesize', 'id' => $field_id, 'size' => 5));
142 $table->add('title', html::label($field_id, Q(rcube_label('pagesize'))));
143 $table->add(null, $input_pagesize->show($config['pagesize']));
146 // show drop-down for available skins
147 if (!isset($no_override['skin'])) {
148 $skins = rcmail_get_skins();
150 if (count($skins) > 1) {
151 $field_id = 'rcmfd_skin';
152 $input_skin = new html_select(array('name'=>'_skin', 'id'=>$field_id));
154 foreach($skins as $skin)
155 $input_skin->add($skin, $skin);
157 $table->add('title', html::label($field_id, Q(rcube_label('skin'))));
158 $table->add(null, $input_skin->show($config['skin']));
163 $out = html::tag('fieldset', null, html::tag('legend', null, Q(rcube_label('uisettings'))) . $table->show($attrib));
167 // Mailbox view (mail screen)
169 $table = new html_table(array('cols' => 2));
171 if (!isset($no_override['focus_on_new_message'])) {
172 $field_id = 'rcmfd_focus_on_new_message';
173 $input_focus_on_new_message = new html_checkbox(array('name' => '_focus_on_new_message', 'id' => $field_id, 'value' => 1));
174 $table->add('title', html::label($field_id, Q(rcube_label('focusonnewmessage'))));
175 $table->add(null, $input_focus_on_new_message->show($config['focus_on_new_message']?1:0));
178 // show config parameter for preview pane
179 if (!isset($no_override['preview_pane'])) {
180 $field_id = 'rcmfd_preview';
181 $input_preview = new html_checkbox(array('name' => '_preview_pane', 'id' => $field_id, 'value' => 1));
183 $table->add('title', html::label($field_id, Q(rcube_label('previewpane'))));
184 $table->add(null, $input_preview->show($config['preview_pane']?1:0));
187 if (!isset($no_override['mdn_requests'])) {
188 $field_id = 'rcmfd_mdn_requests';
189 $select_mdn_requests = new html_select(array('name' => '_mdn_requests', 'id' => $field_id));
190 $select_mdn_requests->add(rcube_label('askuser'), 0);
191 $select_mdn_requests->add(rcube_label('autosend'), 1);
192 $select_mdn_requests->add(rcube_label('ignore'), 2);
194 $table->add('title', html::label($field_id, Q(rcube_label('mdnrequests'))));
195 $table->add(null, $select_mdn_requests->show($config['mdn_requests']));
198 if (!isset($no_override['keep_alive'])) {
199 $field_id = 'rcmfd_keep_alive';
200 $select_keep_alive = new html_select(array('name' => '_keep_alive', 'id' => $field_id));
202 foreach(array(1, 3, 5, 10, 15, 30, 60) as $min)
203 if((!$config['min_keep_alive'] || $config['min_keep_alive'] <= $min * 60)
204 && (!$config['session_lifetime'] || $config['session_lifetime'] > $min)) {
205 $select_keep_alive->add(rcube_label(array('name' => 'keepaliveevery', 'vars' => array('n' => $min))), $min);
208 $table->add('title', html::label($field_id, Q(rcube_label('keepalive'))));
209 $table->add(null, $select_keep_alive->show($config['keep_alive']/60));
212 if (!isset($no_override['check_all_folders'])) {
213 $field_id = 'rcmfd_check_all_folders';
214 $input_check_all = new html_checkbox(array('name' => '_check_all_folders', 'id' => $field_id, 'value' => 1));
215 $table->add('title', html::label($field_id, Q(rcube_label('checkallfolders'))));
216 $table->add(null, $input_check_all->show($config['check_all_folders']?1:0));
220 $out = html::tag('fieldset', null, html::tag('legend', null, Q(rcube_label('mailboxview'))) . $table->show($attrib));
226 $table = new html_table(array('cols' => 2));
228 // show checkbox for HTML/plaintext messages
229 if (!isset($no_override['prefer_html'])) {
230 $field_id = 'rcmfd_htmlmsg';
231 $input_preferhtml = new html_checkbox(array('name' => '_prefer_html', 'id' => $field_id, 'value' => 1,
232 'onchange' => JS_OBJECT_NAME.'.toggle_prefer_html(this)'));
234 $table->add('title', html::label($field_id, Q(rcube_label('preferhtml'))));
235 $table->add(null, $input_preferhtml->show($config['prefer_html']?1:0));
238 if (!isset($no_override['show_images'])) {
239 $field_id = 'rcmfd_show_images';
240 $input_show_images = new html_select(array('name' => '_show_images', 'id' => $field_id));
241 $input_show_images->add(rcube_label('never'), 0);
242 $input_show_images->add(rcube_label('fromknownsenders'), 1);
243 $input_show_images->add(rcube_label('always'), 2);
245 $table->add('title', html::label($field_id, Q(rcube_label('showremoteimages'))));
246 $table->add(null, $input_show_images->show($config['show_images']));
249 if (!isset($no_override['inline_images'])) {
250 $field_id = 'rcmfd_inline_images';
251 $input_inline_images = new html_checkbox(array('name' => '_inline_images', 'id' => $field_id, 'value' => 1));
253 $table->add('title', html::label($field_id, Q(rcube_label('showinlineimages'))));
254 $table->add(null, $input_inline_images->show($config['inline_images']?1:0));
258 $out = html::tag('fieldset', null, html::tag('legend', null, Q(rcube_label('messagesdisplaying'))) . $table->show($attrib));
264 $table = new html_table(array('cols' => 2));
266 // Show checkbox for HTML Editor
267 if (!isset($no_override['htmleditor'])) {
268 $field_id = 'rcmfd_htmleditor';
269 $input_htmleditor = new html_checkbox(array('name' => '_htmleditor', 'id' => $field_id, 'value' => 1));
271 $table->add('title', html::label($field_id, Q(rcube_label('htmleditor'))));
272 $table->add(null, $input_htmleditor->show($config['htmleditor']?1:0));
275 if (!isset($no_override['draft_autosave'])) {
276 $field_id = 'rcmfd_autosave';
277 $select_autosave = new html_select(array('name' => '_draft_autosave', 'id' => $field_id, 'disabled' => empty($config['drafts_mbox'])));
278 $select_autosave->add(rcube_label('never'), 0);
279 foreach (array(3, 5, 10) as $i => $min)
280 $select_autosave->add(rcube_label(array('name' => 'everynminutes', 'vars' => array('n' => $min))), $min*60);
282 $table->add('title', html::label($field_id, Q(rcube_label('autosavedraft'))));
283 $table->add(null, $select_autosave->show($config['draft_autosave']));
286 if (!isset($no_override['mime_param_folding'])) {
287 $field_id = 'rcmfd_param_folding';
288 $select_param_folding = new html_select(array('name' => '_mime_param_folding', 'id' => $field_id));
289 $select_param_folding->add(rcube_label('2231folding'), 0);
290 $select_param_folding->add(rcube_label('miscfolding'), 1);
291 $select_param_folding->add(rcube_label('2047folding'), 2);
293 $table->set_row_attribs('advanced');
294 $table->add('title', html::label($field_id, Q(rcube_label('mimeparamfolding'))));
295 $table->add(null, $select_param_folding->show($config['mime_param_folding']));
299 $out = html::tag('fieldset', null, html::tag('legend', null, Q(rcube_label('messagescomposition'))) . $table->show($attrib));
303 // Special IMAP folders
305 // Configure special folders
306 if (!isset($no_override['default_imap_folders'])) {
307 $RCMAIL->imap_init(true);
308 $select = rcmail_mailbox_select(array('noselection' => '---', 'realnames' => true, 'maxlength' => 30));
310 $table = new html_table(array('cols' => 2));
312 if (!isset($no_override['drafts_mbox'])) {
313 $table->add('title', Q(rcube_label('drafts')));
314 $table->add(null, $select->show($config['drafts_mbox'], array('name' => "_drafts_mbox", 'onchange' => "document.getElementById('rcmfd_autosave').disabled=this.selectedIndex==0")));
317 if (!isset($no_override['sent_mbox'])) {
318 $table->add('title', Q(rcube_label('sent')));
319 $table->add(null, $select->show($config['sent_mbox'], array('name' => "_sent_mbox")));
322 if (!isset($no_override['junk_mbox'])) {
323 $table->add('title', Q(rcube_label('junk')));
324 $table->add(null, $select->show($config['junk_mbox'], array('name' => "_junk_mbox")));
327 if (!isset($no_override['trash_mbox'])) {
328 $table->add('title', Q(rcube_label('trash')));
329 $table->add(null, $select->show($config['trash_mbox'], array('name' => "_trash_mbox")));
332 $out = html::tag('fieldset', null, html::tag('legend', null, Q(rcube_label('specialfolders'))) . $table->show($attrib));
339 $table = new html_table(array('cols' => 2));
341 if (!isset($no_override['read_when_deleted'])) {
342 $field_id = 'rcmfd_read_deleted';
343 $input_readdeleted = new html_checkbox(array('name' => '_read_when_deleted', 'id' => $field_id, 'value' => 1));
345 $table->add('title', html::label($field_id, Q(rcube_label('readwhendeleted'))));
346 $table->add(null, $input_readdeleted->show($config['read_when_deleted']?1:0));
349 if (!isset($no_override['flag_for_deletion'])) {
350 $field_id = 'rcmfd_flag_for_deletion';
351 $input_flagfordeletion = new html_checkbox(array('name' => '_flag_for_deletion', 'id' => $field_id, 'value' => 1));
353 $table->add('title', html::label($field_id, Q(rcube_label('flagfordeletion'))));
354 $table->add(null, $input_flagfordeletion->show($config['flag_for_deletion']?1:0));
357 // don't show deleted messages
358 if (!isset($no_override['skip_deleted'])) {
359 $field_id = 'rcmfd_skip_deleted';
360 $input_purge = new html_checkbox(array('name' => '_skip_deleted', 'id' => $field_id, 'value' => 1));
362 $table->add('title', html::label($field_id, Q(rcube_label('skipdeleted'))));
363 $table->add(null, $input_purge->show($config['skip_deleted']?1:0));
366 // Trash purging on logout
367 if (!isset($no_override['logout_purge'])) {
368 $field_id = 'rcmfd_logout_purge';
369 $input_purge = new html_checkbox(array('name' => '_logout_purge', 'id' => $field_id, 'value' => 1));
371 $table->add('title', html::label($field_id, Q(rcube_label('logoutclear'))));
372 $table->add(null, $input_purge->show($config['logout_purge']?1:0));
375 // INBOX compacting on logout
376 if (!isset($no_override['logout_expunge'])) {
377 $field_id = 'rcmfd_logout_expunge';
378 $input_expunge = new html_checkbox(array('name' => '_logout_expunge', 'id' => $field_id, 'value' => 1));
380 $table->add('title', html::label($field_id, Q(rcube_label('logoutcompact'))));
381 $table->add(null, $input_expunge->show($config['logout_expunge']?1:0));
385 $out = html::tag('fieldset', null, html::tag('legend', null, Q(rcube_label('serversettings'))) . $table->show($attrib));
397 function rcmail_identities_list($attrib)
399 global $OUTPUT, $USER;
401 // add id to message list table if not specified
402 if (!strlen($attrib['id']))
403 $attrib['id'] = 'rcmIdentitiesList';
405 // define list of cols to be displayed
406 $a_show_cols = array('name', 'email');
408 // create XHTML table
409 $out = rcube_table_output($attrib, $USER->list_identities(), $a_show_cols, 'identity_id');
412 $OUTPUT->add_gui_object('identitieslist', $attrib['id']);
419 // similar function as in /steps/addressbook/edit.inc
420 function get_form_tags($attrib, $action, $add_hidden=array())
422 global $EDIT_FORM, $RCMAIL;
425 if (!strlen($EDIT_FORM))
427 $hiddenfields = new html_hiddenfield(array('name' => '_task', 'value' => $RCMAIL->task));
428 $hiddenfields->add(array('name' => '_action', 'value' => $action));
431 $hiddenfields->add($add_hidden);
433 $form_start = !strlen($attrib['form']) ? $RCMAIL->output->form_tag(array('name' => "form", 'method' => "post")) : '';
434 $form_start .= $hiddenfields->show();
437 $form_end = (!strlen($EDIT_FORM) && !strlen($attrib['form'])) ? '</form>' : '';
438 $form_name = strlen($attrib['form']) ? $attrib['form'] : 'form';
440 if (!strlen($EDIT_FORM))
441 $RCMAIL->output->add_gui_object('editform', $form_name);
443 $EDIT_FORM = $form_name;
445 return array($form_start, $form_end);
448 function rcmail_get_skins()
453 $dir = opendir($path);
458 while (($file = readdir($dir)) !== false)
460 $filename = $path.'/'.$file;
461 if (is_dir($filename) && is_readable($filename)
462 && !in_array($file, array('.', '..', '.svn')))
472 // register UI objects
473 $OUTPUT->add_handlers(array(
474 'userprefs' => 'rcmail_user_prefs_form',
475 'identitieslist' => 'rcmail_identities_list',
476 'itentitieslist' => 'rcmail_identities_list' // keep this for backward compatibility