Mercurial > hg > rc2
comparison program/steps/settings/func.inc @ 0:4681f974d28b
vanilla 1.3.3 distro, I hope
author | Charlie Root |
---|---|
date | Thu, 04 Jan 2018 15:52:31 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4681f974d28b |
---|---|
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-2013, The Roundcube Dev Team | | |
9 | | | |
10 | Licensed under the GNU General Public License version 3 or | | |
11 | any later version with exceptions for skins & plugins. | | |
12 | See the README file for a full license statement. | | |
13 | | | |
14 | PURPOSE: | | |
15 | Provide functionality for user's settings & preferences | | |
16 | | | |
17 +-----------------------------------------------------------------------+ | |
18 | Author: Thomas Bruederli <roundcube@gmail.com> | | |
19 +-----------------------------------------------------------------------+ | |
20 */ | |
21 | |
22 if (!$OUTPUT->ajax_call) { | |
23 $OUTPUT->set_pagetitle($RCMAIL->gettext('preferences')); | |
24 } | |
25 | |
26 // register UI objects | |
27 $OUTPUT->add_handlers(array( | |
28 'settingstabs' => 'rcmail_settings_tabs', | |
29 'prefsframe' => 'rcmail_preferences_frame', | |
30 'sectionslist' => 'rcmail_sections_list', | |
31 'identitieslist' => 'rcmail_identities_list', | |
32 )); | |
33 | |
34 // register action aliases | |
35 $RCMAIL->register_action_map(array( | |
36 'folders' => 'folders.inc', | |
37 'rename-folder' => 'folders.inc', | |
38 'delete-folder' => 'folders.inc', | |
39 'subscribe' => 'folders.inc', | |
40 'unsubscribe' => 'folders.inc', | |
41 'purge' => 'folders.inc', | |
42 'folder-size' => 'folders.inc', | |
43 'add-identity' => 'edit_identity.inc', | |
44 'add-response' => 'edit_response.inc', | |
45 'save-response' => 'edit_response.inc', | |
46 'delete-response' => 'responses.inc', | |
47 'delete-identity' => 'identities.inc', | |
48 'upload-display' => 'upload.inc', | |
49 )); | |
50 | |
51 | |
52 // similar function as /steps/settings/identities.inc::rcmail_identity_frame() | |
53 function rcmail_preferences_frame($attrib) | |
54 { | |
55 global $OUTPUT; | |
56 | |
57 if (!$attrib['id']) { | |
58 $attrib['id'] = 'rcmprefsframe'; | |
59 } | |
60 | |
61 return $OUTPUT->frame($attrib, true); | |
62 } | |
63 | |
64 | |
65 function rcmail_sections_list($attrib) | |
66 { | |
67 global $RCMAIL; | |
68 | |
69 // add id to message list table if not specified | |
70 if (!strlen($attrib['id'])) { | |
71 $attrib['id'] = 'rcmsectionslist'; | |
72 } | |
73 | |
74 list($list, $cols) = rcmail_user_prefs(); | |
75 | |
76 // create XHTML table | |
77 $out = $RCMAIL->table_output($attrib, $list, $cols, 'id'); | |
78 | |
79 // set client env | |
80 $RCMAIL->output->add_gui_object('sectionslist', $attrib['id']); | |
81 $RCMAIL->output->include_script('list.js'); | |
82 | |
83 return $out; | |
84 } | |
85 | |
86 | |
87 function rcmail_identities_list($attrib) | |
88 { | |
89 global $OUTPUT, $RCMAIL; | |
90 | |
91 // add id to message list table if not specified | |
92 if (!strlen($attrib['id'])) { | |
93 $attrib['id'] = 'rcmIdentitiesList'; | |
94 } | |
95 | |
96 // get identities list and define 'mail' column | |
97 $list = $RCMAIL->user->list_emails(); | |
98 foreach ($list as $idx => $row) { | |
99 $list[$idx]['mail'] = trim($row['name'] . ' <' . rcube_utils::idn_to_utf8($row['email']) . '>'); | |
100 } | |
101 | |
102 // get all identites from DB and define list of cols to be displayed | |
103 $plugin = $RCMAIL->plugins->exec_hook('identities_list', array( | |
104 'list' => $list, | |
105 'cols' => array('mail') | |
106 )); | |
107 | |
108 // @TODO: use <UL> instead of <TABLE> for identities list | |
109 // create XHTML table | |
110 $out = $RCMAIL->table_output($attrib, $plugin['list'], $plugin['cols'], 'identity_id'); | |
111 | |
112 // set client env | |
113 $OUTPUT->add_gui_object('identitieslist', $attrib['id']); | |
114 | |
115 return $out; | |
116 } | |
117 | |
118 | |
119 // similar function as in /steps/addressbook/edit.inc | |
120 function get_form_tags($attrib, $action, $id = null, $hidden = null) | |
121 { | |
122 global $EDIT_FORM, $RCMAIL; | |
123 | |
124 $form_start = $form_end = ''; | |
125 | |
126 if (empty($EDIT_FORM)) { | |
127 $request_key = $action . (isset($id) ? '.'.$id : ''); | |
128 $form_start = $RCMAIL->output->request_form(array( | |
129 'name' => 'form', | |
130 'method' => 'post', | |
131 'task' => $RCMAIL->task, | |
132 'action' => $action, | |
133 'request' => $request_key, | |
134 'noclose' => true | |
135 ) + $attrib); | |
136 | |
137 if (is_array($hidden)) { | |
138 $hiddenfields = new html_hiddenfield($hidden); | |
139 $form_start .= $hiddenfields->show(); | |
140 } | |
141 | |
142 $form_end = !strlen($attrib['form']) ? '</form>' : ''; | |
143 | |
144 $EDIT_FORM = !empty($attrib['form']) ? $attrib['form'] : 'form'; | |
145 $RCMAIL->output->add_gui_object('editform', $EDIT_FORM); | |
146 } | |
147 | |
148 return array($form_start, $form_end); | |
149 } | |
150 | |
151 | |
152 function rcmail_user_prefs($current = null) | |
153 { | |
154 global $RCMAIL; | |
155 | |
156 $sections['general'] = array('id' => 'general', 'section' => $RCMAIL->gettext('uisettings')); | |
157 $sections['mailbox'] = array('id' => 'mailbox', 'section' => $RCMAIL->gettext('mailboxview')); | |
158 $sections['mailview'] = array('id' => 'mailview','section' => $RCMAIL->gettext('messagesdisplaying')); | |
159 $sections['compose'] = array('id' => 'compose', 'section' => $RCMAIL->gettext('messagescomposition')); | |
160 $sections['addressbook'] = array('id' => 'addressbook','section' => $RCMAIL->gettext('contacts')); | |
161 $sections['folders'] = array('id' => 'folders', 'section' => $RCMAIL->gettext('specialfolders')); | |
162 $sections['server'] = array('id' => 'server', 'section' => $RCMAIL->gettext('serversettings')); | |
163 | |
164 // hook + define list cols | |
165 $plugin = $RCMAIL->plugins->exec_hook('preferences_sections_list', | |
166 array('list' => $sections, 'cols' => array('section'))); | |
167 | |
168 $sections = $plugin['list']; | |
169 $config = $RCMAIL->config->all(); | |
170 $no_override = array_flip((array)$RCMAIL->config->get('dont_override')); | |
171 | |
172 foreach ($sections as $idx => $sect) { | |
173 $sections[$idx]['class'] = $idx; | |
174 | |
175 if ($current && $sect['id'] != $current) { | |
176 continue; | |
177 } | |
178 | |
179 $blocks = array(); | |
180 | |
181 switch ($sect['id']) { | |
182 | |
183 // general | |
184 case 'general': | |
185 $blocks = array( | |
186 'main' => array('name' => rcube::Q($RCMAIL->gettext('mainoptions'))), | |
187 'skin' => array('name' => rcube::Q($RCMAIL->gettext('skin'))), | |
188 'browser' => array('name' => rcube::Q($RCMAIL->gettext('browseroptions'))), | |
189 'advanced'=> array('name' => rcube::Q($RCMAIL->gettext('advancedoptions'))), | |
190 ); | |
191 | |
192 // language selection | |
193 if (!isset($no_override['language'])) { | |
194 if (!$current) { | |
195 continue 2; | |
196 } | |
197 | |
198 $a_lang = $RCMAIL->list_languages(); | |
199 asort($a_lang); | |
200 | |
201 $field_id = 'rcmfd_lang'; | |
202 $select = new html_select(array('name' => '_language', 'id' => $field_id)); | |
203 $select->add(array_values($a_lang), array_keys($a_lang)); | |
204 | |
205 $blocks['main']['options']['language'] = array( | |
206 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('language'))), | |
207 'content' => $select->show($RCMAIL->user->language), | |
208 ); | |
209 } | |
210 | |
211 // timezone selection | |
212 if (!isset($no_override['timezone'])) { | |
213 if (!$current) { | |
214 continue 2; | |
215 } | |
216 | |
217 $field_id = 'rcmfd_timezone'; | |
218 $select = new html_select(array('name' => '_timezone', 'id' => $field_id)); | |
219 $select->add($RCMAIL->gettext('autodetect'), 'auto'); | |
220 | |
221 $zones = array(); | |
222 foreach (DateTimeZone::listIdentifiers() as $i => $tzs) { | |
223 try { | |
224 $tz = new DateTimeZone($tzs); | |
225 $date = new DateTime(date('Y') . '-12-21', $tz); | |
226 $offset = $date->format('Z') + 45000; | |
227 $sortkey = sprintf('%06d.%s', $offset, $tzs); | |
228 $zones[$sortkey] = array($tzs, $date->format('P')); | |
229 } | |
230 catch (Exception $e) {} | |
231 } | |
232 | |
233 ksort($zones); | |
234 | |
235 foreach ($zones as $zone) { | |
236 list($tzs, $offset) = $zone; | |
237 $select->add('(GMT ' . $offset . ') ' . strtr($tzs, '_', ' '), $tzs); | |
238 } | |
239 | |
240 $blocks['main']['options']['timezone'] = array( | |
241 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('timezone'))), | |
242 'content' => $select->show((string)$config['timezone']), | |
243 ); | |
244 } | |
245 | |
246 // date/time formatting | |
247 if (!isset($no_override['time_format'])) { | |
248 if (!$current) { | |
249 continue 2; | |
250 } | |
251 | |
252 $reftime = mktime(7,30,0); | |
253 $defaults = array('G:i', 'H:i', 'g:i a', 'h:i A'); | |
254 $formats = (array)$RCMAIL->config->get('time_formats', $defaults); | |
255 $field_id = 'rcmfd_time_format'; | |
256 $select = new html_select(array('name' => '_time_format', 'id' => $field_id)); | |
257 | |
258 foreach ($formats as $choice) { | |
259 $select->add(date($choice, $reftime), $choice); | |
260 } | |
261 | |
262 $blocks['main']['options']['time_format'] = array( | |
263 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('timeformat'))), | |
264 'content' => $select->show($RCMAIL->config->get('time_format')), | |
265 ); | |
266 } | |
267 | |
268 if (!isset($no_override['date_format'])) { | |
269 if (!$current) { | |
270 continue 2; | |
271 } | |
272 | |
273 $refdate = mktime(12,30,0,7,24); | |
274 $defaults = array('Y-m-d','d-m-Y','Y/m/d','m/d/Y','d/m/Y','d.m.Y','j.n.Y'); | |
275 $formats = (array)$RCMAIL->config->get('date_formats', $defaults); | |
276 $field_id = 'rcmfd_date_format'; | |
277 $select = new html_select(array('name' => '_date_format', 'id' => $field_id)); | |
278 | |
279 foreach ($formats as $choice) { | |
280 $select->add(date($choice, $refdate), $choice); | |
281 } | |
282 | |
283 $blocks['main']['options']['date_format'] = array( | |
284 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('dateformat'))), | |
285 'content' => $select->show($config['date_format']), | |
286 ); | |
287 } | |
288 | |
289 // Show checkbox for toggling 'pretty dates' | |
290 if (!isset($no_override['prettydate'])) { | |
291 if (!$current) { | |
292 continue 2; | |
293 } | |
294 | |
295 $field_id = 'rcmfd_prettydate'; | |
296 $input = new html_checkbox(array('name' => '_pretty_date', 'id' => $field_id, 'value' => 1)); | |
297 | |
298 $blocks['main']['options']['prettydate'] = array( | |
299 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('prettydate'))), | |
300 'content' => $input->show($config['prettydate']?1:0), | |
301 ); | |
302 } | |
303 | |
304 if (!isset($no_override['refresh_interval'])) { | |
305 if (!$current) { | |
306 continue 2; | |
307 } | |
308 | |
309 $field_id = 'rcmfd_refresh_interval'; | |
310 $select = new html_select(array('name' => '_refresh_interval', 'id' => $field_id)); | |
311 | |
312 $select->add($RCMAIL->gettext('never'), 0); | |
313 foreach (array(1, 3, 5, 10, 15, 30, 60) as $min) { | |
314 if (!$config['min_refresh_interval'] || $config['min_refresh_interval'] <= $min * 60) { | |
315 $label = $RCMAIL->gettext(array('name' => 'everynminutes', 'vars' => array('n' => $min))); | |
316 $select->add($label, $min); | |
317 } | |
318 } | |
319 | |
320 $blocks['main']['options']['refresh_interval'] = array( | |
321 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('refreshinterval'))), | |
322 'content' => $select->show($config['refresh_interval']/60), | |
323 ); | |
324 } | |
325 | |
326 // show drop-down for available skins | |
327 if (!isset($no_override['skin'])) { | |
328 if (!$current) { | |
329 continue 2; | |
330 } | |
331 | |
332 $skins = rcmail_get_skins(); | |
333 | |
334 if (count($skins) > 1) { | |
335 $field_id = 'rcmfd_skin'; | |
336 $input = new html_radiobutton(array('name'=>'_skin')); | |
337 | |
338 foreach ($skins as $skin) { | |
339 $thumbnail = "skins/$skin/thumbnail.png"; | |
340 $skinname = ucfirst($skin); | |
341 $author_link = $license_link = ''; | |
342 $meta = @json_decode(@file_get_contents(INSTALL_PATH . "skins/$skin/meta.json"), true); | |
343 | |
344 if (is_array($meta) && $meta['name']) { | |
345 $skinname = $meta['name']; | |
346 $author_link = $meta['url'] ? html::a(array('href' => $meta['url'], 'target' => '_blank'), rcube::Q($meta['author'])) : rcube::Q($meta['author']); | |
347 $license_link = $meta['license-url'] ? html::a(array('href' => $meta['license-url'], 'target' => '_blank', 'tabindex' => '-1'), rcube::Q($meta['license'])) : rcube::Q($meta['license']); | |
348 } | |
349 | |
350 $img = html::img(array( | |
351 'src' => $thumbnail, | |
352 'class' => 'skinthumbnail', | |
353 'alt' => $skin, | |
354 'width' => 64, | |
355 'height' => 64, | |
356 'onerror' => "this.src = rcmail.assets_path('program/resources/blank.gif')", | |
357 )); | |
358 | |
359 $skinnames[] = mb_strtolower($skinname); | |
360 $blocks['skin']['options'][$skin]['content'] = html::label(array('class' => 'skinselection'), | |
361 html::span('skinitem', $input->show($config['skin'], array('value' => $skin, 'id' => $field_id.$skin))) . | |
362 html::span('skinitem', $img) . | |
363 html::span('skinitem', html::span('skinname', rcube::Q($skinname)) . html::br() . | |
364 html::span('skinauthor', $author_link ? 'by ' . $author_link : '') . html::br() . | |
365 html::span('skinlicense', $license_link ? $RCMAIL->gettext('license').': ' . $license_link : '')) | |
366 ); | |
367 } | |
368 array_multisort($blocks['skin']['options'], SORT_ASC, SORT_STRING, $skinnames); | |
369 } | |
370 } | |
371 | |
372 // standard_windows option decides if new windows should be | |
373 // opened as popups or standard windows (which can be handled by browsers as tabs) | |
374 if (!isset($no_override['standard_windows'])) { | |
375 if (!$current) { | |
376 continue 2; | |
377 } | |
378 | |
379 $field_id = 'rcmfd_standard_windows'; | |
380 $checkbox = new html_checkbox(array('name' => '_standard_windows', 'id' => $field_id, 'value' => 1)); | |
381 | |
382 $blocks['browser']['options']['standard_windows'] = array( | |
383 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('standardwindows'))), | |
384 'content' => $checkbox->show($config['standard_windows']?1:0), | |
385 ); | |
386 } | |
387 | |
388 if ($current) { | |
389 $product_name = $RCMAIL->config->get('product_name', 'Roundcube Webmail'); | |
390 $RCMAIL->output->add_script(sprintf("%s.check_protocol_handler('%s', '#mailtoprotohandler');", | |
391 rcmail_output::JS_OBJECT_NAME, rcube::JQ($product_name)), 'docready'); | |
392 } | |
393 | |
394 $blocks['browser']['options']['mailtoprotohandler'] = array( | |
395 'content' => html::a(array( | |
396 'href' => '#', | |
397 'id' => 'mailtoprotohandler' | |
398 ), | |
399 rcube::Q($RCMAIL->gettext('mailtoprotohandler'))) . | |
400 html::span('mailtoprotohandler-status', ''), | |
401 ); | |
402 | |
403 break; | |
404 | |
405 // Mailbox view (mail screen) | |
406 case 'mailbox': | |
407 $blocks = array( | |
408 'main' => array('name' => rcube::Q($RCMAIL->gettext('mainoptions'))), | |
409 'new_message' => array('name' => rcube::Q($RCMAIL->gettext('newmessage'))), | |
410 'advanced' => array('name' => rcube::Q($RCMAIL->gettext('advancedoptions'))), | |
411 ); | |
412 | |
413 if (!isset($no_override['layout'])) { | |
414 if (!$current) { | |
415 continue 2; | |
416 } | |
417 | |
418 $field_id = 'rcmfd_layout'; | |
419 $select = new html_select(array('name' => '_layout', 'id' => $field_id)); | |
420 | |
421 $select->add($RCMAIL->gettext('layoutwidescreendesc'), 'widescreen'); | |
422 $select->add($RCMAIL->gettext('layoutdesktopdesc'), 'desktop'); | |
423 $select->add($RCMAIL->gettext('layoutlistdesc'), 'list'); | |
424 | |
425 $blocks['main']['options']['layout'] = array( | |
426 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('layout'))), | |
427 'content' => $select->show($config['layout'] ?: 'widescreen'), | |
428 ); | |
429 } | |
430 | |
431 // show config parameter for auto marking the previewed message as read | |
432 if (!isset($no_override['mail_read_time'])) { | |
433 if (!$current) { | |
434 continue 2; | |
435 } | |
436 | |
437 // apply default if config option is not set at all | |
438 $config['mail_read_time'] = intval($RCMAIL->config->get('mail_read_time')); | |
439 | |
440 $field_id = 'rcmfd_mail_read_time'; | |
441 $select = new html_select(array('name' => '_mail_read_time', 'id' => $field_id)); | |
442 | |
443 $select->add($RCMAIL->gettext('never'), -1); | |
444 $select->add($RCMAIL->gettext('immediately'), 0); | |
445 | |
446 foreach (array(5, 10, 20, 30) as $sec) { | |
447 $label = $RCMAIL->gettext(array('name' => 'afternseconds', 'vars' => array('n' => $sec))); | |
448 $select->add($label, $sec); | |
449 } | |
450 | |
451 $blocks['main']['options']['mail_read_time'] = array( | |
452 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('automarkread'))), | |
453 'content' => $select->show($config['mail_read_time']), | |
454 ); | |
455 } | |
456 | |
457 if (!isset($no_override['mdn_requests'])) { | |
458 if (!$current) { | |
459 continue 2; | |
460 } | |
461 | |
462 $field_id = 'rcmfd_mdn_requests'; | |
463 $select = new html_select(array('name' => '_mdn_requests', 'id' => $field_id)); | |
464 $select->add($RCMAIL->gettext('askuser'), 0); | |
465 $select->add($RCMAIL->gettext('autosend'), 1); | |
466 $select->add($RCMAIL->gettext('autosendknown'), 3); | |
467 $select->add($RCMAIL->gettext('autosendknownignore'), 4); | |
468 $select->add($RCMAIL->gettext('ignorerequest'), 2); | |
469 | |
470 $blocks['main']['options']['mdn_requests'] = array( | |
471 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('mdnrequests'))), | |
472 'content' => $select->show($config['mdn_requests']), | |
473 ); | |
474 } | |
475 | |
476 if (!isset($no_override['autoexpand_threads'])) { | |
477 if (!$current) { | |
478 continue 2; | |
479 } | |
480 | |
481 $storage = $RCMAIL->get_storage(); | |
482 $supported = $storage->get_capability('THREAD'); | |
483 | |
484 if ($supported) { | |
485 $field_id = 'rcmfd_autoexpand_threads'; | |
486 $select = new html_select(array('name' => '_autoexpand_threads', 'id' => $field_id)); | |
487 $select->add($RCMAIL->gettext('never'), 0); | |
488 $select->add($RCMAIL->gettext('do_expand'), 1); | |
489 $select->add($RCMAIL->gettext('expand_only_unread'), 2); | |
490 | |
491 $blocks['main']['options']['autoexpand_threads'] = array( | |
492 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('autoexpand_threads'))), | |
493 'content' => $select->show($config['autoexpand_threads']), | |
494 ); | |
495 } | |
496 } | |
497 | |
498 // show page size selection | |
499 if (!isset($no_override['mail_pagesize'])) { | |
500 if (!$current) { | |
501 continue 2; | |
502 } | |
503 | |
504 $field_id = 'rcmfd_mail_pagesize'; | |
505 $input = new html_inputfield(array('name' => '_mail_pagesize', 'id' => $field_id, 'size' => 5)); | |
506 $size = intval($config['mail_pagesize'] ?: $config['pagesize']); | |
507 | |
508 $blocks['main']['options']['pagesize'] = array( | |
509 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('pagesize'))), | |
510 'content' => $input->show($size ?: 50), | |
511 ); | |
512 } | |
513 | |
514 if (!isset($no_override['check_all_folders'])) { | |
515 if (!$current) { | |
516 continue 2; | |
517 } | |
518 | |
519 $field_id = 'rcmfd_check_all_folders'; | |
520 $input = new html_checkbox(array('name' => '_check_all_folders', 'id' => $field_id, 'value' => 1)); | |
521 | |
522 $blocks['new_message']['options']['check_all_folders'] = array( | |
523 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('checkallfolders'))), | |
524 'content' => $input->show($config['check_all_folders']?1:0), | |
525 ); | |
526 } | |
527 break; | |
528 | |
529 // Message viewing | |
530 case 'mailview': | |
531 $blocks = array( | |
532 'main' => array('name' => rcube::Q($RCMAIL->gettext('mainoptions'))), | |
533 'advanced' => array('name' => rcube::Q($RCMAIL->gettext('advancedoptions'))), | |
534 ); | |
535 | |
536 // show checkbox to open message view in new window | |
537 if (!isset($no_override['message_extwin'])) { | |
538 if (!$current) { | |
539 continue 2; | |
540 } | |
541 | |
542 $field_id = 'rcmfd_message_extwin'; | |
543 $input = new html_checkbox(array('name' => '_message_extwin', 'id' => $field_id, 'value' => 1)); | |
544 | |
545 $blocks['main']['options']['message_extwin'] = array( | |
546 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('showinextwin'))), | |
547 'content' => $input->show($config['message_extwin']?1:0), | |
548 ); | |
549 } | |
550 | |
551 // show checkbox to show email instead of name | |
552 if (!isset($no_override['message_show_email'])) { | |
553 if (!$current) { | |
554 continue 2; | |
555 } | |
556 | |
557 $field_id = 'rcmfd_message_show_email'; | |
558 $input = new html_checkbox(array('name' => '_message_show_email', 'id' => $field_id, 'value' => 1)); | |
559 | |
560 $blocks['main']['options']['message_show_email'] = array( | |
561 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('showemail'))), | |
562 'content' => $input->show($config['message_show_email']?1:0), | |
563 ); | |
564 } | |
565 | |
566 // show checkbox for HTML/plaintext messages | |
567 if (!isset($no_override['prefer_html'])) { | |
568 if (!$current) { | |
569 continue 2; | |
570 } | |
571 | |
572 $field_id = 'rcmfd_htmlmsg'; | |
573 $input = new html_checkbox(array('name' => '_prefer_html', 'id' => $field_id, 'value' => 1, | |
574 'onchange' => "$('#rcmfd_show_images').prop('disabled', !this.checked).val(0)")); | |
575 | |
576 $blocks['main']['options']['prefer_html'] = array( | |
577 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('preferhtml'))), | |
578 'content' => $input->show($config['prefer_html']?1:0), | |
579 ); | |
580 } | |
581 | |
582 if (!isset($no_override['default_charset'])) { | |
583 if (!$current) { | |
584 continue 2; | |
585 } | |
586 | |
587 $field_id = 'rcmfd_default_charset'; | |
588 | |
589 $blocks['advanced']['options']['default_charset'] = array( | |
590 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('defaultcharset'))), | |
591 'content' => $RCMAIL->output->charset_selector(array( | |
592 'id' => $field_id, 'name' => '_default_charset', 'selected' => $config['default_charset'] | |
593 ))); | |
594 } | |
595 | |
596 if (!isset($no_override['show_images'])) { | |
597 if (!$current) { | |
598 continue 2; | |
599 } | |
600 | |
601 $field_id = 'rcmfd_show_images'; | |
602 $input = new html_select(array('name' => '_show_images', 'id' => $field_id, | |
603 'disabled' => !$config['prefer_html'])); | |
604 | |
605 $input->add($RCMAIL->gettext('never'), 0); | |
606 $input->add($RCMAIL->gettext('fromknownsenders'), 1); | |
607 $input->add($RCMAIL->gettext('always'), 2); | |
608 | |
609 $blocks['main']['options']['show_images'] = array( | |
610 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('showremoteimages'))), | |
611 'content' => $input->show($config['prefer_html'] ? $config['show_images'] : 0), | |
612 ); | |
613 } | |
614 | |
615 if (!isset($no_override['inline_images'])) { | |
616 if (!$current) { | |
617 continue 2; | |
618 } | |
619 | |
620 $field_id = 'rcmfd_inline_images'; | |
621 $input = new html_checkbox(array('name' => '_inline_images', 'id' => $field_id, 'value' => 1)); | |
622 | |
623 $blocks['main']['options']['inline_images'] = array( | |
624 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('showinlineimages'))), | |
625 'content' => $input->show($config['inline_images']?1:0), | |
626 ); | |
627 } | |
628 | |
629 // "display after delete" checkbox | |
630 if (!isset($no_override['display_next'])) { | |
631 if (!$current) { | |
632 continue 2; | |
633 } | |
634 | |
635 $field_id = 'rcmfd_displaynext'; | |
636 $input = new html_checkbox(array('name' => '_display_next', 'id' => $field_id, 'value' => 1)); | |
637 | |
638 $blocks['main']['options']['display_next'] = array( | |
639 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('displaynext'))), | |
640 'content' => $input->show($config['display_next']?1:0), | |
641 ); | |
642 } | |
643 break; | |
644 | |
645 // Mail composition | |
646 case 'compose': | |
647 $blocks = array( | |
648 'main' => array('name' => rcube::Q($RCMAIL->gettext('mainoptions'))), | |
649 'sig' => array('name' => rcube::Q($RCMAIL->gettext('signatureoptions'))), | |
650 'spellcheck' => array('name' => rcube::Q($RCMAIL->gettext('spellcheckoptions'))), | |
651 'advanced' => array('name' => rcube::Q($RCMAIL->gettext('advancedoptions'))), | |
652 ); | |
653 | |
654 // show checkbox to compose messages in a new window | |
655 if (!isset($no_override['compose_extwin'])) { | |
656 if (!$current) { | |
657 continue 2; | |
658 } | |
659 | |
660 $field_id = 'rcmfdcompose_extwin'; | |
661 $input = new html_checkbox(array('name' => '_compose_extwin', 'id' => $field_id, 'value' => 1)); | |
662 | |
663 $blocks['main']['options']['compose_extwin'] = array( | |
664 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('composeextwin'))), | |
665 'content' => $input->show($config['compose_extwin']?1:0), | |
666 ); | |
667 } | |
668 | |
669 if (!isset($no_override['htmleditor'])) { | |
670 if (!$current) { | |
671 continue 2; | |
672 } | |
673 | |
674 $field_id = 'rcmfd_htmleditor'; | |
675 $select = new html_select(array('name' => '_htmleditor', 'id' => $field_id)); | |
676 | |
677 $select->add($RCMAIL->gettext('never'), 0); | |
678 $select->add($RCMAIL->gettext('htmlonreply'), 2); | |
679 $select->add($RCMAIL->gettext('htmlonreplyandforward'), 3); | |
680 $select->add($RCMAIL->gettext('always'), 1); | |
681 $select->add($RCMAIL->gettext('alwaysbutplain'), 4); | |
682 | |
683 $blocks['main']['options']['htmleditor'] = array( | |
684 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('htmleditor'))), | |
685 'content' => $select->show(intval($config['htmleditor'])), | |
686 ); | |
687 } | |
688 | |
689 if (!isset($no_override['draft_autosave'])) { | |
690 if (!$current) { | |
691 continue 2; | |
692 } | |
693 | |
694 $field_id = 'rcmfd_autosave'; | |
695 $select = new html_select(array('name' => '_draft_autosave', 'id' => $field_id, 'disabled' => empty($config['drafts_mbox']))); | |
696 | |
697 $select->add($RCMAIL->gettext('never'), 0); | |
698 foreach (array(1, 3, 5, 10) as $i => $min) { | |
699 $label = $RCMAIL->gettext(array('name' => 'everynminutes', 'vars' => array('n' => $min))); | |
700 $select->add($label, $min*60); | |
701 } | |
702 | |
703 $blocks['main']['options']['draft_autosave'] = array( | |
704 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('autosavedraft'))), | |
705 'content' => $select->show($config['draft_autosave']), | |
706 ); | |
707 } | |
708 | |
709 if (!isset($no_override['mime_param_folding'])) { | |
710 if (!$current) { | |
711 continue 2; | |
712 } | |
713 | |
714 $field_id = 'rcmfd_param_folding'; | |
715 $select = new html_select(array('name' => '_mime_param_folding', 'id' => $field_id)); | |
716 | |
717 $select->add($RCMAIL->gettext('2231folding'), 0); | |
718 $select->add($RCMAIL->gettext('miscfolding'), 1); | |
719 $select->add($RCMAIL->gettext('2047folding'), 2); | |
720 | |
721 $blocks['advanced']['options']['mime_param_folding'] = array( | |
722 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('mimeparamfolding'))), | |
723 'content' => $select->show($config['mime_param_folding']), | |
724 ); | |
725 } | |
726 | |
727 if (!isset($no_override['force_7bit'])) { | |
728 if (!$current) { | |
729 continue 2; | |
730 } | |
731 | |
732 $field_id = 'rcmfd_force_7bit'; | |
733 $input = new html_checkbox(array('name' => '_force_7bit', 'id' => $field_id, 'value' => 1)); | |
734 | |
735 $blocks['advanced']['options']['force_7bit'] = array( | |
736 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('force7bit'))), | |
737 'content' => $input->show($config['force_7bit']?1:0), | |
738 ); | |
739 } | |
740 | |
741 if (!isset($no_override['mdn_default'])) { | |
742 if (!$current) { | |
743 continue 2; | |
744 } | |
745 | |
746 $field_id = 'rcmfd_mdn_default'; | |
747 $input = new html_checkbox(array('name' => '_mdn_default', 'id' => $field_id, 'value' => 1)); | |
748 | |
749 $blocks['main']['options']['mdn_default'] = array( | |
750 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('reqmdn'))), | |
751 'content' => $input->show($config['mdn_default']?1:0), | |
752 ); | |
753 } | |
754 | |
755 if (!isset($no_override['dsn_default'])) { | |
756 if (!$current) { | |
757 continue 2; | |
758 } | |
759 | |
760 $field_id = 'rcmfd_dsn_default'; | |
761 $input = new html_checkbox(array('name' => '_dsn_default', 'id' => $field_id, 'value' => 1)); | |
762 | |
763 $blocks['main']['options']['dsn_default'] = array( | |
764 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('reqdsn'))), | |
765 'content' => $input->show($config['dsn_default']?1:0), | |
766 ); | |
767 } | |
768 | |
769 if (!isset($no_override['reply_same_folder'])) { | |
770 if (!$current) { | |
771 continue 2; | |
772 } | |
773 | |
774 $field_id = 'rcmfd_reply_same_folder'; | |
775 $input = new html_checkbox(array('name' => '_reply_same_folder', 'id' => $field_id, 'value' => 1)); | |
776 | |
777 $blocks['main']['options']['reply_same_folder'] = array( | |
778 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('replysamefolder'))), | |
779 'content' => $input->show($config['reply_same_folder']?1:0), | |
780 ); | |
781 } | |
782 | |
783 if (!isset($no_override['reply_mode'])) { | |
784 if (!$current) { | |
785 continue 2; | |
786 } | |
787 | |
788 $field_id = 'rcmfd_reply_mode'; | |
789 $select = new html_select(array('name' => '_reply_mode', 'id' => $field_id)); | |
790 | |
791 $select->add($RCMAIL->gettext('replyempty'), -1); | |
792 $select->add($RCMAIL->gettext('replybottomposting'), 0); | |
793 $select->add($RCMAIL->gettext('replytopposting'), 1); | |
794 | |
795 $blocks['main']['options']['reply_mode'] = array( | |
796 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('whenreplying'))), | |
797 'content' => $select->show(intval($config['reply_mode'])), | |
798 ); | |
799 } | |
800 | |
801 if (!isset($no_override['spellcheck_before_send']) && $config['enable_spellcheck']) { | |
802 if (!$current) { | |
803 continue 2; | |
804 } | |
805 | |
806 $field_id = 'rcmfd_spellcheck_before_send'; | |
807 $input = new html_checkbox(array('name' => '_spellcheck_before_send', 'id' => $field_id, 'value' => 1)); | |
808 | |
809 $blocks['spellcheck']['options']['spellcheck_before_send'] = array( | |
810 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('spellcheckbeforesend'))), | |
811 'content' => $input->show($config['spellcheck_before_send']?1:0), | |
812 ); | |
813 } | |
814 | |
815 if ($config['enable_spellcheck']) { | |
816 if (!$current) { | |
817 continue 2; | |
818 } | |
819 | |
820 foreach (array('syms', 'nums', 'caps') as $key) { | |
821 $key = 'spellcheck_ignore_'.$key; | |
822 if (!isset($no_override[$key])) { | |
823 $input = new html_checkbox(array('name' => '_'.$key, 'id' => 'rcmfd_'.$key, 'value' => 1)); | |
824 | |
825 $blocks['spellcheck']['options'][$key] = array( | |
826 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext(str_replace('_', '', $key)))), | |
827 'content' => $input->show($config[$key]?1:0), | |
828 ); | |
829 } | |
830 } | |
831 } | |
832 | |
833 if (!isset($no_override['show_sig'])) { | |
834 if (!$current) { | |
835 continue 2; | |
836 } | |
837 | |
838 $field_id = 'rcmfd_show_sig'; | |
839 $select = new html_select(array('name' => '_show_sig', 'id' => $field_id)); | |
840 | |
841 $select->add($RCMAIL->gettext('never'), 0); | |
842 $select->add($RCMAIL->gettext('always'), 1); | |
843 $select->add($RCMAIL->gettext('newmessageonly'), 2); | |
844 $select->add($RCMAIL->gettext('replyandforwardonly'), 3); | |
845 | |
846 $blocks['sig']['options']['show_sig'] = array( | |
847 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('autoaddsignature'))), | |
848 'content' => $select->show($RCMAIL->config->get('show_sig', 1)), | |
849 ); | |
850 } | |
851 | |
852 if (!isset($no_override['sig_below'])) { | |
853 if (!$current) { | |
854 continue 2; | |
855 } | |
856 | |
857 $field_id = 'rcmfd_sig_below'; | |
858 $input = new html_checkbox(array('name' => '_sig_below', 'id' => $field_id, 'value' => 1)); | |
859 | |
860 $blocks['sig']['options']['sig_below'] = array( | |
861 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('sigbelow'))), | |
862 'content' => $input->show($RCMAIL->config->get('sig_below') ? 1 : 0), | |
863 ); | |
864 } | |
865 | |
866 if (!isset($no_override['strip_existing_sig'])) { | |
867 if (!$current) { | |
868 continue 2; | |
869 } | |
870 | |
871 $field_id = 'rcmfd_strip_existing_sig'; | |
872 $input = new html_checkbox(array('name' => '_strip_existing_sig', 'id' => $field_id, 'value' => 1)); | |
873 | |
874 $blocks['sig']['options']['strip_existing_sig'] = array( | |
875 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('replyremovesignature'))), | |
876 'content' => $input->show($config['strip_existing_sig']?1:0), | |
877 ); | |
878 } | |
879 | |
880 if (!isset($no_override['sig_separator'])) { | |
881 if (!$current) { | |
882 continue 2; | |
883 } | |
884 | |
885 $field_id = 'rcmfd_sig_separator'; | |
886 $input = new html_checkbox(array('name' => '_sig_separator', 'id' => $field_id, 'value' => 1)); | |
887 | |
888 $blocks['sig']['options']['sig_separator'] = array( | |
889 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('sigseparator'))), | |
890 'content' => $input->show($RCMAIL->config->get('sig_separator') ? 1 : 0), | |
891 ); | |
892 } | |
893 | |
894 if (!isset($no_override['forward_attachment'])) { | |
895 if (!$current) { | |
896 continue 2; | |
897 } | |
898 | |
899 $field_id = 'rcmfd_forward_attachment'; | |
900 $select = new html_select(array('name' => '_forward_attachment', 'id' => $field_id)); | |
901 | |
902 $select->add($RCMAIL->gettext('inline'), 0); | |
903 $select->add($RCMAIL->gettext('asattachment'), 1); | |
904 | |
905 $blocks['main']['options']['forward_attachment'] = array( | |
906 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('forwardmode'))), | |
907 'content' => $select->show(intval($config['forward_attachment'])), | |
908 ); | |
909 } | |
910 | |
911 if (!isset($no_override['default_font']) || !isset($no_override['default_font_size'])) { | |
912 if (!$current) { | |
913 continue 2; | |
914 } | |
915 | |
916 // Default font size | |
917 $field_id = 'rcmfd_default_font_size'; | |
918 $select_default_font_size = new html_select(array('name' => '_default_font_size', 'id' => $field_id)); | |
919 | |
920 $fontsizes = array('', '8pt', '10pt', '12pt', '14pt', '18pt', '24pt', '36pt'); | |
921 foreach ($fontsizes as $size) { | |
922 $select_default_font_size->add($size, $size); | |
923 } | |
924 | |
925 // Default font | |
926 $field_id = 'rcmfd_default_font'; | |
927 $select_default_font = new html_select(array('name' => '_default_font', 'id' => $field_id)); | |
928 $select_default_font->add('', ''); | |
929 | |
930 $fonts = rcmail::font_defs(); | |
931 foreach (array_keys($fonts) as $fname) { | |
932 $select_default_font->add($fname, $fname); | |
933 } | |
934 | |
935 $blocks['main']['options']['default_font'] = array( | |
936 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('defaultfont'))), | |
937 'content' => $select_default_font->show($RCMAIL->config->get('default_font', 1)) . | |
938 $select_default_font_size->show($RCMAIL->config->get('default_font_size', 1)) | |
939 ); | |
940 } | |
941 | |
942 if (!isset($no_override['reply_all_mode'])) { | |
943 if (!$current) { | |
944 continue 2; | |
945 } | |
946 | |
947 $field_id = 'rcmfd_reply_all_mode'; | |
948 $select = new html_select(array('name' => '_reply_all_mode', 'id' => $field_id)); | |
949 | |
950 $select->add($RCMAIL->gettext('replyalldefault'), 0); | |
951 $select->add($RCMAIL->gettext('replyalllist'), 1); | |
952 | |
953 $blocks['main']['options']['reply_all_mode'] = array( | |
954 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('replyallmode'))), | |
955 'content' => $select->show(intval($config['reply_all_mode'])), | |
956 ); | |
957 } | |
958 | |
959 if (!isset($no_override['compose_save_localstorage'])) { | |
960 if (!$current) { | |
961 continue 2; | |
962 } | |
963 | |
964 $field_id = 'rcmfd_compose_save_localstorage'; | |
965 $input = new html_checkbox(array('name' => '_compose_save_localstorage', 'id' => $field_id, 'value' => 1)); | |
966 | |
967 $blocks['advanced']['options']['compose_save_localstorage'] = array( | |
968 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('savelocalstorage'))), | |
969 'content' => $input->show($config['compose_save_localstorage']?1:0), | |
970 ); | |
971 } | |
972 | |
973 break; | |
974 | |
975 // Addressbook config | |
976 case 'addressbook': | |
977 $blocks = array( | |
978 'main' => array('name' => rcube::Q($RCMAIL->gettext('mainoptions'))), | |
979 'advanced' => array('name' => rcube::Q($RCMAIL->gettext('advancedoptions'))), | |
980 ); | |
981 | |
982 if (!isset($no_override['default_addressbook']) | |
983 && (!$current || ($books = $RCMAIL->get_address_sources(true, true))) | |
984 ) { | |
985 if (!$current) { | |
986 continue 2; | |
987 } | |
988 | |
989 $field_id = 'rcmfd_default_addressbook'; | |
990 $select = new html_select(array('name' => '_default_addressbook', 'id' => $field_id)); | |
991 | |
992 foreach ($books as $book) { | |
993 $select->add(html_entity_decode($book['name'], ENT_COMPAT, 'UTF-8'), $book['id']); | |
994 } | |
995 | |
996 $blocks['main']['options']['default_addressbook'] = array( | |
997 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('defaultabook'))), | |
998 'content' => $select->show($config['default_addressbook']), | |
999 ); | |
1000 } | |
1001 | |
1002 // show addressbook listing mode selection | |
1003 if (!isset($no_override['addressbook_name_listing'])) { | |
1004 if (!$current) { | |
1005 continue 2; | |
1006 } | |
1007 | |
1008 $field_id = 'rcmfd_addressbook_name_listing'; | |
1009 $select = new html_select(array('name' => '_addressbook_name_listing', 'id' => $field_id)); | |
1010 | |
1011 $select->add($RCMAIL->gettext('name'), 0); | |
1012 $select->add($RCMAIL->gettext('firstname') . ' ' . $RCMAIL->gettext('surname'), 1); | |
1013 $select->add($RCMAIL->gettext('surname') . ' ' . $RCMAIL->gettext('firstname'), 2); | |
1014 $select->add($RCMAIL->gettext('surname') . ', ' . $RCMAIL->gettext('firstname'), 3); | |
1015 | |
1016 $blocks['main']['options']['list_name_listing'] = array( | |
1017 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('listnamedisplay'))), | |
1018 'content' => $select->show($config['addressbook_name_listing']), | |
1019 ); | |
1020 } | |
1021 | |
1022 // show addressbook sort column | |
1023 if (!isset($no_override['addressbook_sort_col'])) { | |
1024 if (!$current) { | |
1025 continue 2; | |
1026 } | |
1027 | |
1028 $field_id = 'rcmfd_addressbook_sort_col'; | |
1029 $select = new html_select(array('name' => '_addressbook_sort_col', 'id' => $field_id)); | |
1030 | |
1031 $select->add($RCMAIL->gettext('name'), 'name'); | |
1032 $select->add($RCMAIL->gettext('firstname'), 'firstname'); | |
1033 $select->add($RCMAIL->gettext('surname'), 'surname'); | |
1034 | |
1035 $blocks['main']['options']['sort_col'] = array( | |
1036 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('listsorting'))), | |
1037 'content' => $select->show($config['addressbook_sort_col']), | |
1038 ); | |
1039 } | |
1040 | |
1041 // show addressbook page size selection | |
1042 if (!isset($no_override['addressbook_pagesize'])) { | |
1043 if (!$current) { | |
1044 continue 2; | |
1045 } | |
1046 | |
1047 $field_id = 'rcmfd_addressbook_pagesize'; | |
1048 $input = new html_inputfield(array('name' => '_addressbook_pagesize', 'id' => $field_id, 'size' => 5)); | |
1049 $size = intval($config['addressbook_pagesize'] ?: $config['pagesize']); | |
1050 | |
1051 $blocks['main']['options']['pagesize'] = array( | |
1052 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('pagesize'))), | |
1053 'content' => $input->show($size ?: 50), | |
1054 ); | |
1055 } | |
1056 | |
1057 if (!isset($no_override['autocomplete_single'])) { | |
1058 if (!$current) { | |
1059 continue 2; | |
1060 } | |
1061 | |
1062 $field_id = 'rcmfd_autocomplete_single'; | |
1063 $checkbox = new html_checkbox(array('name' => '_autocomplete_single', 'id' => $field_id, 'value' => 1)); | |
1064 | |
1065 $blocks['main']['options']['autocomplete_single'] = array( | |
1066 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('autocompletesingle'))), | |
1067 'content' => $checkbox->show($config['autocomplete_single']?1:0), | |
1068 ); | |
1069 } | |
1070 break; | |
1071 | |
1072 // Special IMAP folders | |
1073 case 'folders': | |
1074 $blocks = array( | |
1075 'main' => array('name' => rcube::Q($RCMAIL->gettext('mainoptions'))), | |
1076 'advanced' => array('name' => rcube::Q($RCMAIL->gettext('advancedoptions'))), | |
1077 ); | |
1078 | |
1079 if (!isset($no_override['show_real_foldernames'])) { | |
1080 if (!$current) { | |
1081 continue 2; | |
1082 } | |
1083 | |
1084 $field_id = 'show_real_foldernames'; | |
1085 $input = new html_checkbox(array('name' => '_show_real_foldernames', 'id' => $field_id, 'value' => 1)); | |
1086 | |
1087 $blocks['main']['options']['show_real_foldernames'] = array( | |
1088 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('show_real_foldernames'))), | |
1089 'content' => $input->show($config['show_real_foldernames']?1:0), | |
1090 ); | |
1091 } | |
1092 | |
1093 // Configure special folders | |
1094 $set = array('drafts_mbox', 'sent_mbox', 'junk_mbox', 'trash_mbox'); | |
1095 if ($current && count(array_intersect($no_override, $set)) < 4) { | |
1096 $select = $RCMAIL->folder_selector(array( | |
1097 'noselection' => '---', | |
1098 'realnames' => true, | |
1099 'maxlength' => 30, | |
1100 'folder_filter' => 'mail', | |
1101 'folder_rights' => 'w', | |
1102 )); | |
1103 | |
1104 // #1486114, #1488279, #1489219 | |
1105 $onchange = "if ($(this).val() == 'INBOX') $(this).val('')"; | |
1106 } | |
1107 | |
1108 if (!isset($no_override['drafts_mbox'])) { | |
1109 if (!$current) { | |
1110 continue 2; | |
1111 } | |
1112 | |
1113 $blocks['main']['options']['drafts_mbox'] = array( | |
1114 'title' => rcube::Q($RCMAIL->gettext('drafts')), | |
1115 'content' => $select->show($config['drafts_mbox'], array('name' => "_drafts_mbox", 'onchange' => $onchange)), | |
1116 ); | |
1117 } | |
1118 | |
1119 if (!isset($no_override['sent_mbox'])) { | |
1120 if (!$current) { | |
1121 continue 2; | |
1122 } | |
1123 | |
1124 $blocks['main']['options']['sent_mbox'] = array( | |
1125 'title' => rcube::Q($RCMAIL->gettext('sent')), | |
1126 'content' => $select->show($config['sent_mbox'], array('name' => "_sent_mbox", 'onchange' => '')), | |
1127 ); | |
1128 } | |
1129 | |
1130 if (!isset($no_override['junk_mbox'])) { | |
1131 if (!$current) { | |
1132 continue 2; | |
1133 } | |
1134 | |
1135 $blocks['main']['options']['junk_mbox'] = array( | |
1136 'title' => rcube::Q($RCMAIL->gettext('junk')), | |
1137 'content' => $select->show($config['junk_mbox'], array('name' => "_junk_mbox", 'onchange' => $onchange)), | |
1138 ); | |
1139 } | |
1140 | |
1141 if (!isset($no_override['trash_mbox'])) { | |
1142 if (!$current) { | |
1143 continue 2; | |
1144 } | |
1145 | |
1146 $blocks['main']['options']['trash_mbox'] = array( | |
1147 'title' => rcube::Q($RCMAIL->gettext('trash')), | |
1148 'content' => $select->show($config['trash_mbox'], array('name' => "_trash_mbox", 'onchange' => $onchange)), | |
1149 ); | |
1150 } | |
1151 break; | |
1152 | |
1153 // Server settings | |
1154 case 'server': | |
1155 $blocks = array( | |
1156 'main' => array('name' => rcube::Q($RCMAIL->gettext('mainoptions'))), | |
1157 'maintenance' => array('name' => rcube::Q($RCMAIL->gettext('maintenance'))), | |
1158 'advanced' => array('name' => rcube::Q($RCMAIL->gettext('advancedoptions'))), | |
1159 ); | |
1160 | |
1161 if (!isset($no_override['read_when_deleted'])) { | |
1162 if (!$current) { | |
1163 continue 2; | |
1164 } | |
1165 | |
1166 $field_id = 'rcmfd_read_deleted'; | |
1167 $input = new html_checkbox(array('name' => '_read_when_deleted', 'id' => $field_id, 'value' => 1)); | |
1168 | |
1169 $blocks['main']['options']['read_when_deleted'] = array( | |
1170 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('readwhendeleted'))), | |
1171 'content' => $input->show($config['read_when_deleted']?1:0), | |
1172 ); | |
1173 } | |
1174 | |
1175 if (!isset($no_override['flag_for_deletion'])) { | |
1176 if (!$current) { | |
1177 continue 2; | |
1178 } | |
1179 | |
1180 $field_id = 'rcmfd_flag_for_deletion'; | |
1181 $input = new html_checkbox(array('name' => '_flag_for_deletion', 'id' => $field_id, 'value' => 1)); | |
1182 | |
1183 $blocks['main']['options']['flag_for_deletion'] = array( | |
1184 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('flagfordeletion'))), | |
1185 'content' => $input->show($config['flag_for_deletion']?1:0), | |
1186 ); | |
1187 } | |
1188 | |
1189 // don't show deleted messages | |
1190 if (!isset($no_override['skip_deleted'])) { | |
1191 if (!$current) { | |
1192 continue 2; | |
1193 } | |
1194 | |
1195 $field_id = 'rcmfd_skip_deleted'; | |
1196 $input = new html_checkbox(array('name' => '_skip_deleted', 'id' => $field_id, 'value' => 1)); | |
1197 | |
1198 $blocks['main']['options']['skip_deleted'] = array( | |
1199 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('skipdeleted'))), | |
1200 'content' => $input->show($config['skip_deleted']?1:0), | |
1201 ); | |
1202 } | |
1203 | |
1204 if (!isset($no_override['delete_always'])) { | |
1205 if (!$current) { | |
1206 continue 2; | |
1207 } | |
1208 | |
1209 $field_id = 'rcmfd_delete_always'; | |
1210 $input = new html_checkbox(array('name' => '_delete_always', 'id' => $field_id, 'value' => 1)); | |
1211 | |
1212 $blocks['main']['options']['delete_always'] = array( | |
1213 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('deletealways'))), | |
1214 'content' => $input->show($config['delete_always']?1:0), | |
1215 ); | |
1216 } | |
1217 | |
1218 if (!isset($no_override['delete_junk'])) { | |
1219 if (!$current) { | |
1220 continue 2; | |
1221 } | |
1222 | |
1223 $field_id = 'rcmfd_delete_junk'; | |
1224 $input = new html_checkbox(array('name' => '_delete_junk', 'id' => $field_id, 'value' => 1)); | |
1225 | |
1226 $blocks['main']['options']['delete_junk'] = array( | |
1227 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('deletejunk'))), | |
1228 'content' => $input->show($config['delete_junk']?1:0), | |
1229 ); | |
1230 } | |
1231 | |
1232 // Trash purging on logout | |
1233 if (!isset($no_override['logout_purge'])) { | |
1234 if (!$current) { | |
1235 continue 2; | |
1236 } | |
1237 | |
1238 $field_id = 'rcmfd_logout_purge'; | |
1239 $input = new html_checkbox(array('name' => '_logout_purge', 'id' => $field_id, 'value' => 1)); | |
1240 | |
1241 $blocks['maintenance']['options']['logout_purge'] = array( | |
1242 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('logoutclear'))), | |
1243 'content' => $input->show($config['logout_purge']?1:0), | |
1244 ); | |
1245 } | |
1246 | |
1247 // INBOX compacting on logout | |
1248 if (!isset($no_override['logout_expunge'])) { | |
1249 if (!$current) { | |
1250 continue 2; | |
1251 } | |
1252 | |
1253 $field_id = 'rcmfd_logout_expunge'; | |
1254 $input = new html_checkbox(array('name' => '_logout_expunge', 'id' => $field_id, 'value' => 1)); | |
1255 | |
1256 $blocks['maintenance']['options']['logout_expunge'] = array( | |
1257 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('logoutcompact'))), | |
1258 'content' => $input->show($config['logout_expunge']?1:0), | |
1259 ); | |
1260 } | |
1261 } | |
1262 | |
1263 $found = false; | |
1264 $data = $RCMAIL->plugins->exec_hook('preferences_list', | |
1265 array('section' => $sect['id'], 'blocks' => $blocks, 'current' => $current)); | |
1266 | |
1267 $advanced_prefs = (array) $RCMAIL->config->get('advanced_prefs'); | |
1268 | |
1269 // create output | |
1270 foreach ($data['blocks'] as $key => $block) { | |
1271 if (!empty($block['content']) || !empty($block['options'])) { | |
1272 $found = true; | |
1273 } | |
1274 // move some options to the 'advanced' block as configured by admin | |
1275 if ($key != 'advanced') { | |
1276 foreach ($advanced_prefs as $opt) { | |
1277 if ($block['options'][$opt]) { | |
1278 $data['blocks']['advanced']['options'][$opt] = $block['options'][$opt]; | |
1279 unset($data['blocks'][$key]['options'][$opt]); | |
1280 } | |
1281 } | |
1282 } | |
1283 } | |
1284 | |
1285 // move 'advanced' block to the end of the list | |
1286 if (!empty($data['blocks']['advanced'])) { | |
1287 $adv = $data['blocks']['advanced']; | |
1288 unset($data['blocks']['advanced']); | |
1289 $data['blocks']['advanced'] = $adv; | |
1290 } | |
1291 | |
1292 if (!$found) | |
1293 unset($sections[$idx]); | |
1294 else | |
1295 $sections[$idx]['blocks'] = $data['blocks']; | |
1296 | |
1297 // allow plugins to add a header to each section | |
1298 $data = $RCMAIL->plugins->exec_hook('preferences_section_header', | |
1299 array('section' => $sect['id'], 'header' => '', 'current' => $current)); | |
1300 | |
1301 if (!empty($data['header'])) { | |
1302 $sections[$idx]['header'] = $data['header']; | |
1303 } | |
1304 } | |
1305 | |
1306 return array($sections, $plugin['cols']); | |
1307 } | |
1308 | |
1309 | |
1310 function rcmail_get_skins() | |
1311 { | |
1312 $path = RCUBE_INSTALL_PATH . 'skins'; | |
1313 $skins = array(); | |
1314 $dir = opendir($path); | |
1315 | |
1316 if (!$dir) { | |
1317 return false; | |
1318 } | |
1319 | |
1320 while (($file = readdir($dir)) !== false) { | |
1321 $filename = $path.'/'.$file; | |
1322 if (!preg_match('/^\./', $file) && is_dir($filename) && is_readable($filename)) { | |
1323 $skins[] = $file; | |
1324 } | |
1325 } | |
1326 | |
1327 closedir($dir); | |
1328 | |
1329 return $skins; | |
1330 } | |
1331 | |
1332 | |
1333 function rcmail_folder_options($mailbox) | |
1334 { | |
1335 global $RCMAIL; | |
1336 | |
1337 $options = $RCMAIL->get_storage()->folder_info($mailbox); | |
1338 $options['protected'] = $options['is_root'] | |
1339 || strtoupper($mailbox) === 'INBOX' | |
1340 || ($options['special'] && $RCMAIL->config->get('protect_default_folders')); | |
1341 | |
1342 return $options; | |
1343 } | |
1344 | |
1345 /** | |
1346 * Updates (or creates) folder row in the subscriptions table | |
1347 * | |
1348 * @param string $name Folder name | |
1349 * @param string $oldname Old folder name (for update) | |
1350 * @param bool $subscribe Checks subscription checkbox | |
1351 * @param string $class CSS class name for folder row | |
1352 */ | |
1353 function rcmail_update_folder_row($name, $oldname=null, $subscribe=false, $class_name=null) | |
1354 { | |
1355 global $RCMAIL, $OUTPUT; | |
1356 | |
1357 $protect_folders = $RCMAIL->config->get('protect_default_folders'); | |
1358 $storage = $RCMAIL->get_storage(); | |
1359 $delimiter = $storage->get_hierarchy_delimiter(); | |
1360 | |
1361 $name_utf8 = rcube_charset::convert($name, 'UTF7-IMAP'); | |
1362 $protected = $protect_folders && $storage->is_special_folder($name); | |
1363 $foldersplit = explode($delimiter, $storage->mod_folder($name)); | |
1364 $level = count($foldersplit) - 1; | |
1365 $display_name = $protected ? $RCMAIL->localize_foldername($name) : rcube_charset::convert($foldersplit[$level], 'UTF7-IMAP'); | |
1366 $class_name = trim($class_name . ' mailbox'); | |
1367 | |
1368 if ($oldname === null) { | |
1369 $OUTPUT->command('add_folder_row', $name, $name_utf8, $display_name, $protected, $subscribe, | |
1370 $class_name); | |
1371 } | |
1372 else { | |
1373 $OUTPUT->command('replace_folder_row', $oldname, $name, $name_utf8, $display_name, $protected, $class_name); | |
1374 } | |
1375 } | |
1376 | |
1377 /** | |
1378 * Render the list of settings sections (AKA tabs) | |
1379 */ | |
1380 function rcmail_settings_tabs($attrib) | |
1381 { | |
1382 global $RCMAIL, $OUTPUT; | |
1383 | |
1384 // add default attributes | |
1385 $attrib += array('tagname' => 'span', 'idprefix' => 'settingstab', 'selclass' => 'selected'); | |
1386 | |
1387 $default_actions = array( | |
1388 array('command' => 'preferences', 'type' => 'link', 'label' => 'preferences', 'title' => 'editpreferences'), | |
1389 array('command' => 'folders', 'type' => 'link', 'label' => 'folders', 'title' => 'managefolders'), | |
1390 array('command' => 'identities', 'type' => 'link', 'label' => 'identities', 'title' => 'manageidentities'), | |
1391 array('command' => 'responses', 'type' => 'link', 'label' => 'responses', 'title' => 'manageresponses'), | |
1392 ); | |
1393 | |
1394 $disabled_actions = (array) $RCMAIL->config->get('disabled_actions'); | |
1395 | |
1396 // get all identites from DB and define list of cols to be displayed | |
1397 $plugin = $RCMAIL->plugins->exec_hook('settings_actions', array( | |
1398 'actions' => $default_actions, | |
1399 'attrib' => $attrib, | |
1400 )); | |
1401 | |
1402 $attrib = $plugin['attrib']; | |
1403 $tagname = $attrib['tagname']; | |
1404 $tabs = array(); | |
1405 | |
1406 foreach ($plugin['actions'] as $action) { | |
1407 $task_action = $action['command'] ? $action['command'] : $action['action']; | |
1408 if (in_array('settings.' . $task_action, $disabled_actions)) { | |
1409 continue; | |
1410 } | |
1411 | |
1412 if (!$action['command'] && !$action['href'] && $action['action']) { | |
1413 $action['href'] = $RCMAIL->url(array('_action' => $action['action'])); | |
1414 } | |
1415 | |
1416 $button = $OUTPUT->button($action); | |
1417 $attr = $attrib; | |
1418 | |
1419 $cmd = $action['action'] ?: $action['command']; | |
1420 $id = $action['id'] ?: $cmd; | |
1421 | |
1422 if (!empty($id)) { | |
1423 $attr['id'] = preg_replace('/[^a-z0-9]/i', '', $attrib['idprefix'] . $id); | |
1424 } | |
1425 | |
1426 $classnames = array($attrib['class']); | |
1427 if (!empty($action['class'])) { | |
1428 $classnames[] = $action['class']; | |
1429 } | |
1430 else if (!empty($cmd)) { | |
1431 $classnames[] = $cmd; | |
1432 } | |
1433 if ($RCMAIL->action == $cmd) { | |
1434 $classnames[] = $attrib['selclass']; | |
1435 } | |
1436 | |
1437 $attr['class'] = join(' ', $classnames); | |
1438 $tabs[] = html::tag($tagname, $attr, $button, html::$common_attrib); | |
1439 } | |
1440 | |
1441 return join('', $tabs); | |
1442 } |