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 2873 2009-08-27 06:18:54Z thomasb $
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 'prettydate' => isset($_POST['_pretty_date']) ? TRUE : FALSE,
36 'skin' => isset($_POST['_skin']) ? get_input_value('_skin', RCUBE_INPUT_POST) : $CONFIG['skin'],
41 $a_user_prefs = array(
42 'focus_on_new_message' => isset($_POST['_focus_on_new_message']) ? TRUE : FALSE,
43 'preview_pane' => isset($_POST['_preview_pane']) ? TRUE : FALSE,
44 'mdn_requests' => isset($_POST['_mdn_requests']) ? intval($_POST['_mdn_requests']) : 0,
45 'keep_alive' => isset($_POST['_keep_alive']) ? intval($_POST['_keep_alive'])*60 : $CONFIG['keep_alive'],
46 'check_all_folders' => isset($_POST['_check_all_folders']) ? TRUE : FALSE,
51 $a_user_prefs = array(
52 'prefer_html' => isset($_POST['_prefer_html']) ? TRUE : FALSE,
53 'inline_images' => isset($_POST['_inline_images']) ? TRUE : FALSE,
54 'show_images' => isset($_POST['_show_images']) ? intval($_POST['_show_images']) : 0,
55 'display_next' => isset($_POST['_display_next']) ? TRUE : FALSE,
60 $a_user_prefs = array(
61 'htmleditor' => isset($_POST['_htmleditor']) ? TRUE : FALSE,
62 'draft_autosave' => isset($_POST['_draft_autosave']) ? intval($_POST['_draft_autosave']) : 0,
63 'mime_param_folding' => isset($_POST['_mime_param_folding']) ? intval($_POST['_mime_param_folding']) : 0,
68 $a_user_prefs = array(
69 'read_when_deleted' => isset($_POST['_read_when_deleted']) ? TRUE : FALSE,
70 'skip_deleted' => isset($_POST['_skip_deleted']) ? TRUE : FALSE,
71 'flag_for_deletion' => isset($_POST['_flag_for_deletion']) ? TRUE : FALSE,
72 'logout_purge' => isset($_POST['_logout_purge']) ? TRUE : FALSE,
73 'logout_expunge' => isset($_POST['_logout_expunge']) ? TRUE : FALSE,
78 $a_user_prefs = array(
79 'drafts_mbox' => get_input_value('_drafts_mbox', RCUBE_INPUT_POST),
80 'sent_mbox' => get_input_value('_sent_mbox', RCUBE_INPUT_POST),
81 'junk_mbox' => get_input_value('_junk_mbox', RCUBE_INPUT_POST),
82 'trash_mbox' => get_input_value('_trash_mbox', RCUBE_INPUT_POST),
89 $data = rcmail::get_instance()->plugins->exec_hook('save_preferences',
90 array('prefs' => $a_user_prefs, 'section' => $CURR_SECTION));
92 $a_user_prefs = $data['prefs'];
94 // don't override these parameters
95 foreach ((array)$CONFIG['dont_override'] as $p)
96 $a_user_prefs[$p] = $CONFIG[$p];
99 // verify some options
100 switch ($CURR_SECTION)
104 // switch UI language
105 if (isset($_POST['_language']) && $a_user_prefs['language'] != $_SESSION['language']) {
106 $RCMAIL->load_language($a_user_prefs['language']);
107 $OUTPUT->command('reload', 500);
111 $OUTPUT->set_skin($a_user_prefs['skin']);
114 if ($a_user_prefs['pagesize'] < 1)
115 $a_user_prefs['pagesize'] = 10;
117 if (isset($CONFIG['max_pagesize']) && ($a_user_prefs['pagesize'] > $CONFIG['max_pagesize']))
118 $a_user_prefs['pagesize'] = (int) $CONFIG['max_pagesize'];
124 if (isset($a_user_prefs['keep_alive'])) {
125 $a_user_prefs['keep_alive'] = max(60, $CONFIG['min_keep_alive'], $a_user_prefs['keep_alive']);
126 if (!empty($CONFIG['session_lifetime']))
127 $a_user_prefs['keep_alive'] = min($CONFIG['session_lifetime']*60, $a_user_prefs['keep_alive']);
133 // special handling for 'default_imap_folders'
134 if (in_array('default_imap_folders', (array)$CONFIG['dont_override'])) {
135 foreach (array('drafts_mbox','sent_mbox','junk_mbox','trash_mbox') as $p)
136 $a_user_prefs[$p] = $CONFIG[$p];
138 $a_user_prefs['default_imap_folders'] = array('INBOX');
139 foreach (array('drafts_mbox','sent_mbox','junk_mbox','trash_mbox') as $p) {
140 if ($a_user_prefs[$p])
141 $a_user_prefs['default_imap_folders'][] = $a_user_prefs[$p];
148 if ($USER->save_prefs($a_user_prefs))
149 $OUTPUT->show_message('successfullysaved', 'confirmation');
151 // display the form again
152 rcmail_overwrite_action('edit-prefs');