commit | author | age
|
4e17e6
|
1 |
<?php |
T |
2 |
|
|
3 |
/* |
|
4 |
+-----------------------------------------------------------------------+ |
|
5 |
| program/steps/settings/func.inc | |
|
6 |
| | |
|
7 |
| This file is part of the RoundCube Webmail client | |
|
8 |
| Copyright (C) 2005, RoundCube Dev. - Switzerland | |
30233b
|
9 |
| Licensed under the GNU GPL | |
4e17e6
|
10 |
| | |
T |
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 |
|
|
23 |
// get user record |
d7cb77
|
24 |
$sql_result = $DB->query("SELECT username, mail_host FROM ".get_table_name('users')." |
S |
25 |
WHERE user_id=?", |
|
26 |
$_SESSION['user_id']); |
4e17e6
|
27 |
|
T |
28 |
if ($USER_DATA = $DB->fetch_assoc($sql_result)) |
|
29 |
$PAGE_TITLE = sprintf('%s %s@%s', rcube_label('settingsfor'), $USER_DATA['username'], $USER_DATA['mail_host']); |
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
function rcmail_user_prefs_form($attrib) |
|
34 |
{ |
|
35 |
global $DB, $CONFIG, $sess_user_lang; |
|
36 |
|
b19097
|
37 |
$no_override = is_array($CONFIG['dont_override']) ? array_flip($CONFIG['dont_override']) : array(); |
T |
38 |
|
10a699
|
39 |
// add some labels to client |
T |
40 |
rcube_add_label('nopagesizewarning'); |
|
41 |
|
4e17e6
|
42 |
list($form_start, $form_end) = get_form_tags($attrib, 'save-prefs'); |
T |
43 |
unset($attrib['form']); |
|
44 |
|
|
45 |
// allow the following attributes to be added to the <table> tag |
|
46 |
$attrib_str = create_attrib_string($attrib, array('style', 'class', 'id', 'cellpadding', 'cellspacing', 'border', 'summary')); |
|
47 |
|
|
48 |
// return the complete edit form as table |
|
49 |
$out = "$form_start<table" . $attrib_str . ">\n\n"; |
|
50 |
|
|
51 |
// show language selection |
b19097
|
52 |
if (!isset($no_override['language'])) |
T |
53 |
{ |
|
54 |
$a_lang = rcube_list_languages(); |
|
55 |
asort($a_lang); |
cd900d
|
56 |
|
b19097
|
57 |
$field_id = 'rcmfd_lang'; |
T |
58 |
$select_lang = new select(array('name' => '_language', 'id' => $field_id)); |
|
59 |
$select_lang->add(array_values($a_lang), array_keys($a_lang)); |
cd900d
|
60 |
|
b19097
|
61 |
$out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n", |
T |
62 |
$field_id, |
|
63 |
rep_specialchars_output(rcube_label('language')), |
|
64 |
$select_lang->show($sess_user_lang)); |
|
65 |
} |
4e17e6
|
66 |
|
T |
67 |
|
|
68 |
// show page size selection |
b19097
|
69 |
if (!isset($no_override['timezone'])) |
T |
70 |
{ |
|
71 |
$field_id = 'rcmfd_timezone'; |
|
72 |
$select_timezone = new select(array('name' => '_timezone', 'id' => $field_id)); |
|
73 |
$select_timezone->add('(GMT -11:00) Midway Island, Samoa', '-11'); |
|
74 |
$select_timezone->add('(GMT -10:00) Hawaii', '-10'); |
|
75 |
$select_timezone->add('(GMT -9:00) Alaska', '-9'); |
|
76 |
$select_timezone->add('(GMT -8:00) Pacific Time (US/Canada)', '-8'); |
|
77 |
$select_timezone->add('(GMT -7:00) Mountain Time (US/Canada)', '-7'); |
|
78 |
$select_timezone->add('(GMT -6:00) Central Time (US/Canada), Mexico City', '-6'); |
|
79 |
$select_timezone->add('(GMT -5:00) Eastern Time (US/Canada), Bogota, Lima', '-5'); |
|
80 |
$select_timezone->add('(GMT -4:00) Atlantic Time (Canada), Caracas, La Paz', '-4'); |
|
81 |
$select_timezone->add('(GMT -3:00) Brazil, Buenos Aires, Georgetown', '-3'); |
|
82 |
$select_timezone->add('(GMT -3:30) Nfld Time (Canada), Nfld, S. Labador', '-3.5'); |
|
83 |
$select_timezone->add('(GMT -2:00) Mid-Atlantic', '-2'); |
|
84 |
$select_timezone->add('(GMT -1:00) Azores, Cape Verde Islands', '-1'); |
|
85 |
$select_timezone->add('(GMT) Western Europe, London, Lisbon, Casablanca', '0'); |
|
86 |
$select_timezone->add('(GMT +1:00) Central European Time', '1'); |
|
87 |
$select_timezone->add('(GMT +2:00) EET: Kaliningrad, South Africa', '2'); |
|
88 |
$select_timezone->add('(GMT +3:00) Baghdad, Kuwait, Riyadh, Moscow, Nairobi', '3'); |
|
89 |
$select_timezone->add('(GMT +3:30) Tehran', '3.5'); |
|
90 |
$select_timezone->add('(GMT +4:00) Abu Dhabi, Muscat, Baku, Tbilisi', '4'); |
|
91 |
$select_timezone->add('(GMT +4:30) Kabul', '4.5'); |
|
92 |
$select_timezone->add('(GMT +5:00) Ekaterinburg, Islamabad, Karachi', '5'); |
|
93 |
$select_timezone->add('(GMT +5:30) Chennai, Kolkata, Mumbai, New Delhi', '5.5'); |
|
94 |
$select_timezone->add('(GMT +5:45) Kathmandu', '5.75'); |
|
95 |
$select_timezone->add('(GMT +6:00) Almaty, Dhaka, Colombo', '6'); |
|
96 |
$select_timezone->add('(GMT +7:00) Bangkok, Hanoi, Jakarta', '7'); |
|
97 |
$select_timezone->add('(GMT +8:00) Beijing, Perth, Singapore, Taipei', '8'); |
|
98 |
$select_timezone->add('(GMT +9:00) Tokyo, Seoul, Yakutsk', '9'); |
|
99 |
$select_timezone->add('(GMT +9:30) Adelaide, Darwin', '9.5'); |
|
100 |
$select_timezone->add('(GMT +10:00) EAST/AEST: Guam, Vladivostok', '10'); |
|
101 |
$select_timezone->add('(GMT +11:00) Magadan, Solomon Islands', '11'); |
|
102 |
$select_timezone->add('(GMT +12:00) Auckland, Wellington, Kamchatka', '12'); |
|
103 |
$select_timezone->add('(GMT +13:00) Tonga, Pheonix Islands', '13'); |
|
104 |
$select_timezone->add('(GMT +14:00) Kiribati', '14'); |
4e17e6
|
105 |
|
T |
106 |
|
b19097
|
107 |
$out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n", |
T |
108 |
$field_id, |
|
109 |
rep_specialchars_output(rcube_label('timezone')), |
|
110 |
$select_timezone->show($CONFIG['timezone'])); |
|
111 |
} |
4e17e6
|
112 |
|
b19097
|
113 |
// daylight savings |
T |
114 |
if (!isset($no_override['dst_active'])) |
|
115 |
{ |
|
116 |
$field_id = 'rcmfd_dst'; |
|
117 |
$input_dst = new 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 |
rep_specialchars_output(rcube_label('dstactive')), |
|
121 |
$input_dst->show($CONFIG['dst_active'])); |
|
122 |
} |
4647e1
|
123 |
|
4e17e6
|
124 |
// show page size selection |
b19097
|
125 |
if (!isset($no_override['pagesize'])) |
T |
126 |
{ |
|
127 |
$field_id = 'rcmfd_pgsize'; |
|
128 |
$input_pagesize = new textfield(array('name' => '_pagesize', 'id' => $field_id, 'size' => 5)); |
4e17e6
|
129 |
|
b19097
|
130 |
$out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n", |
T |
131 |
$field_id, |
|
132 |
rep_specialchars_output(rcube_label('pagesize')), |
|
133 |
$input_pagesize->show($CONFIG['pagesize'])); |
|
134 |
} |
4e17e6
|
135 |
|
30233b
|
136 |
// MM: Show checkbox for toggling 'pretty dates' |
b19097
|
137 |
if (!isset($no_override['prettydate'])) |
T |
138 |
{ |
|
139 |
$field_id = 'rcmfd_prettydate'; |
|
140 |
$input_prettydate = new checkbox(array('name' => '_pretty_date', 'id' => $field_id, 'value' => 1)); |
30233b
|
141 |
|
b19097
|
142 |
$out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n", |
T |
143 |
$field_id, |
|
144 |
rep_specialchars_output(rcube_label('prettydate')), |
|
145 |
$input_prettydate->show($CONFIG['prettydate']?1:0)); |
|
146 |
} |
|
147 |
|
|
148 |
// show checkbox for HTML/plaintext messages |
|
149 |
if (!isset($no_override['prefer_html'])) |
|
150 |
{ |
|
151 |
$field_id = 'rcmfd_htmlmsg'; |
|
152 |
$input_pagesize = new checkbox(array('name' => '_prefer_html', 'id' => $field_id, 'value' => 1)); |
|
153 |
|
|
154 |
$out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n", |
|
155 |
$field_id, |
|
156 |
rep_specialchars_output(rcube_label('preferhtml')), |
|
157 |
$input_pagesize->show($CONFIG['prefer_html']?1:0)); |
|
158 |
} |
30233b
|
159 |
|
a0109c
|
160 |
// Show checkbox for HTML Editor |
b19097
|
161 |
if (!isset($no_override['htmleditor'])) |
T |
162 |
{ |
|
163 |
$field_id = 'rcmfd_htmleditor'; |
|
164 |
$input_htmleditor = new checkbox(array('name' => '_htmleditor', 'id' => $field_id, 'value' => 1)); |
|
165 |
$out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n", |
|
166 |
$field_id, |
|
167 |
rep_specialchars_output(rcube_label('htmleditor')), |
|
168 |
$input_htmleditor->show($CONFIG['htmleditor']?1:0)); |
|
169 |
} |
a0109c
|
170 |
|
b19097
|
171 |
// show config parameter for preview pane |
T |
172 |
if (!isset($no_override['preview_pane'])) |
|
173 |
{ |
|
174 |
$field_id = 'rcmfd_preview'; |
|
175 |
$input_preview = new checkbox(array('name' => '_preview_pane', 'id' => $field_id, 'value' => 1)); |
|
176 |
$out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n", |
|
177 |
$field_id, |
|
178 |
rep_specialchars_output(rcube_label('previewpane')), |
|
179 |
$input_preview->show($CONFIG['preview_pane']?1:0)); |
|
180 |
} |
|
181 |
|
166796
|
182 |
if (!empty($CONFIG['drafts_mbox']) && !isset($no_override['draft_autosave'])) |
d656f1
|
183 |
{ |
T |
184 |
$field_id = 'rcmfd_autosave'; |
|
185 |
$select_autosave = new select(array('name' => '_draft_autosave', 'id' => $field_id)); |
|
186 |
$select_autosave->add(rcube_label('never'), 0); |
|
187 |
foreach (array(3, 5, 10) as $i => $min) |
|
188 |
$select_autosave->add(rcube_label(array('name' => 'everynminutes', 'vars' => array('n' => $min))), $min*60); |
|
189 |
|
|
190 |
$out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n", |
|
191 |
$field_id, |
|
192 |
rep_specialchars_output(rcube_label('autosavedraft')), |
|
193 |
$select_autosave->show($CONFIG['draft_autosave'])); |
|
194 |
} |
4e17e6
|
195 |
|
T |
196 |
$out .= "\n</table>$form_end"; |
|
197 |
|
|
198 |
return $out; |
|
199 |
} |
|
200 |
|
|
201 |
|
|
202 |
|
|
203 |
function rcmail_identities_list($attrib) |
|
204 |
{ |
|
205 |
global $DB, $CONFIG, $OUTPUT, $JS_OBJECT_NAME; |
|
206 |
|
|
207 |
|
|
208 |
// get contacts from DB |
d7cb77
|
209 |
$sql_result = $DB->query("SELECT * FROM ".get_table_name('identities')." |
1cded8
|
210 |
WHERE del<>1 |
d7cb77
|
211 |
AND user_id=? |
1cded8
|
212 |
ORDER BY standard DESC, name ASC", |
d7cb77
|
213 |
$_SESSION['user_id']); |
4e17e6
|
214 |
|
T |
215 |
|
|
216 |
// add id to message list table if not specified |
|
217 |
if (!strlen($attrib['id'])) |
|
218 |
$attrib['id'] = 'rcmIdentitiesList'; |
|
219 |
|
|
220 |
// define list of cols to be displayed |
|
221 |
$a_show_cols = array('name', 'email', 'organization', 'reply-to'); |
|
222 |
|
|
223 |
// create XHTML table |
|
224 |
$out = rcube_table_output($attrib, $sql_result, $a_show_cols, 'identity_id'); |
|
225 |
|
|
226 |
// set client env |
|
227 |
$javascript = sprintf("%s.gui_object('identitieslist', '%s');\n", $JS_OBJECT_NAME, $attrib['id']); |
|
228 |
$OUTPUT->add_script($javascript); |
|
229 |
|
|
230 |
return $out; |
|
231 |
} |
|
232 |
|
|
233 |
|
|
234 |
|
|
235 |
// similar function as in /steps/addressbook/edit.inc |
|
236 |
function get_form_tags($attrib, $action, $add_hidden=array()) |
|
237 |
{ |
|
238 |
global $OUTPUT, $JS_OBJECT_NAME, $EDIT_FORM, $SESS_HIDDEN_FIELD; |
|
239 |
|
|
240 |
$form_start = ''; |
|
241 |
if (!strlen($EDIT_FORM)) |
|
242 |
{ |
|
243 |
$hiddenfields = new hiddenfield(array('name' => '_task', 'value' => $GLOBALS['_task'])); |
|
244 |
$hiddenfields->add(array('name' => '_action', 'value' => $action)); |
|
245 |
|
|
246 |
if ($add_hidden) |
|
247 |
$hiddenfields->add($add_hidden); |
|
248 |
|
|
249 |
if ($_GET['_framed'] || $_POST['_framed']) |
|
250 |
$hiddenfields->add(array('name' => '_framed', 'value' => 1)); |
|
251 |
|
|
252 |
$form_start = !strlen($attrib['form']) ? '<form name="form" action="./" method="post">' : ''; |
|
253 |
$form_start .= "\n$SESS_HIDDEN_FIELD\n"; |
|
254 |
$form_start .= $hiddenfields->show(); |
|
255 |
} |
|
256 |
|
|
257 |
$form_end = (!strlen($EDIT_FORM) && !strlen($attrib['form'])) ? '</form>' : ''; |
|
258 |
$form_name = strlen($attrib['form']) ? $attrib['form'] : 'form'; |
|
259 |
|
|
260 |
if (!strlen($EDIT_FORM)) |
|
261 |
$OUTPUT->add_script("$JS_OBJECT_NAME.gui_object('editform', '$form_name');"); |
|
262 |
|
|
263 |
$EDIT_FORM = $form_name; |
|
264 |
|
|
265 |
return array($form_start, $form_end); |
|
266 |
} |
|
267 |
|
|
268 |
|
|
269 |
?> |