1: <?php
2: /**
3: * Session cache implementation for the preferences system.
4: *
5: * Copyright 2010-2012 Horde LLC (http://www.horde.org/)
6: *
7: * See the enclosed file COPYING for license information (LGPL). If you
8: * did not receive this file, see http://www.horde.org/licenses/lgpl21.
9: *
10: * @author Michael Slusarz <slusarz@horde.org>
11: * @category Horde
12: * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
13: * @package Prefs
14: */
15: class Horde_Prefs_Cache_Session extends Horde_Prefs_Cache_Base
16: {
17: /**
18: * Session key.
19: *
20: * @var string
21: */
22: protected $_key;
23:
24: /**
25: */
26: public function __construct($user, array $params = array())
27: {
28: parent::__construct($user, $params);
29:
30: $this->_key = 'horde_prefs_cache_' . $this->_params['user'];
31: }
32:
33: /**
34: */
35: public function get($scope)
36: {
37: return isset($_SESSION[$this->_key][$scope])
38: ? $_SESSION[$this->_key][$scope]
39: : false;
40: }
41:
42: /**
43: */
44: public function store($scope_ob)
45: {
46: $_SESSION[$this->_key][$scope_ob->getScope()] = $scope_ob;
47: }
48:
49: /**
50: */
51: public function remove($scope = null)
52: {
53: if (is_null($scope)) {
54: unset($_SESSION[$this->_key]);
55: } else {
56: unset($_SESSION[$this->_key][$scope]);
57: }
58: }
59:
60: }
61: