]> git.donarmstrong.com Git - roundcube.git/blob - program/steps/settings/save_prefs.inc
Imported Upstream version 0.2~alpha
[roundcube.git] / program / steps / settings / save_prefs.inc
1 <?php
2
3 /*
4  +-----------------------------------------------------------------------+
5  | program/steps/settings/save_prefs.inc                                 |
6  |                                                                       |
7  | This file is part of the RoundCube Webmail client                     |
8  | Copyright (C) 2005-2007, RoundCube Dev. - Switzerland                 |
9  | Licensed under the GNU GPL                                            |
10  |                                                                       |
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: save_prefs.inc 1403 2008-05-19 08:09:38Z alec $
19
20 */
21
22 $a_user_prefs = array(
23   'timezone'     => isset($_POST['_timezone']) ? floatval($_POST['_timezone']) : $CONFIG['timezone'],
24   'dst_active'   => isset($_POST['_dst_active']) ? TRUE : FALSE,
25   'pagesize'     => is_numeric($_POST['_pagesize']) ? max(2, intval($_POST['_pagesize'])) : $CONFIG['pagesize'],
26   'prettydate'   => isset($_POST['_pretty_date']) ? TRUE : FALSE,
27   'prefer_html'  => isset($_POST['_prefer_html']) ? TRUE : FALSE,
28   'htmleditor'   => isset($_POST['_htmleditor']) ? TRUE : FALSE,
29   'preview_pane' => isset($_POST['_preview_pane']) ? TRUE : FALSE,
30   'read_when_deleted' => isset($_POST['_read_when_deleted']) ? TRUE : FALSE,
31   'flag_for_deletion' => isset($_POST['_flag_for_deletion']) ? TRUE : FALSE,
32   'logout_purge' => isset($_POST['_logout_purge']) ? TRUE : FALSE,
33   'logout_expunge' => isset($_POST['_logout_expunge']) ? TRUE : FALSE,
34   'draft_autosave' => isset($_POST['_draft_autosave']) ? intval($_POST['_draft_autosave']) : 0,
35   'mdn_requests' => isset($_POST['_mdn_requests']) ? intval($_POST['_mdn_requests']) : 0,
36   );
37
38 // don't override these parameters
39 foreach ((array)$CONFIG['dont_override'] as $p)
40   $a_user_prefs[$p] = $CONFIG[$p];
41
42
43 // switch UI language
44 if (isset($_POST['_language'])) {
45   $RCMAIL->load_language(get_input_value('_language', RCUBE_INPUT_POST));
46 }
47
48 // force min size
49 if ($a_user_prefs['pagesize'] < 1)
50   $a_user_prefs['pagesize'] = 10;
51
52 if (isset($CONFIG['max_pagesize']) && ($a_user_prefs['pagesize'] > $CONFIG['max_pagesize']))
53   $a_user_prefs['pagesize'] = (int) $CONFIG['max_pagesize'];
54
55 if ($USER->save_prefs($a_user_prefs))
56   $OUTPUT->show_message('successfullysaved', 'confirmation');
57
58
59 // go to next step
60 rcmail_overwrite_action('preferences');
61
62 ?>