Overview

Packages

  • Kronolith
  • None

Classes

  • Kronolith
  • Kronolith_Ajax_Application
  • Kronolith_Ajax_Imple_ContactAutoCompleter
  • Kronolith_Ajax_Imple_Embed
  • Kronolith_Ajax_Imple_TagActions
  • Kronolith_Ajax_Imple_TagAutoCompleter
  • Kronolith_Api
  • Kronolith_Calendar
  • Kronolith_Calendar_External
  • Kronolith_Calendar_External_Tasks
  • Kronolith_Calendar_Holiday
  • Kronolith_Calendar_Internal
  • Kronolith_Calendar_Remote
  • Kronolith_Calendar_Resource
  • Kronolith_Calendars_Base
  • Kronolith_Calendars_Default
  • Kronolith_Calendars_Kolab
  • Kronolith_Day
  • Kronolith_Driver
  • Kronolith_Driver_Holidays
  • Kronolith_Driver_Horde
  • Kronolith_Driver_Ical
  • Kronolith_Driver_Kolab
  • Kronolith_Driver_Mock
  • Kronolith_Driver_Resource
  • Kronolith_Driver_Sql
  • Kronolith_Event
  • Kronolith_Event_Holidays
  • Kronolith_Event_Horde
  • Kronolith_Event_Ical
  • Kronolith_Event_Kolab
  • Kronolith_Event_Resource
  • Kronolith_Event_Sql
  • Kronolith_Exception
  • Kronolith_Factory_Calendars
  • Kronolith_Factory_Geo
  • Kronolith_Form_CreateCalendar
  • Kronolith_Form_CreateResource
  • Kronolith_Form_CreateResourceGroup
  • Kronolith_Form_DeleteCalendar
  • Kronolith_Form_DeleteResource
  • Kronolith_Form_DeleteResourceGroup
  • Kronolith_Form_EditCalendar
  • Kronolith_Form_EditRemoteCalendar
  • Kronolith_Form_EditResource
  • Kronolith_Form_EditResourceGroup
  • Kronolith_Form_SubscribeRemoteCalendar
  • Kronolith_Form_UnsubscribeRemoteCalendar
  • Kronolith_FreeBusy
  • Kronolith_FreeBusy_View
  • Kronolith_FreeBusy_View_Day
  • Kronolith_FreeBusy_View_Month
  • Kronolith_FreeBusy_View_Week
  • Kronolith_FreeBusy_View_Workweek
  • Kronolith_Geo_Base
  • Kronolith_Geo_Mysql
  • Kronolith_Geo_Sql
  • Kronolith_LoginTasks_SystemTask_Upgrade
  • Kronolith_LoginTasks_Task_PurgeEvents
  • Kronolith_Notification_Listener_AjaxStatus
  • Kronolith_Resource
  • Kronolith_Resource_Base
  • Kronolith_Resource_Group
  • Kronolith_Resource_Single
  • Kronolith_Storage
  • Kronolith_Storage_Kolab
  • Kronolith_Storage_Sql
  • Kronolith_Tagger
  • Kronolith_Test
  • Kronolith_View_Day
  • Kronolith_View_DeleteEvent
  • Kronolith_View_EditEvent
  • Kronolith_View_Event
  • Kronolith_View_ExportEvent
  • Kronolith_View_Month
  • Kronolith_View_Week
  • Kronolith_View_WorkWeek
  • Kronolith_View_Year
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * The Kronolith_Driver_Horde class implements the Kronolith_Driver API for
  4:  * time objects retrieved from other Horde applications.
  5:  *
  6:  * Possible driver parameters:
  7:  *
  8:  * Copyright 2009-2012 Horde LLC (http://www.horde.org/)
  9:  *
 10:  * See the enclosed file COPYING for license information (GPL). If you
 11:  * did not receive this file, see http://www.horde.org/licenses/gpl.
 12:  *
 13:  * @author  Jan Schneider <jan@horde.org>
 14:  * @package Kronolith
 15:  */
 16: class Kronolith_Driver_Horde extends Kronolith_Driver
 17: {
 18:     /**
 19:      * The API (application) of the current calendar.
 20:      *
 21:      * @var string
 22:      */
 23:     public $api;
 24: 
 25:     public function open($calendar)
 26:     {
 27:         parent::open($calendar);
 28:         list($this->api,) = explode('/', $this->calendar, 2);
 29:     }
 30: 
 31:     public function listAlarms($date, $fullevent = false)
 32:     {
 33:         return array();
 34:     }
 35: 
 36:     /**
 37:      * Lists all events in the time range, optionally restricting results to
 38:      * only events with alarms.
 39:      *
 40:      * @param Horde_Date $startDate      Start of range date object.
 41:      * @param Horde_Date $endDate        End of range data object.
 42:      * @param boolean $showRecurrence    Return every instance of a recurring
 43:      *                                   event? If false, will only return
 44:      *                                   recurring events once inside the
 45:      *                                   $startDate - $endDate range.
 46:      * @param boolean $hasAlarm          Only return events with alarms?
 47:      * @param boolean $json              Store the results of the events'
 48:      *                                   toJson() method?
 49:      * @param boolean $coverDates        Whether to add the events to all days
 50:      *                                   that they cover.
 51:      *
 52:      * @return array  Events in the given time range.
 53:      * @throws Kronolith_Exception
 54:      */
 55:     public function listEvents($startDate = null, $endDate = null,
 56:                                $showRecurrence = false, $hasAlarm = false,
 57:                                $json = false, $coverDates = true)
 58:     {
 59:         list($this->api, $category) = explode('/', $this->calendar, 2);
 60:         if (!$this->_params['registry']->hasMethod($this->api . '/listTimeObjects')) {
 61:             return array();
 62:         }
 63: 
 64:         if (is_null($startDate)) {
 65:             $startDate = new Horde_Date(array('mday' => 1,
 66:                                               'month' => 1,
 67:                                               'year' => 0000));
 68:         }
 69:         if (is_null($endDate)) {
 70:             $endDate = new Horde_Date(array('mday' => 31,
 71:                                             'month' => 12,
 72:                                             'year' => 9999));
 73:         }
 74: 
 75:         $startDate = clone $startDate;
 76:         $startDate->hour = $startDate->min = $startDate->sec = 0;
 77:         $endDate = clone $endDate;
 78:         $endDate->hour = 23;
 79:         $endDate->min = $endDate->sec = 59;
 80: 
 81:         try {
 82:             $eventsList = $this->_params['registry']->call($this->api . '/listTimeObjects', array(array($category), $startDate, $endDate));
 83:         } catch (Horde_Exception $e) {
 84:             throw new Kronolith_Exception($e);
 85:         }
 86: 
 87:         $results = array();
 88:         foreach ($eventsList as $eventsListItem) {
 89:             $event = new Kronolith_Event_Horde($this, $eventsListItem);
 90: 
 91:             /* Ignore events out of the period. */
 92:             if (
 93:                 /* Starts after the period. */
 94:                 $event->start->compareDateTime($endDate) > 0 ||
 95:                 /* End before the period and doesn't recur. */
 96:                 (!$event->recurs() &&
 97:                  $event->end->compareDateTime($startDate) < 0) ||
 98:                 /* Recurs and ... */
 99:                 ($event->recurs() &&
100:                  /* ... has a recurrence end before the period. */
101:                  ($event->recurrence->hasRecurEnd() &&
102:                   $event->recurrence->recurEnd->compareDateTime($startDate) < 0))) {
103:                 continue;
104:             }
105: 
106:             Kronolith::addEvents($results, $event, $startDate,
107:                                  $endDate, $showRecurrence, $json, $coverDates);
108:         }
109: 
110:         return $results;
111:     }
112: 
113:     /**
114:      * Updates an existing event in the backend.
115:      *
116:      * @param Kronolith_Event_Horde $event  The event to save.
117:      *
118:      * @return string  The event id.
119:      * @throws Kronolith_Exception
120:      */
121:     protected function _updateEvent(Kronolith_Event $event)
122:     {
123:         if (!isset($this->api)) {
124:             list($this->api, $category) = explode('/', $this->calendar, 2);
125:         }
126:         try {
127:             $this->_params['registry']->call($this->api . '/saveTimeObject', array($event->toTimeobject()));
128:         } catch (Horde_Exception $e) {
129:             throw new Kronolith_Exception($e);
130:         }
131: 
132:         return $event->timeobject['id'];
133:     }
134: 
135:     /**
136:      * @todo: implement getTimeObject in timeobjects API.
137:      * @throws Kronolith_Exception
138:      * @throws Horde_Exception_NotFound
139:      */
140:     public function getEvent($eventId = null, $start = null)
141:     {
142:         $end = null;
143:         if ($start) {
144:             $start = new Horde_Date($start);
145:             $end = clone $start;
146:             $end->mday++;
147:         }
148: 
149:         $events = $this->listEvents($start, $end, (bool)$start);
150:         foreach ($events as $day) {
151:             if (isset($day[$eventId])) {
152:                 return $day[$eventId];
153:             }
154:         }
155: 
156:         throw new Horde_Exception_NotFound(_("Event not found"));
157:     }
158: 
159: }
160: 
API documentation generated by ApiGen