| 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, 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$ |
|---|
| 19 | |
|---|
| 20 | */ |
|---|
| 21 | |
|---|
| 22 | $a_user_prefs = $_SESSION['user_prefs']; |
|---|
| 23 | if (!is_array($a_user_prefs)) |
|---|
| 24 | $a_user_prefs = array(); |
|---|
| 25 | |
|---|
| 26 | |
|---|
| 27 | $a_user_prefs['timezone'] = isset($_POST['_timezone']) ? (int)$_POST['_timezone'] : $CONFIG['timezone']; |
|---|
| 28 | $a_user_prefs['pagesize'] = is_numeric($_POST['_pagesize']) ? (int)$_POST['_pagesize'] : $CONFIG['pagesize']; |
|---|
| 29 | $a_user_prefs['prefer_html'] = isset($_POST['_prefer_html']) ? TRUE : FALSE; |
|---|
| 30 | |
|---|
| 31 | // MM: Date format toggle (Pretty / Standard) |
|---|
| 32 | $a_user_prefs['prettydate'] = isset($_POST['_pretty_date']) ? TRUE : FALSE; |
|---|
| 33 | |
|---|
| 34 | if (isset($_POST['_language'])) |
|---|
| 35 | { |
|---|
| 36 | $sess_user_lang = $_SESSION['user_lang'] = $_POST['_language']; |
|---|
| 37 | rcmail_set_locale($sess_user_lang); |
|---|
| 38 | } |
|---|
| 39 | |
|---|
| 40 | |
|---|
| 41 | $DB->query("UPDATE ".get_table_name('users')." |
|---|
| 42 | SET preferences=?, |
|---|
| 43 | language=? |
|---|
| 44 | WHERE user_id=?", |
|---|
| 45 | serialize($a_user_prefs), |
|---|
| 46 | $sess_user_lang, |
|---|
| 47 | $_SESSION['user_id']); |
|---|
| 48 | |
|---|
| 49 | if ($DB->affected_rows()) |
|---|
| 50 | { |
|---|
| 51 | show_message('successfullysaved', 'confirmation'); |
|---|
| 52 | |
|---|
| 53 | $_SESSION['user_prefs'] = $a_user_prefs; |
|---|
| 54 | $CONFIG = array_merge($CONFIG, $a_user_prefs); |
|---|
| 55 | } |
|---|
| 56 | |
|---|
| 57 | |
|---|
| 58 | // go to next step |
|---|
| 59 | $_action = 'preferences'; |
|---|
| 60 | |
|---|
| 61 | // overwrite action variable |
|---|
| 62 | $OUTPUT->add_script(sprintf("\n%s.set_env('action', '%s');", $JS_OBJECT_NAME, $_action)); |
|---|
| 63 | |
|---|
| 64 | ?> |
|---|