Kronolith_Driver_Ical
extends Kronolith_Driver
in package
The Kronolith_Driver_Ical class implements the Kronolith_Driver API for iCalendar data.
Possible driver parameters:
- url: The location of the remote calendar.
- proxy: A hash with HTTP proxy information.
- user: The user name for HTTP Basic Authentication.
- password: The password for HTTP Basic Authentication.
Tags
Table of Contents
- $backgroundColor : string
- The HTML background color to be used for this event.
- $calendar : string
- The current calendar.
- $foregroundColor : string
- The HTML foreground color to be used for this event.
- $_cache : array<string|int, mixed>
- Cache events as we fetch them to avoid fetching or parsing the same event twice.
- $_client : Client
- DAV client object.
- $_davSupport : array<string|int, mixed>
- A list of DAV support levels.
- $_params : array<string|int, mixed>
- A hash containing any parameters for the current driver.
- $_permission : int
- The Horde_Perms permissions mask matching the CalDAV ACL.
- $_errormsg : string
- An error message to throw when something is wrong.
- __construct() : mixed
- Constructor.
- backgroundColor() : string
- Returns the background color of the current calendar.
- colors() : array<string|int, mixed>
- Returns the colors of the current calendar.
- countEvents() : int
- Returns the number of events in the current calendar.
- delete() : mixed
- Stub to be overridden in the child class.
- deleteEvent() : mixed
- Deletes an event.
- exists() : mixed
- Stub for child class to override if it can implement.
- filterEventsByCalendar() : mixed
- Stub to be overridden in the child class if it can implement.
- getByUID() : mixed
- Stub to be overridden in the child class.
- getCalendarInfo() : array<string|int, mixed>
- Returns calendar information.
- getEvent() : mixed
- Stub to be overridden in the child class.
- getParam() : mixed
- Returns a configuration for this driver.
- getPermission() : int
- Returns the permissions for the current calendar.
- getRemoteCalendar() : Horde_Icalendar
- Fetches a remote calendar into the cache and return the data.
- initialize() : mixed
- Stub to initiate a driver.
- isCalDAV() : bool
- Returns whether the remote calendar is a CalDAV server, and propagates the $_davSupport propery with the server's DAV capabilities.
- listAlarms() : mixed
- Stub to be overridden in the child class.
- listEvents() : mixed
- Lists all events in the time range, optionally restricting results to only events with alarms.
- move() : mixed
- Moves an event to a new calendar.
- nextRecurrence() : Horde_Date|bool
- Finds the next recurrence of $eventId that's after $afterDate.
- open() : mixed
- Selects a calendar as the currently opened calendar.
- removeUserData() : mixed
- Stub for child class to override if it can implement.
- saveEvent() : string
- Saves an event in the backend.
- search() : array<string|int, mixed>
- Searches a calendar.
- setParam() : mixed
- Sets a configuration for this driver.
- setParams() : mixed
- Sets all configuration parameters for this driver.
- supportsTimezones() : bool
- Returns whether this driver supports per-event timezones.
- synchronize() : mixed
- Synchronize if driver needs to.
- _addEvent() : string
- Adds an event to the backend.
- _addTags() : mixed
- Helper function to add tags from a newly creted event to the tagger.
- _convertEvents() : array<string|int, mixed>
- Converts all components of a Horde_Icalendar container into a Kronolith_Event list.
- _deleteEvent() : Kronolith_Event
- Deletes an event.
- _getClient() : Client
- Returns a configured, cached DAV client.
- _getRemoteEvents() : array<string|int, mixed>
- Fetches a remote calendar and converts it to Kronolith_Event objects.
- _getUrl() : string
- Returns the URL of this calendar.
- _handleNotifications() : mixed
- Wrapper for sending notifications, so that we can overwrite this action in Kronolith_Driver_Resource.
- _listCalDAVEvents() : array<string|int, mixed>
- Lists all events in the time range, optionally restricting results to only events with alarms.
- _listEvents() : mixed
- Lists all events in the time range, optionally restricting results to only events with alarms.
- _listWebDAVEvents() : array<string|int, mixed>
- Lists all events in the time range, optionally restricting results to only events with alarms.
- _move() : mixed
- Stub to be overridden in the child class.
- _processComponents() : mixed
- Processes the components of a Horde_Icalendar container into an event list.
- _request() : array<string|int, mixed>
- Sends a CalDAV request.
- _saveEvent() : ResponseInterface
- Updates an existing event in the backend.
- _updateEvent() : string
- Updates an existing event in the backend.
- _updateTags() : mixed
- Helper function to update an existing event's tags to tagger storage.
Properties
$backgroundColor
The HTML background color to be used for this event.
public
string
$backgroundColor
= '#ddd'
$calendar
The current calendar.
public
string
$calendar
$foregroundColor
The HTML foreground color to be used for this event.
public
string
$foregroundColor
= '#000'
$_cache
Cache events as we fetch them to avoid fetching or parsing the same event twice.
protected
array<string|int, mixed>
$_cache
= array()
$_client
DAV client object.
protected
Client
$_client
$_davSupport
A list of DAV support levels.
protected
array<string|int, mixed>
$_davSupport
$_params
A hash containing any parameters for the current driver.
protected
array<string|int, mixed>
$_params
= array()
$_permission
The Horde_Perms permissions mask matching the CalDAV ACL.
protected
int
$_permission
$_errormsg
An error message to throw when something is wrong.
private
string
$_errormsg
Methods
__construct()
Constructor.
public
__construct([array<string|int, mixed> $params = array() ][, string $errormsg = null ]) : mixed
Just stores the $params in our newly-created object. All other work is done by .
Parameters
- $params : array<string|int, mixed> = array()
-
Any parameters needed for this driver.
- $errormsg : string = null
-
A custom error message to use.
Return values
mixed —backgroundColor()
Returns the background color of the current calendar.
public
backgroundColor() : string
Return values
string —The calendar color.
colors()
Returns the colors of the current calendar.
public
colors() : array<string|int, mixed>
Return values
array<string|int, mixed> —The calendar background and foreground color.
countEvents()
Returns the number of events in the current calendar.
public
countEvents() : int
Tags
Return values
int —The number of events.
delete()
Stub to be overridden in the child class.
public
delete(mixed $calendar) : mixed
Note: This method only "Purges" the calendar - removing the events, it doesn't remove the calendar itself.
Parameters
- $calendar : mixed
Tags
Return values
mixed —deleteEvent()
Deletes an event.
public
deleteEvent(mixed $eventId[, bool $silent = false ]) : mixed
Parameters
- $eventId : mixed
-
Either the event id to delete, or the event object.
- $silent : bool = false
-
Don't send notifications, used when deleting events in bulk from maintenance tasks.
Tags
Return values
mixed —exists()
Stub for child class to override if it can implement.
public
exists(mixed $uid[, mixed $calendar_id = null ]) : mixed
Parameters
- $uid : mixed
- $calendar_id : mixed = null
Tags
Return values
mixed —filterEventsByCalendar()
Stub to be overridden in the child class if it can implement.
public
filterEventsByCalendar(mixed $uids, mixed $calendar) : mixed
Parameters
- $uids : mixed
- $calendar : mixed
Tags
Return values
mixed —getByUID()
Stub to be overridden in the child class.
public
getByUID(mixed $uid[, mixed $calendars = null ][, mixed $getAll = false ]) : mixed
Parameters
- $uid : mixed
- $calendars : mixed = null
- $getAll : mixed = false
Tags
Return values
mixed —getCalendarInfo()
Returns calendar information.
public
getCalendarInfo() : array<string|int, mixed>
Return values
array<string|int, mixed> —A hash with the keys 'name', 'desc', and 'color'.
getEvent()
Stub to be overridden in the child class.
public
getEvent([mixed $eventId = null ]) : mixed
Parameters
- $eventId : mixed = null
Tags
Return values
mixed —getParam()
Returns a configuration for this driver.
public
getParam(string $param) : mixed
Parameters
- $param : string
-
A parameter name.
Return values
mixed —The parameter value or null if not set.
getPermission()
Returns the permissions for the current calendar.
public
getPermission() : int
Return values
int —A Horde_Perms permission bit mask.
getRemoteCalendar()
Fetches a remote calendar into the cache and return the data.
public
getRemoteCalendar([bool $cache = true ]) : Horde_Icalendar
Parameters
- $cache : bool = true
-
Whether to return data from the cache.
Tags
Return values
Horde_Icalendar —The calendar data.
initialize()
Stub to initiate a driver.
public
initialize() : mixed
Tags
Return values
mixed —isCalDAV()
Returns whether the remote calendar is a CalDAV server, and propagates the $_davSupport propery with the server's DAV capabilities.
public
isCalDAV() : bool
Tags
Return values
bool —True if the remote calendar is a CalDAV server.
listAlarms()
Stub to be overridden in the child class.
public
listAlarms(mixed $date[, mixed $fullevent = false ]) : mixed
Parameters
- $date : mixed
- $fullevent : mixed = false
Return values
mixed —listEvents()
Lists all events in the time range, optionally restricting results to only events with alarms.
public
listEvents([Horde_Date $startDate = null ][, Horde_Date $endDate = null ][, array<string|int, mixed> $options = array() ]) : mixed
Parameters
- $startDate : Horde_Date = null
-
The start of range date.
- $endDate : Horde_Date = null
-
The end of date range.
- $options : array<string|int, mixed> = array()
-
Additional options:
- show_recurrence: (boolean) Return every instance of a recurring event? DEFAULT: false (Only return recurring events once inside $startDate - $endDate range)
- has_alarm: (boolean) Only return events with alarms. DEFAULT: false (Return all events)
- json: (boolean) Store the results of the event's toJson() method? DEFAULT: false
- cover_dates: (boolean) Add the events to all days that they cover? DEFAULT: true
- hide_exceptions: (boolean) Hide events that represent exceptions to a recurring event. DEFAULT: false (Do not hide exception events)
- fetch_tags: (boolean) Fetch tags for all events. DEFAULT: false (Do not fetch event tags)
Tags
Return values
mixed —move()
Moves an event to a new calendar.
public
move(string $eventId, string $newCalendar) : mixed
Parameters
- $eventId : string
-
The event to move.
- $newCalendar : string
-
The new calendar.
Tags
Return values
mixed —nextRecurrence()
Finds the next recurrence of $eventId that's after $afterDate.
public
nextRecurrence(string $eventId, Horde_Date $afterDate) : Horde_Date|bool
Parameters
- $eventId : string
-
The ID of the event to fetch.
- $afterDate : Horde_Date
-
Return events after this date.
Tags
Return values
Horde_Date|bool —The date of the next recurrence or false if the event does not recur after $afterDate.
open()
Selects a calendar as the currently opened calendar.
public
open(string $calendar) : mixed
Parameters
- $calendar : string
-
A calendar identifier.
Return values
mixed —removeUserData()
Stub for child class to override if it can implement.
public
removeUserData(mixed $user) : mixed
Parameters
- $user : mixed
Tags
Return values
mixed —saveEvent()
Saves an event in the backend.
public
saveEvent(Kronolith_Event $event) : string
If it is a new event, it is added, otherwise the event is updated.
Parameters
- $event : Kronolith_Event
-
The event to save.
Tags
Return values
string —The event id.
search()
Searches a calendar.
public
search(object $query[, bool $json = false ]) : array<string|int, mixed>
Parameters
- $query : object
-
An object with the criteria to search for.
- $json : bool = false
-
Store the results of the events' toJson() method?
Tags
Return values
array<string|int, mixed> —An array of search results keyed by date, with each date containing an array of Kronolith_Events occuring on that date.
setParam()
Sets a configuration for this driver.
public
setParam(string $param, mixed $value) : mixed
Parameters
- $param : string
-
A parameter name.
- $value : mixed
-
The parameter value.
Return values
mixed —setParams()
Sets all configuration parameters for this driver.
public
setParams(string $params) : mixed
Parameters
- $params : string
-
A parameters hash.
Return values
mixed —supportsTimezones()
Returns whether this driver supports per-event timezones.
public
supportsTimezones() : bool
Return values
bool —Whether this drivers suppports per-event timezones.
synchronize()
Synchronize if driver needs to.
public
synchronize([bool $force = false ][, string $token = false ]) : mixed
Parameters
- $force : bool = false
-
If true, forces synchronization, even if we have already done so.
- $token : string = false
-
A synchroniziation token, if available.
Return values
mixed —_addEvent()
Adds an event to the backend.
protected
_addEvent(Kronolith_Event $event) : string
Parameters
- $event : Kronolith_Event
-
The event to save.
Tags
Return values
string —The event id.
_addTags()
Helper function to add tags from a newly creted event to the tagger.
protected
_addTags(Kronolith_Event $event) : mixed
Parameters
- $event : Kronolith_Event
-
The event to save tags to storage for.
Return values
mixed —_convertEvents()
Converts all components of a Horde_Icalendar container into a Kronolith_Event list.
protected
_convertEvents(Horde_Icalendar $ical) : array<string|int, mixed>
Parameters
- $ical : Horde_Icalendar
-
A Horde_Icalendar container.
Tags
Return values
array<string|int, mixed> —List of Kronolith_Event_Ical objects.
_deleteEvent()
Deletes an event.
protected
_deleteEvent(string $eventId[, bool $silent = false ]) : Kronolith_Event
Parameters
- $eventId : string
-
The ID of the event to delete.
- $silent : bool = false
-
Don't send notifications, used when deleting events in bulk from maintenance tasks.
Tags
Return values
Kronolith_Event —Returns the deleted event.
_getClient()
Returns a configured, cached DAV client.
protected
_getClient(string $uri) : Client
Parameters
- $uri : string
-
The base URI for any requests.
Tags
Return values
Client —A DAV client.
_getRemoteEvents()
Fetches a remote calendar and converts it to Kronolith_Event objects.
protected
_getRemoteEvents() : array<string|int, mixed>
The converted event objects will be cached for an hour.
Tags
Return values
array<string|int, mixed> —List of Kronolith_Event_Ical objects.
_getUrl()
Returns the URL of this calendar.
protected
_getUrl() : string
Does any necessary trimming and URL scheme fixes on the user-provided calendar URL.
Return values
string —The URL of this calendar.
_handleNotifications()
Wrapper for sending notifications, so that we can overwrite this action in Kronolith_Driver_Resource.
protected
_handleNotifications(Kronolith_Event $event, string $action) : mixed
Parameters
- $event : Kronolith_Event
- $action : string
Return values
mixed —_listCalDAVEvents()
Lists all events in the time range, optionally restricting results to only events with alarms.
protected
_listCalDAVEvents([mixed $startDate = null ][, mixed $endDate = null ][, bool $showRecurrence = false ][, bool $hasAlarm = false ][, bool $json = false ][, bool $coverDates = true ][, mixed $hideExceptions = false ]) : array<string|int, mixed>
Parameters
- $startDate : mixed = null
- $endDate : mixed = null
- $showRecurrence : bool = false
-
Return every instance of a recurring event? If false, will only return recurring events once inside the $startDate - $endDate range.
- $hasAlarm : bool = false
-
Only return events with alarms?
- $json : bool = false
-
Store the results of the events' toJson() method?
- $coverDates : bool = true
-
Whether to add the events to all days that they cover. $param boolean $hideExceptions Hide events that represent exceptions to a recurring event.
- $hideExceptions : mixed = false
Tags
Return values
array<string|int, mixed> —Events in the given time range.
_listEvents()
Lists all events in the time range, optionally restricting results to only events with alarms.
protected
_listEvents([Horde_Date $startDate = null ][, Horde_Date $endDate = null ][, array<string|int, mixed> $options = array() ]) : mixed
Parameters
- $startDate : Horde_Date = null
-
The start of range date.
- $endDate : Horde_Date = null
-
The end of date range.
- $options : array<string|int, mixed> = array()
-
Additional options:
- show_recurrence: (boolean) Return every instance of a recurring event? DEFAULT: false (Only return recurring events once inside $startDate - $endDate range)
- has_alarm: (boolean) Only return events with alarms. DEFAULT: false (Return all events)
- json: (boolean) Store the results of the event's toJson() method? DEFAULT: false
- cover_dates: (boolean) Add the events to all days that they cover? DEFAULT: true
- hide_exceptions: (boolean) Hide events that represent exceptions to a recurring event. DEFAULT: false (Do not hide exception events)
- fetch_tags: (boolean) Fetch tags for all events. DEFAULT: false (Do not fetch event tags)
Tags
Return values
mixed —_listWebDAVEvents()
Lists all events in the time range, optionally restricting results to only events with alarms.
protected
_listWebDAVEvents([mixed $startDate = null ][, mixed $endDate = null ][, bool $showRecurrence = false ][, bool $hasAlarm = false ][, bool $json = false ][, bool $coverDates = true ][, mixed $hideExceptions = false ]) : array<string|int, mixed>
Parameters
- $startDate : mixed = null
- $endDate : mixed = null
- $showRecurrence : bool = false
-
Return every instance of a recurring event? If false, will only return recurring events once inside the $startDate - $endDate range.
- $hasAlarm : bool = false
-
Only return events with alarms?
- $json : bool = false
-
Store the results of the events' toJson() method?
- $coverDates : bool = true
-
Whether to add the events to all days that they cover. $param boolean $hideExceptions Hide events that represent exceptions to a recurring event.
- $hideExceptions : mixed = false
Tags
Return values
array<string|int, mixed> —Events in the given time range.
_move()
Stub to be overridden in the child class.
protected
_move(mixed $eventId, mixed $newCalendar) : mixed
Parameters
- $eventId : mixed
- $newCalendar : mixed
Tags
Return values
mixed —_processComponents()
Processes the components of a Horde_Icalendar container into an event list.
protected
_processComponents(array<string|int, mixed> &$results, array<string|int, mixed> $events, mixed $startDate, mixed $endDate, bool $showRecurrence, bool $json, bool $coverDates, bool $hideExceptions[, string $id = null ]) : mixed
Parameters
- $results : array<string|int, mixed>
-
Gets filled with the events in the given time range.
- $events : array<string|int, mixed>
-
A list of Kronolith_Event_Ical objects.
- $startDate : mixed
- $endDate : mixed
- $showRecurrence : bool
-
Return every instance of a recurring event? If false, will only return recurring events once inside the $startDate - $endDate range.
- $json : bool
-
Store the results of the events' toJson() method?
- $coverDates : bool
-
Whether to add the events to all days that they cover.
- $hideExceptions : bool
-
Hide events that represent exceptions to a recurring event.
- $id : string = null
-
Enforce a certain event id (not UID).
Tags
Return values
mixed —_request()
Sends a CalDAV request.
protected
_request(string $method, string $url[, XMLWriter $xml = null ][, array<string|int, mixed> $headers = array() ]) : array<string|int, mixed>
Parameters
- $method : string
-
A request method.
- $url : string
-
A request URL.
- $xml : XMLWriter = null
-
An XMLWriter object with the body content.
- $headers : array<string|int, mixed> = array()
-
A hash with additional request headers.
Tags
Return values
array<string|int, mixed> —The Horde_Http_Response object and the parsed SimpleXMLElement results.
_saveEvent()
Updates an existing event in the backend.
protected
_saveEvent(Kronolith_Event $event) : ResponseInterface
Parameters
- $event : Kronolith_Event
-
The event to save.
Tags
Return values
ResponseInterface —The HTTP response.
_updateEvent()
Updates an existing event in the backend.
protected
_updateEvent(Kronolith_Event $event) : string
Parameters
- $event : Kronolith_Event
-
The event to save.
Tags
Return values
string —The event id.
_updateTags()
Helper function to update an existing event's tags to tagger storage.
protected
_updateTags(Kronolith_Event $event) : mixed
Parameters
- $event : Kronolith_Event
-
The event to update