1: <?php
2: /**
3: * Caches active sync parameters.
4: *
5: * PHP version 5
6: *
7: * @category Kolab
8: * @package Kolab_Storage
9: * @author Gunnar Wrobel <wrobel@pardus.de>
10: * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
11: * @link http://pear.horde.org/index.php?package=Kolab_Storage
12: */
13:
14: /**
15: * Caches active sync parameters.
16: *
17: * Copyright 2011-2012 Horde LLC (http://www.horde.org/)
18: *
19: * See the enclosed file COPYING for license information (LGPL). If you
20: * did not receive this file, see http://www.horde.org/licenses/lgpl21.
21: *
22: * @since Horde_Kolab_Storage 1.1.0
23: *
24: * @category Kolab
25: * @package Kolab_Storage
26: * @author Gunnar Wrobel <wrobel@pardus.de>
27: * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
28: * @link http://pear.horde.org/index.php?package=Kolab_Storage
29: */
30: class Horde_Kolab_Storage_List_Query_ActiveSync_Cache
31: extends Horde_Kolab_Storage_List_Query_ActiveSync_Base
32: {
33: /** The active sync information */
34: const ACTIVE_SYNC = 'ACTIVE_SYNC';
35:
36: /**
37: * The list cache.
38: *
39: * @var Horde_Kolab_Storage_Cache_List
40: */
41: private $_list_cache;
42:
43: /**
44: * The cached active sync data.
45: *
46: * @var array
47: */
48: private $_active_sync;
49:
50: /**
51: * Constructor.
52: *
53: * @param Horde_Kolab_Storage_List $list The queriable list.
54: * @param array $params Additional parameters.
55: */
56: public function __construct(Horde_Kolab_Storage_List $list,
57: $params)
58: {
59: parent::__construct($list, $params);
60: $this->_list_cache = $params['cache'];
61: if ($this->_list_cache->hasQuery(self::ACTIVE_SYNC)) {
62: $this->_active_sync = $this->_list_cache->getQuery(self::ACTIVE_SYNC);
63: } else {
64: $this->_active_sync = array();
65: }
66: }
67:
68: /**
69: * Returns the active sync settings.
70: *
71: * @param string $folder The folder name.
72: *
73: * @return array The folder active sync parameters.
74: */
75: public function getActiveSync($folder)
76: {
77: if (!isset($this->_active_sync[$folder])) {
78: $this->_active_sync[$folder] = parent::getActiveSync($folder);
79: $this->_list_cache->setQuery(self::ACTIVE_SYNC, $this->_active_sync);
80: $this->_list_cache->save();
81: }
82: return $this->_active_sync[$folder];
83: }
84:
85: /**
86: * Set the active sync settings.
87: *
88: * @param string $folder The folder name.
89: * @param array $data The active sync settings.
90: *
91: * @return string The encoded share parameters.
92: */
93: public function setActiveSync($folder, array $data)
94: {
95: parent::setActiveSync($folder, $data);
96: $this->_active_sync[$folder] = $data;
97: $this->_list_cache->setQuery(self::ACTIVE_SYNC, $this->_active_sync);
98: $this->_list_cache->save();
99: }
100:
101: /**
102: * Create a new folder.
103: *
104: * @param string $folder The path of the folder to create.
105: * @param string $type An optional type for the folder.
106: *
107: * @return NULL
108: */
109: public function createFolder($folder, $type = null)
110: {
111: }
112:
113: /**
114: * Delete a folder.
115: *
116: * @param string $folder The path of the folder to delete.
117: *
118: * @return NULL
119: */
120: public function deleteFolder($folder)
121: {
122: unset($this->_active_sync[$folder]);
123: $this->_list_cache->setQuery(self::ACTIVE_SYNC, $this->_active_sync);
124: $this->_list_cache->save();
125: }
126:
127: /**
128: * Rename a folder.
129: *
130: * @param string $old The old path of the folder.
131: * @param string $new The new path of the folder.
132: *
133: * @return NULL
134: */
135: public function renameFolder($old, $new)
136: {
137: if (isset($this->_active_sync[$old])) {
138: $this->_active_sync[$new] = $this->_active_sync[$old];
139: unset($this->_active_sync[$old]);
140: $this->_list_cache->setQuery(self::ACTIVE_SYNC, $this->_active_sync);
141: }
142: $this->_list_cache->save();
143: }
144:
145: /**
146: * Return the last sync stamp.
147: *
148: * @return string The stamp.
149: */
150: public function getStamp()
151: {
152: return $this->_list->getStamp();
153: }
154:
155: /**
156: * Synchronize the ACL information with the information from the backend.
157: *
158: * @param array $params Additional parameters.
159: *
160: * @return NULL
161: */
162: public function synchronize($params = array())
163: {
164: $this->_active_sync = array();
165: }
166: }