1: <?php
2: /**
3: * Logs the resource access.
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: * Logs the resource access.
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_Log
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 logger.
41: *
42: * @var mixed
43: */
44: private $_logger;
45:
46: /**
47: * Constructor.
48: *
49: * @param Horde_Kolab_FreeBusy_Resource_Interface $resource The decorated
50: * resource.
51: * @param mixed $logger The log handler. The
52: * class must at least
53: * provide the debug()
54: * method.
55: */
56: public function __construct(
57: Horde_Kolab_FreeBusy_Resource $resource,
58: $logger
59: ) {
60: $this->_resource = $resource;
61: $this->_logger = $logger;
62: }
63:
64: protected function getLogger()
65: {
66: return $this->_logger;
67: }
68:
69: protected function getResource()
70: {
71: return $this->_resource;
72: }
73:
74: /**
75: * Connect to the resource.
76: *
77: * @return NULL
78: *
79: * @throws Horde_Kolab_FreeBusy_Exception If connecting to the resource
80: * failed.
81: */
82: public function connect()
83: {
84: $this->_resource->connect();
85: $this->logger->debug(
86: sprintf(
87: 'Successfully connected to resource %s',
88: $this->_resource->getName()
89: )
90: );
91: }
92:
93: /**
94: * Return the name of the resource.
95: *
96: * @return string The name for the resource.
97: */
98: public function getName()
99: {
100: return $this->_resource->getName();
101: }
102:
103: /**
104: * Return the owner of the resource.
105: *
106: * @return Horde_Kolab_FreeBusy_Owner The resource owner.
107: */
108: public function getOwner()
109: {
110: return $this->_resource->getOwner();
111: }
112:
113: /**
114: * Return for whom this resource exports relevant data.
115: *
116: * @return string The user type the exported data of this resource is
117: * relevant for.
118: *
119: * @throws Horde_Kolab_FreeBusy_Exception If retrieving the relevance
120: * information failed.
121: */
122: public function getRelevance()
123: {
124: $relevance = $this->_resource->getRelevance();
125: if (empty($relevance)) {
126: $this->_logger->debug(
127: sprintf(
128: 'No relevance value found for %s',
129: $this->_resource->getName()
130: )
131: );
132: } else {
133: $this->_logger->debug(
134: sprintf(
135: 'Relevance for %s is %s',
136: $this->_resource->getName(),
137: $relevance
138: )
139: );
140: }
141: return $relevance;
142: }
143:
144: /**
145: * Fetch the resource ACL.
146: *
147: * @return array ACL for this resource.
148: *
149: * @throws Horde_Kolab_FreeBusy_Exception If retrieving the ACL information
150: * failed.
151: */
152: public function getAcl()
153: {
154: $acl = $this->_resource->getAcl();
155: if (empty($acl)) {
156: $this->_logger->debug(
157: sprintf(
158: 'No ACL found for %s',
159: $this->_resource->getName()
160: )
161: );
162: } else {
163: $this->_logger->debug(
164: sprintf(
165: 'ACL for %s is %s',
166: $this->_resource->getName(),
167: serialize($acl)
168: )
169: );
170: }
171: return $acl;
172: }
173:
174: /**
175: * Fetch the access controls on specific attributes of this
176: * resource.
177: *
178: * @return array Attribute ACL for this resource.
179: *
180: * @throws Horde_Kolab_FreeBusy_Exception If retrieving the attribute ACL
181: * information failed.
182: */
183: public function getAttributeAcl()
184: {
185: $attribute_acl = $this->_resource->getAttributeAcl();
186: if (empty($attribute_acl)) {
187: $this->_logger->debug(
188: sprintf(
189: 'No attribute ACL found for %s',
190: $this->_resource->getName()
191: )
192: );
193: } else {
194: $this->_logger->debug(
195: sprintf(
196: 'Attribute ACL for %s is %s',
197: $this->_resource->getName(),
198: serialize($attribute_acl)
199: )
200: );
201: }
202: return $attribute_acl;
203: }
204: }
205: