4 +-----------------------------------------------------------------------+
5 | program/steps/settings/save_prefs.inc |
7 | This file is part of the RoundCube Webmail client |
8 | Copyright (C) 2005-2009, RoundCube Dev. - Switzerland |
9 | Licensed under the GNU GPL |
12 | Save user preferences to DB and to the current session |
14 +-----------------------------------------------------------------------+
15 | Author: Thomas Bruederli <roundcube@gmail.com> |
16 +-----------------------------------------------------------------------+
18 $Id: save_prefs.inc 2983 2009-09-23 12:32:09Z alec $
22 $CURR_SECTION = get_input_value('_section', RCUBE_INPUT_POST);
24 $a_user_prefs = array();
26 // set options for specified section
27 switch ($CURR_SECTION)
30 $a_user_prefs = array(
31 'language' => isset($_POST['_language']) ? get_input_value('_language', RCUBE_INPUT_POST) : $CONFIG['language'],
32 'timezone' => isset($_POST['_timezone']) ? (is_numeric($_POST['_timezone']) ? floatval($_POST['_timezone']) : get_input_value('_timezone', RCUBE_INPUT_POST)) : $CONFIG['timezone'],
33 'dst_active' => isset($_POST['_dst_active']) ? TRUE : FALSE,
34 'pagesize' => is_numeric($_POST['_pagesize']) ? max(2, intval($_POST['_pagesize'])) : $CONFIG['pagesize'],
35 'index_sort' => isset($_POST['_index_sort']) ? TRUE : FALSE,
36 'prettydate' => isset($_POST['_pretty_date']) ? TRUE : FALSE,
37 'skin' => isset($_POST['_skin']) ? get_input_value('_skin', RCUBE_INPUT_POST) : $CONFIG['skin'],
42 $a_user_prefs = array(
43 'focus_on_new_message' => isset($_POST['_focus_on_new_message']) ? TRUE : FALSE,
44 'preview_pane' => isset($_POST['_preview_pane']) ? TRUE : FALSE,
45 'mdn_requests' => isset($_POST['_mdn_requests']) ? intval($_POST['_mdn_requests']) : 0,
46 'keep_alive' => isset($_POST['_keep_alive']) ? intval($_POST['_keep_alive'])*60 : $CONFIG['keep_alive'],
47 'check_all_folders' => isset($_POST['_check_all_folders']) ? TRUE : FALSE,
52 $a_user_prefs = array(
53 'prefer_html' => isset($_POST['_prefer_html']) ? TRUE : FALSE,
54 'inline_images' => isset($_POST['_inline_images']) ? TRUE : FALSE,
55 'show_images' => isset($_POST['_show_images']) ? intval($_POST['_show_images']) : 0,
56 'display_next' => isset($_POST['_display_next']) ? TRUE : FALSE,
61 $a_user_prefs = array(
62 'htmleditor' => isset($_POST['_htmleditor']) ? TRUE : FALSE,
63 'draft_autosave' => isset($_POST['_draft_autosave']) ? intval($_POST['_draft_autosave']) : 0,
64 'mime_param_folding' => isset($_POST['_mime_param_folding']) ? intval($_POST['_mime_param_folding']) : 0,
69 $a_user_prefs = array(
70 'read_when_deleted' => isset($_POST['_read_when_deleted']) ? TRUE : FALSE,
71 'skip_deleted' => isset($_POST['_skip_deleted']) ? TRUE : FALSE,
72 'flag_for_deletion' => isset($_POST['_flag_for_deletion']) ? TRUE : FALSE,
73 'logout_purge' => isset($_POST['_logout_purge']) ? TRUE : FALSE,
74 'logout_expunge' => isset($_POST['_logout_expunge']) ? TRUE : FALSE,
79 $a_user_prefs = array(
80 'drafts_mbox' => get_input_value('_drafts_mbox', RCUBE_INPUT_POST),
81 'sent_mbox' => get_input_value('_sent_mbox', RCUBE_INPUT_POST),
82 'junk_mbox' => get_input_value('_junk_mbox', RCUBE_INPUT_POST),
83 'trash_mbox' => get_input_value('_trash_mbox', RCUBE_INPUT_POST),
90 $data = rcmail::get_instance()->plugins->exec_hook('save_preferences',
91 array('prefs' => $a_user_prefs, 'section' => $CURR_SECTION));
93 $a_user_prefs = $data['prefs'];
95 // don't override these parameters
96 foreach ((array)$CONFIG['dont_override'] as $p)
97 $a_user_prefs[$p] = $CONFIG[$p];
100 // verify some options
101 switch ($CURR_SECTION)
105 // switch UI language
106 if (isset($_POST['_language']) && $a_user_prefs['language'] != $_SESSION['language']) {
107 $RCMAIL->load_language($a_user_prefs['language']);
108 $OUTPUT->command('reload', 500);
112 $OUTPUT->set_skin($a_user_prefs['skin']);
115 if ($a_user_prefs['pagesize'] < 1)
116 $a_user_prefs['pagesize'] = 10;
118 if (isset($CONFIG['max_pagesize']) && ($a_user_prefs['pagesize'] > $CONFIG['max_pagesize']))
119 $a_user_prefs['pagesize'] = (int) $CONFIG['max_pagesize'];
125 if (isset($a_user_prefs['keep_alive'])) {
126 $a_user_prefs['keep_alive'] = max(60, $CONFIG['min_keep_alive'], $a_user_prefs['keep_alive']);
127 if (!empty($CONFIG['session_lifetime']))
128 $a_user_prefs['keep_alive'] = min($CONFIG['session_lifetime']*60, $a_user_prefs['keep_alive']);
134 // special handling for 'default_imap_folders'
135 if (in_array('default_imap_folders', (array)$CONFIG['dont_override'])) {
136 foreach (array('drafts_mbox','sent_mbox','junk_mbox','trash_mbox') as $p)
137 $a_user_prefs[$p] = $CONFIG[$p];
139 $a_user_prefs['default_imap_folders'] = array('INBOX');
140 foreach (array('drafts_mbox','sent_mbox','junk_mbox','trash_mbox') as $p) {
141 if ($a_user_prefs[$p])
142 $a_user_prefs['default_imap_folders'][] = $a_user_prefs[$p];
149 if ($USER->save_prefs($a_user_prefs))
150 $OUTPUT->show_message('successfullysaved', 'confirmation');
152 // display the form again
153 rcmail_overwrite_action('edit-prefs');