1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12:
13:
14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27:
28: class Horde_Kolab_Storage_List_Query_Share_Cache
29: extends Horde_Kolab_Storage_List_Query_Share_Base
30: {
31:
32: const DESCRIPTIONS = 'SHARE_DESCRIPTIONS';
33:
34:
35: const PARAMETERS = 'SHARE_PARAMETERS';
36:
37: 38: 39: 40: 41:
42: private $_list_cache;
43:
44: 45: 46: 47: 48:
49: private $_descriptions;
50:
51: 52: 53: 54: 55:
56: private $_parameters;
57:
58: 59: 60: 61: 62: 63:
64: public function __construct(Horde_Kolab_Storage_List $list,
65: $params)
66: {
67: parent::__construct($list, $params);
68: $this->_list_cache = $params['cache'];
69: if ($this->_list_cache->hasQuery(self::DESCRIPTIONS)) {
70: $this->_descriptions = $this->_list_cache->getQuery(self::DESCRIPTIONS);
71: } else {
72: $this->_descriptions = array();
73: }
74: if ($this->_list_cache->hasLongTerm(self::PARAMETERS)) {
75: $this->_parameters = $this->_list_cache->getLongTerm(self::PARAMETERS);
76: } else {
77: $this->_parameters = array();
78: }
79: }
80:
81: 82: 83: 84: 85: 86: 87:
88: public function getDescription($folder)
89: {
90: if (!isset($this->_descriptions[$folder])) {
91: $this->_descriptions[$folder] = parent::getDescription($folder);
92: $this->_list_cache->setQuery(self::DESCRIPTIONS, $this->_descriptions);
93: $this->_list_cache->save();
94: }
95: return $this->_descriptions[$folder];
96: }
97:
98: 99: 100: 101: 102: 103: 104:
105: public function getParameters($folder)
106: {
107: if (!isset($this->_parameters[$folder])) {
108: $this->_parameters[$folder] = parent::getParameters($folder);
109:
110: $this->_list_cache->setLongTerm(self::PARAMETERS, $this->_parameters);
111: $this->_list_cache->save();
112: }
113: return $this->_parameters[$folder];
114: }
115:
116: 117: 118: 119: 120: 121: 122: 123:
124: public function setDescription($folder, $description)
125: {
126: parent::setDescription($folder, $description);
127: $this->_descriptions[$folder] = $description;
128: $this->_list_cache->setQuery(self::DESCRIPTIONS, $this->_descriptions);
129: $this->_list_cache->save();
130: }
131:
132: 133: 134: 135: 136: 137: 138: 139:
140: public function setParameters($folder, array $parameters)
141: {
142: parent::setParameters($folder, $parameters);
143: $this->_parameters[$folder] = $parameters;
144: $this->_list_cache->setLongTerm(self::PARAMETERS, $this->_parameters);
145: $this->_list_cache->save();
146: }
147:
148: 149: 150: 151: 152: 153: 154: 155:
156: public function createFolder($folder, $type = null)
157: {
158: }
159:
160: 161: 162: 163: 164: 165: 166:
167: public function deleteFolder($folder)
168: {
169: unset($this->_descriptions[$folder]);
170: unset($this->_parameters[$folder]);
171: $this->_list_cache->setQuery(self::DESCRIPTIONS, $this->_descriptions);
172: $this->_list_cache->setLongTerm(self::PARAMETERS, $this->_parameters);
173: $this->_list_cache->save();
174: }
175:
176: 177: 178: 179: 180: 181: 182: 183:
184: public function renameFolder($old, $new)
185: {
186: if (isset($this->_descriptions[$old])) {
187: $this->_descriptions[$new] = $this->_descriptions[$old];
188: unset($this->_descriptions[$old]);
189: $this->_list_cache->setQuery(self::DESCRIPTIONS, $this->_descriptions);
190: }
191: if (isset($this->_parameters[$old])) {
192: $this->_parameters[$new] = $this->_parameters[$old];
193: unset($this->_parameters[$old]);
194: $this->_list_cache->setLongTerm(self::PARAMETERS, $this->_parameters);
195: }
196: $this->_list_cache->save();
197: }
198:
199: 200: 201: 202: 203:
204: public function getStamp()
205: {
206: return $this->_list->getStamp();
207: }
208:
209: 210: 211: 212: 213: 214: 215:
216: public function synchronize($params = array())
217: {
218: $this->_descriptions = array();
219: }
220: }