]> git.donarmstrong.com Git - roundcube.git/blob - program/steps/utils/save_pref.inc
834f3fc17d5c6f5735b81ba76b6fcf9a1b78506a
[roundcube.git] / program / steps / utils / save_pref.inc
1 <?php
2 /*
3
4  +-----------------------------------------------------------------------+
5  | program/steps/utils/save_pref.inc                                     |
6  |                                                                       |
7  | This file is part of the Roundcube Webmail client                     |
8  | Copyright (C) 2005-2010, Roundcube Dev. - Switzerland                 |
9  | Licensed under the GNU GPL                                            |
10  |                                                                       |
11  | PURPOSE:                                                              |
12  |   Save preferences setting in database                                |
13  |                                                                       |
14  +-----------------------------------------------------------------------+
15  | Author: Aleksander Machniak <alec@alec.pl>                            |
16  +-----------------------------------------------------------------------+
17
18  $Id: save_pref.inc 3989 2010-09-25 13:03:53Z alec $
19
20 */
21
22 $name = get_input_value('_name', RCUBE_INPUT_POST);
23 $value = get_input_value('_value', RCUBE_INPUT_POST);
24
25 // save preference value
26 $RCMAIL->user->save_prefs(array($name => $value));
27
28 // update also session if requested
29 if ($sessname = get_input_value('_session', RCUBE_INPUT_POST)) {
30     // Support multidimensional arrays...
31     $vars = explode('/', $sessname);
32
33     // ... up to 3 levels
34     if (count($vars) == 1)
35         $_SESSION[$vars[0]] = $value;
36     else if (count($vars) == 2)
37         $_SESSION[$vars[0]][$vars[1]] = $value;
38     else if (count($vars) == 3)
39         $_SESSION[$vars[0]][$vars[1]][$vars[2]] = $value;
40 }
41
42 $OUTPUT->reset();
43 $OUTPUT->send();
44
45