1: <?php
2: /**
3: * Logs the free/busy 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 free/busy 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_Event_Decorator_Log
30: extends Horde_Kolab_FreeBusy_Resource_Decorator_Log
31: implements Horde_Kolab_FreeBusy_Resource_Event
32: {
33: /**
34: * Constructor.
35: *
36: * @param Horde_Kolab_FreeBusy_Resource_Interface $resource The decorated
37: * resource.
38: * @param mixed $logger The log handler. The
39: * class must at least
40: * provide the debug()
41: * method.
42: */
43: public function __construct(
44: Horde_Kolab_FreeBusy_Resource_Event $resource,
45: $logger
46: ) {
47: parent::__construct($resource, $logger);
48: }
49:
50: /**
51: * Lists all events in the given time range. *
52: *
53: * @param Horde_Date $startDate Start of range date object.
54: * @param Horde_Date $endDate End of range data object.
55: *
56: * @return array Events in the given time range.
57: *
58: * @throws Horde_Kolab_FreeBusy_Exception If retrieving the events failed.
59: */
60: public function listEvents(Horde_Date $startDate, Horde_Date $endDate)
61: {
62: $this->getLogger()->debug(
63: sprintf(
64: 'Listing events for resource %s between %s and %s.',
65: $this->getResource()->getName(),
66: //@todo: (string) is enough in Horde4
67: (string) $startDate->rfc2822DateTime(),
68: (string) $endDate->rfc2822DateTime()
69: )
70: );
71: $events = $this->getResource()->listEvents($startDate, $endDate);
72: $this->getLogger()->debug(
73: sprintf(
74: 'Found %s events.',
75: count($events)
76: )
77: );
78: return $events;
79: }
80: }
81: