]> git.donarmstrong.com Git - roundcube.git/blob - program/steps/settings/func.inc
Imported Upstream version 0.1.1
[roundcube.git] / program / steps / settings / func.inc
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: func.inc 1255 2008-04-05 12:49:21Z thomasb $
19
20 */
21
22
23 if ($USER->ID)
24   $OUTPUT->set_pagetitle(rcube_label('settingsfor') . " ". $USER->get_username());
25
26
27
28 function 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 table
44   $out = "$form_start<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 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 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 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 textfield(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 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 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 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 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   if (!empty($CONFIG['drafts_mbox']) && !isset($no_override['draft_autosave']))
185     {
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);
191
192     $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n",
193                     $field_id,
194                     Q(rcube_label('autosavedraft')),
195                     $select_autosave->show($CONFIG['draft_autosave']));
196     }
197
198   $out .= "\n</table>$form_end";
199
200   return $out;  
201   }
202
203
204
205 function rcmail_identities_list($attrib)
206   {
207   global $OUTPUT, $USER;
208
209   // add id to message list table if not specified
210   if (!strlen($attrib['id']))
211     $attrib['id'] = 'rcmIdentitiesList';
212
213   // define list of cols to be displayed
214   $a_show_cols = array('name', 'email', 'organization', 'reply-to');
215
216   // create XHTML table  
217   $out = rcube_table_output($attrib, $USER->list_identities(), $a_show_cols, 'identity_id');
218   
219   // set client env
220   $OUTPUT->add_gui_object('identitieslist', $attrib['id']);
221
222   return $out;
223   }
224
225
226
227 // similar function as in /steps/addressbook/edit.inc
228 function get_form_tags($attrib, $action, $add_hidden=array())
229   {
230   global $OUTPUT, $EDIT_FORM, $SESS_HIDDEN_FIELD;  
231
232   $form_start = '';
233   if (!strlen($EDIT_FORM))
234     {
235     $hiddenfields = new hiddenfield(array('name' => '_task', 'value' => $GLOBALS['_task']));
236     $hiddenfields->add(array('name' => '_action', 'value' => $action));
237     
238     if ($add_hidden)
239       $hiddenfields->add($add_hidden);
240     
241     if ($_GET['_framed'] || $_POST['_framed'])
242       $hiddenfields->add(array('name' => '_framed', 'value' => 1));
243     
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();
247     }
248     
249   $form_end = (!strlen($EDIT_FORM) && !strlen($attrib['form'])) ? '</form>' : '';
250   $form_name = strlen($attrib['form']) ? $attrib['form'] : 'form';
251
252   if (!strlen($EDIT_FORM))
253     $OUTPUT->add_gui_object('editform', $form_name);
254   
255   $EDIT_FORM = $form_name;
256
257   return array($form_start, $form_end);  
258   }
259
260
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
266 ));
267
268
269 ?>