commit | author | age
|
4e17e6
|
1 |
<?php |
T |
2 |
|
|
3 |
/* |
|
4 |
+-----------------------------------------------------------------------+ |
|
5 |
| program/steps/settings/save_prefs.inc | |
|
6 |
| | |
|
7 |
| This file is part of the RoundCube Webmail client | |
f11541
|
8 |
| Copyright (C) 2005-2007, RoundCube Dev. - Switzerland | |
30233b
|
9 |
| Licensed under the GNU GPL | |
4e17e6
|
10 |
| | |
T |
11 |
| PURPOSE: | |
|
12 |
| Save user preferences to DB and to the current session | |
|
13 |
| | |
|
14 |
+-----------------------------------------------------------------------+ |
|
15 |
| Author: Thomas Bruederli <roundcube@gmail.com> | |
|
16 |
+-----------------------------------------------------------------------+ |
|
17 |
|
|
18 |
$Id$ |
|
19 |
|
|
20 |
*/ |
|
21 |
|
b19097
|
22 |
$a_user_prefs = array( |
55fb73
|
23 |
'language' => isset($_POST['_language']) ? get_input_value('_language', RCUBE_INPUT_POST) : $CONFIG['language'], |
c8ae24
|
24 |
'timezone' => isset($_POST['_timezone']) ? (is_numeric($_POST['_timezone']) ? floatval($_POST['_timezone']) : get_input_value('_timezone', RCUBE_INPUT_POST)) : $CONFIG['timezone'], |
b19097
|
25 |
'dst_active' => isset($_POST['_dst_active']) ? TRUE : FALSE, |
ccb412
|
26 |
'pagesize' => is_numeric($_POST['_pagesize']) ? max(2, intval($_POST['_pagesize'])) : $CONFIG['pagesize'], |
b19097
|
27 |
'prettydate' => isset($_POST['_pretty_date']) ? TRUE : FALSE, |
T |
28 |
'prefer_html' => isset($_POST['_prefer_html']) ? TRUE : FALSE, |
712b30
|
29 |
'addrbook_show_images' => isset($_POST['_addrbook_show_images']) ? TRUE : FALSE, |
b19097
|
30 |
'htmleditor' => isset($_POST['_htmleditor']) ? TRUE : FALSE, |
166b61
|
31 |
'inline_images' => isset($_POST['_inline_images']) ? TRUE : FALSE, |
b19097
|
32 |
'preview_pane' => isset($_POST['_preview_pane']) ? TRUE : FALSE, |
d9b29a
|
33 |
'read_when_deleted' => isset($_POST['_read_when_deleted']) ? TRUE : FALSE, |
3044ae
|
34 |
'flag_for_deletion' => isset($_POST['_flag_for_deletion']) ? TRUE : FALSE, |
eaa394
|
35 |
'logout_purge' => isset($_POST['_logout_purge']) ? TRUE : FALSE, |
A |
36 |
'logout_expunge' => isset($_POST['_logout_expunge']) ? TRUE : FALSE, |
|
37 |
'draft_autosave' => isset($_POST['_draft_autosave']) ? intval($_POST['_draft_autosave']) : 0, |
d9b29a
|
38 |
'mdn_requests' => isset($_POST['_mdn_requests']) ? intval($_POST['_mdn_requests']) : 0, |
67effe
|
39 |
'skin' => isset($_POST['_skin']) ? get_input_value('_skin', RCUBE_INPUT_POST) : $CONFIG['skin'], |
cb3538
|
40 |
'drafts_mbox' => get_input_value('_drafts_mbox', RCUBE_INPUT_POST), |
T |
41 |
'sent_mbox' => get_input_value('_sent_mbox', RCUBE_INPUT_POST), |
|
42 |
'junk_mbox' => get_input_value('_junk_mbox', RCUBE_INPUT_POST), |
|
43 |
'trash_mbox' => get_input_value('_trash_mbox', RCUBE_INPUT_POST), |
b19097
|
44 |
); |
T |
45 |
|
|
46 |
// don't override these parameters |
|
47 |
foreach ((array)$CONFIG['dont_override'] as $p) |
|
48 |
$a_user_prefs[$p] = $CONFIG[$p]; |
4e17e6
|
49 |
|
64f20d
|
50 |
// special handling for 'default_imap_folders' |
T |
51 |
if (in_array('default_imap_folders', (array)$CONFIG['dont_override'])) { |
|
52 |
foreach (array('drafts_mbox','sent_mbox','junk_mbox','trash_mbox') as $p) |
|
53 |
$a_user_prefs[$p] = $CONFIG[$p]; |
|
54 |
} |
|
55 |
else { |
|
56 |
$a_user_prefs['default_imap_folders'] = array('INBOX'); |
|
57 |
foreach (array('drafts_mbox','sent_mbox','junk_mbox','trash_mbox') as $p) { |
|
58 |
if ($a_user_prefs[$p]) |
|
59 |
$a_user_prefs['default_imap_folders'][] = $a_user_prefs[$p]; |
|
60 |
} |
|
61 |
} |
4e17e6
|
62 |
|
b19097
|
63 |
// switch UI language |
1854c4
|
64 |
if (isset($_POST['_language'])) { |
55fb73
|
65 |
$RCMAIL->load_language($a_user_prefs['language']); |
1854c4
|
66 |
} |
4e17e6
|
67 |
|
3b6b91
|
68 |
// switch skin |
A |
69 |
$OUTPUT->set_skin($a_user_prefs['skin']); |
|
70 |
|
b3a645
|
71 |
// force min size |
ed7dd9
|
72 |
if ($a_user_prefs['pagesize'] < 1) |
b3a645
|
73 |
$a_user_prefs['pagesize'] = 10; |
T |
74 |
|
fba1f5
|
75 |
if (isset($CONFIG['max_pagesize']) && ($a_user_prefs['pagesize'] > $CONFIG['max_pagesize'])) |
T |
76 |
$a_user_prefs['pagesize'] = (int) $CONFIG['max_pagesize']; |
|
77 |
|
|
78 |
if ($USER->save_prefs($a_user_prefs)) |
f11541
|
79 |
$OUTPUT->show_message('successfullysaved', 'confirmation'); |
4e17e6
|
80 |
|
T |
81 |
|
|
82 |
// go to next step |
f11541
|
83 |
rcmail_overwrite_action('preferences'); |
4e17e6
|
84 |
|
a0109c
|
85 |
?> |