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 1255 2008-04-05 12:49:21Z thomasb $
24 $OUTPUT->set_pagetitle(rcube_label('settingsfor') . " ". $USER->get_username());
28 function rcmail_user_prefs_form($attrib)
30 global $DB, $CONFIG, $sess_user_lang;
32 $no_override = is_array($CONFIG['dont_override']) ? array_flip($CONFIG['dont_override']) : array();
34 // add some labels to client
35 rcube_add_label('nopagesizewarning');
37 list($form_start, $form_end) = get_form_tags($attrib, 'save-prefs');
38 unset($attrib['form']);
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'));
43 // return the complete edit form as table
44 $out = "$form_start<table" . $attrib_str . ">\n\n";
46 // show language selection
47 if (!isset($no_override['language']))
49 $a_lang = rcube_list_languages();
52 $field_id = 'rcmfd_lang';
53 $select_lang = new select(array('name' => '_language', 'id' => $field_id));
54 $select_lang->add(array_values($a_lang), array_keys($a_lang));
56 $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n",
58 Q(rcube_label('language')),
59 $select_lang->show($sess_user_lang));
63 // show page size selection
64 if (!isset($no_override['timezone']))
66 $field_id = 'rcmfd_timezone';
67 $select_timezone = new 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');
109 $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n",
111 Q(rcube_label('timezone')),
112 $select_timezone->show((string)$CONFIG['timezone']));
116 if (!isset($no_override['dst_active']))
118 $field_id = 'rcmfd_dst';
119 $input_dst = new 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",
122 Q(rcube_label('dstactive')),
123 $input_dst->show($CONFIG['dst_active']));
126 // show page size selection
127 if (!isset($no_override['pagesize']))
129 $field_id = 'rcmfd_pgsize';
130 $input_pagesize = new textfield(array('name' => '_pagesize', 'id' => $field_id, 'size' => 5));
132 $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n",
134 Q(rcube_label('pagesize')),
135 $input_pagesize->show($CONFIG['pagesize']));
138 // MM: Show checkbox for toggling 'pretty dates'
139 if (!isset($no_override['prettydate']))
141 $field_id = 'rcmfd_prettydate';
142 $input_prettydate = new checkbox(array('name' => '_pretty_date', 'id' => $field_id, 'value' => 1));
144 $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n",
146 Q(rcube_label('prettydate')),
147 $input_prettydate->show($CONFIG['prettydate']?1:0));
150 // show checkbox for HTML/plaintext messages
151 if (!isset($no_override['prefer_html']))
153 $field_id = 'rcmfd_htmlmsg';
154 $input_pagesize = new checkbox(array('name' => '_prefer_html', 'id' => $field_id, 'value' => 1));
156 $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n",
158 Q(rcube_label('preferhtml')),
159 $input_pagesize->show($CONFIG['prefer_html']?1:0));
162 // Show checkbox for HTML Editor
163 if (!isset($no_override['htmleditor']))
165 $field_id = 'rcmfd_htmleditor';
166 $input_htmleditor = new 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",
169 Q(rcube_label('htmleditor')),
170 $input_htmleditor->show($CONFIG['htmleditor']?1:0));
173 // show config parameter for preview pane
174 if (!isset($no_override['preview_pane']))
176 $field_id = 'rcmfd_preview';
177 $input_preview = new 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",
180 Q(rcube_label('previewpane')),
181 $input_preview->show($CONFIG['preview_pane']?1:0));
184 if (!empty($CONFIG['drafts_mbox']) && !isset($no_override['draft_autosave']))
186 $field_id = 'rcmfd_autosave';
187 $select_autosave = new select(array('name' => '_draft_autosave', 'id' => $field_id));
188 $select_autosave->add(rcube_label('never'), 0);
189 foreach (array(3, 5, 10) as $i => $min)
190 $select_autosave->add(rcube_label(array('name' => 'everynminutes', 'vars' => array('n' => $min))), $min*60);
192 $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n",
194 Q(rcube_label('autosavedraft')),
195 $select_autosave->show($CONFIG['draft_autosave']));
198 $out .= "\n</table>$form_end";
205 function rcmail_identities_list($attrib)
207 global $OUTPUT, $USER;
209 // add id to message list table if not specified
210 if (!strlen($attrib['id']))
211 $attrib['id'] = 'rcmIdentitiesList';
213 // define list of cols to be displayed
214 $a_show_cols = array('name', 'email', 'organization', 'reply-to');
216 // create XHTML table
217 $out = rcube_table_output($attrib, $USER->list_identities(), $a_show_cols, 'identity_id');
220 $OUTPUT->add_gui_object('identitieslist', $attrib['id']);
227 // similar function as in /steps/addressbook/edit.inc
228 function get_form_tags($attrib, $action, $add_hidden=array())
230 global $OUTPUT, $EDIT_FORM, $SESS_HIDDEN_FIELD;
233 if (!strlen($EDIT_FORM))
235 $hiddenfields = new hiddenfield(array('name' => '_task', 'value' => $GLOBALS['_task']));
236 $hiddenfields->add(array('name' => '_action', 'value' => $action));
239 $hiddenfields->add($add_hidden);
241 if ($_GET['_framed'] || $_POST['_framed'])
242 $hiddenfields->add(array('name' => '_framed', 'value' => 1));
244 $form_start = !strlen($attrib['form']) ? '<form name="form" action="./" method="post">' : '';
245 $form_start .= "\n$SESS_HIDDEN_FIELD\n";
246 $form_start .= $hiddenfields->show();
249 $form_end = (!strlen($EDIT_FORM) && !strlen($attrib['form'])) ? '</form>' : '';
250 $form_name = strlen($attrib['form']) ? $attrib['form'] : 'form';
252 if (!strlen($EDIT_FORM))
253 $OUTPUT->add_gui_object('editform', $form_name);
255 $EDIT_FORM = $form_name;
257 return array($form_start, $form_end);
261 // register UI objects
262 $OUTPUT->add_handlers(array(
263 'userprefs' => 'rcmail_user_prefs_form',
264 'identitieslist' => 'rcmail_identities_list',
265 'itentitieslist' => 'rcmail_identities_list' // keep this for backward compatibility