1: <?php
2: /**
3: * Caches the resource return values in class variables.
4: *
5: * PHP version 5
6: *
7: * @category Kolab
8: * @package Kolab_FreeBusy
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_FreeBusy
12: */
13:
14: /**
15: * Caches the resource return values in class variables.
16: *
17: * Copyright 2009-2012 Horde LLC (http://www.horde.org/)
18: *
19: * See the enclosed file COPYING for license information (LGPL). If you did not
20: * receive this file, see
21: * http://www.horde.org/licenses/lgpl21.
22: *
23: * @category Kolab
24: * @package Kolab_FreeBusy
25: * @author Gunnar Wrobel <wrobel@pardus.de>
26: * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
27: * @link http://pear.horde.org/index.php?package=Kolab_FreeBusy
28: */
29: class Horde_Kolab_FreeBusy_Resource_Decorator_Mcache
30: implements Horde_Kolab_FreeBusy_Resource
31: {
32: /**
33: * The decorated resource.
34: *
35: * @var Horde_Kolab_FreeBusy_Resource_Interface
36: */
37: private $_resource;
38:
39: /**
40: * The cached resource relevance.
41: *
42: * @var string
43: */
44: private $_relevance;
45:
46: /**
47: * The cached resource ACL.
48: *
49: * @var array
50: */
51: private $_acl;
52:
53: /**
54: * The cached resource attribute ACL.
55: *
56: * @var array
57: */
58: private $_attribute_acl;
59:
60: /**
61: * Constructor.
62: *
63: * @param Horde_Kolab_FreeBusy_Resource_Interface $resource The decorated resource.
64: */
65: public function __construct(
66: Horde_Kolab_FreeBusy_Resource $resource
67: ) {
68: $this->_resource = $resource;
69: }
70:
71: /**
72: * Return the name of the resource.
73: *
74: * @return string The name for the resource.
75: */
76: public function getName()
77: {
78: return $this->_resource->getName();
79: }
80:
81: /**
82: * Return the owner of the resource.
83: *
84: * @return Horde_Kolab_FreeBusy_Owner The resource owner.
85: */
86: public function getOwner()
87: {
88: return $this->_resource->getOwner();
89: }
90:
91: /**
92: * Connect to the resource.
93: *
94: * @return NULL
95: *
96: * @throws Horde_Kolab_FreeBusy_Exception If connecting to the resource
97: * failed.
98: */
99: public function connect()
100: {
101: $this->_resource->connect();
102: }
103:
104: /**
105: * Return for whom this resource exports relevant data.
106: *
107: * @return string The user type the exported data of this resource is
108: * relevant for.
109: *
110: * @throws Horde_Kolab_FreeBusy_Exception If retrieving the relevance
111: * information failed.
112: */
113: public function getRelevance()
114: {
115: if (!isset($this->_relevance)) {
116: $this->_relevance = $this->_resource->getRelevance();
117: }
118: return $this->_relevance;
119: }
120:
121: /**
122: * Fetch the resource ACL.
123: *
124: * @return array ACL for this resource.
125: *
126: * @throws Horde_Kolab_FreeBusy_Exception If retrieving the ACL information
127: * failed.
128: */
129: public function getAcl()
130: {
131: if (!isset($this->_acl)) {
132: $this->_acl = $this->_resource->getAcl();
133: }
134: return $this->_acl;
135: }
136:
137: /**
138: * Fetch the access controls on specific attributes of this
139: * resource.
140: *
141: * @return array Attribute ACL for this resource.
142: *
143: * @throws Horde_Kolab_FreeBusy_Exception If retrieving the attribute ACL
144: * information failed.
145: */
146: public function getAttributeAcl()
147: {
148: if (!isset($this->_attribute_acl)) {
149: $this->_attribute_acl = $this->_resource->getAttributeAcl();
150: }
151: return $this->_attribute_acl;
152: }
153:
154: /**
155: * Return the decorated resource.
156: *
157: * @return Horde_Kolab_FreeBusy_Resource_Interface The decorated resource.
158: */
159: protected function getResource()
160: {
161: return $this->_resource;
162: }
163: }
164: