1: <?php
2: /**
3: * A synchronization decorator for the Kolab storage handler.
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: * A synchronization decorator for the Kolab storage handler.
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: * @category Kolab
23: * @package Kolab_Storage
24: * @author Gunnar Wrobel <wrobel@pardus.de>
25: * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
26: * @link http://pear.horde.org/index.php?package=Kolab_Storage
27: */
28: class Horde_Kolab_Storage_Decorator_Synchronization
29: implements Horde_Kolab_Storage
30: {
31: /**
32: * The decorated storage handler.
33: *
34: * @var Horde_Kolab_Storage
35: */
36: private $_storage;
37:
38: /**
39: * The synchronization strategy
40: *
41: * @var Horde_Kolab_Storage_Synchronization
42: */
43: private $_synchronization;
44:
45: /**
46: * Constructor.
47: *
48: * @param Horde_Kolab_Storage $storage The storage handler.
49: * @param Horde_Kolab_Storage_Synchronization $synchronization The synchronization strategy.
50: */
51: public function __construct(Horde_Kolab_Storage $storage,
52: Horde_Kolab_Storage_Synchronization $synchronization)
53: {
54: $this->_storage = $storage;
55: $this->_synchronization = $synchronization;
56: }
57:
58: /**
59: * Get the folder list object.
60: *
61: * @return Horde_Kolab_Storage_List The handler for the list of folders
62: * present in the Kolab backend.
63: */
64: public function getList()
65: {
66: $list = $this->_storage->getList();
67: $this->_synchronization->synchronizeList($list);
68: return $list;
69: }
70:
71: /**
72: * Get a folder list object for a "system" user.
73: *
74: * @param string $type The type of system user.
75: *
76: * @return Horde_Kolab_Storage_List The handler for the list of folders
77: * present in the Kolab backend.
78: */
79: public function getSystemList($type)
80: {
81: $list = $this->_storage->getSystemList($type);
82: $this->_synchronization->synchronizeList($list);
83: return $list;
84: }
85:
86: /**
87: * Get a Folder object.
88: *
89: * @param string $folder The folder name.
90: *
91: * @return Horde_Kolab_Storage_Folder The Kolab folder object.
92: */
93: public function getFolder($folder)
94: {
95: return $this->getList()->getFolder($folder);
96: }
97:
98: /**
99: * Return a data handler for accessing data in the specified
100: * folder.
101: *
102: * @param string $folder The name of the folder.
103: * @param string $object_type The type of data we want to
104: * access in the folder.
105: * @param int $data_version Format version of the object data.
106: *
107: * @return Horde_Kolab_Data The data object.
108: */
109: public function getData($folder, $object_type = null, $data_version = 1)
110: {
111: $data = $this->_storage->getData($folder, $object_type, $data_version);
112: $this->_synchronization->synchronizeData($data);
113: return $data;
114: }
115: }