1: <?php
2: /**
3: * Copyright 2013-2014 Horde LLC (http://www.horde.org/)
4: *
5: * See the enclosed file COPYING for license information (GPL). If you
6: * did not receive this file, see http://www.horde.org/licenses/gpl.
7: *
8: * @category Horde
9: * @copyright 2013-2014 Horde LLC
10: * @license http://www.horde.org/licenses/gpl GPL
11: * @package IMP
12: */
13:
14: /**
15: * Abstract object handling folder tree prefereces.
16: *
17: * @author Michael Slusarz <slusarz@horde.org>
18: * @category Horde
19: * @copyright 2013-2014 Horde LLC
20: * @license http://www.horde.org/licenses/gpl GPL
21: * @package IMP
22: *
23: * @property-read boolean $locked True if pref is locked.
24: */
25: class IMP_Ftree_Prefs implements ArrayAccess, Horde_Shutdown_Task
26: {
27: /**
28: * Preference data.
29: *
30: * @var array
31: */
32: protected $_data = array();
33:
34: /**
35: * Is the preference locked?
36: *
37: * @var boolean
38: */
39: protected $_locked;
40:
41: /**
42: */
43: public function __get($name)
44: {
45: switch ($name) {
46: case 'locked':
47: return $this->_locked;
48: }
49: }
50:
51: /* ArrayAccess methods. */
52:
53: /**
54: */
55: public function offsetExists($offset)
56: {
57: return true;
58: }
59:
60: /**
61: */
62: public function offsetGet($offset)
63: {
64: return isset($this->_data[strval($offset)]);
65: }
66:
67: /**
68: */
69: public function offsetSet($offset, $value)
70: {
71: if (!$this->locked && ($this[$offset] != $value)) {
72: if ($value) {
73: $this->_data[strval($offset)] = true;
74: } else {
75: unset($this->_data[strval($offset)]);
76: }
77:
78: Horde_Shutdown::add($this);
79: }
80: }
81:
82: /**
83: */
84: public function offsetUnset($offset)
85: {
86: $this[$offset] = false;
87: }
88:
89: /* Horde_Shutdown_Task method. */
90:
91: /**
92: */
93: public function shutdown()
94: {
95: }
96:
97: }
98: