Documentation

Kronolith_Driver_Resource extends Kronolith_Driver
in package

The Kronolith_Driver_Resource class implements the Kronolith_Driver API for storing resource calendars.

Copyright 1999-2017 Horde LLC (http://www.horde.org/)

See the enclosed file LICENSE for license information (GPL). If you did not receive this file, see http://www.horde.org/licenses/gpl.

Tags
author

Michael J Rubinsky mrubinsk@horde.org

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.
$_driver  : Kronolith_Driver
The main event storage driver.
$_eventClass  : string
The class name of the event object to instantiate.
$_params  : array<string|int, mixed>
A hash containing any parameters for the current driver.
$_errormsg  : string
An error message to throw when something is wrong.
__construct()  : mixed
Constructor.
_deleteResourceCalendar()  : mixed
Delete the resource calendar
backgroundColor()  : string
Returns the background color of the current calendar.
colors()  : array<string|int, mixed>
Returns the colors of the current calendar.
convertFromDriver()  : mixed
Converts a value from the driver's charset to the default charset.
convertToDriver()  : mixed
Converts a value from the default charset to the driver's charset.
countEvents()  : int
Returns the number of events in the current calendar.
delete()  : mixed
Removes a resource from storage, along with any events in the resource's calendar.
deleteEvent()  : mixed
Delete 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()  : Kronolith_Event
Get an event or events with the given UID value.
getEvent()  : mixed
Stub to be overridden in the child class.
getGroupMemberships()  : array<string|int, mixed>
Obtain the group id for each group the specified resource is a member of.
getParam()  : mixed
Returns a configuration for this driver.
getResource()  : Kronolith_Resource_Base
Obtain a Kronolith_Resource by the resource's id
getResourceIdByCalendar()  : int
Obtain the resource id associated with the given calendar uid.
initialize()  : mixed
Stub to initiate a driver.
isResourceCalendar()  : bool
Determine if the provided calendar id represents a resource's calendar.
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.
listResources()  : an
Return a list of Kronolith_Resources
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.
save()  : Kronolith_Resource
Save or update a Kronolith_Resource
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()  : mixed
Stub to be overridden in the child class.
_addTags()  : mixed
Helper function to add tags from a newly creted event to the tagger.
_buildResourceEvent()  : mixed
_deleteEvent()  : Kronolith_Event
Stub to be overridden in the child class.
_handleNotifications()  : mixed
Wrapper for sending notifications, so that we can overwrite this action in Kronolith_Driver_Resource.
_listEvents()  : mixed
Stub to be overridden in concrete class.
_move()  : mixed
Stub to be overridden in the child class.
_updateEvent()  : mixed
Stub to be overridden in the child class.
_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'

$_eventClass

The class name of the event object to instantiate.

protected string $_eventClass = 'Kronolith_Event_Resource'

$_params

A hash containing any parameters for the current driver.

protected array<string|int, mixed> $_params = array()

$_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

_deleteResourceCalendar()

Delete the resource calendar

public _deleteResourceCalendar(string $calendar) : mixed
Parameters
$calendar : string

The calendar id.

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.

convertFromDriver()

Converts a value from the driver's charset to the default charset.

public convertFromDriver(mixed $value) : mixed
Parameters
$value : mixed

A value to convert.

Return values
mixed

The converted value.

convertToDriver()

Converts a value from the default charset to the driver's charset.

public convertToDriver(mixed $value) : mixed
Parameters
$value : mixed

A value to convert.

Return values
mixed

The converted value.

countEvents()

Returns the number of events in the current calendar.

public countEvents() : int
Tags
throws
Kronolith_Exception
Return values
int

The number of events.

delete()

Removes a resource from storage, along with any events in the resource's calendar.

public delete(Kronolith_Resource_Base $resource) : mixed
Parameters
$resource : Kronolith_Resource_Base

The kronolith resource to remove

Tags
throws

Kronolith_Exception, Horde_Exception_PermissionDenied

Return values
mixed

deleteEvent()

Delete an event.

public deleteEvent(string|Kronolith_Event_Resource $eventId[, bool $silent = false ][, bool $keep_bound = false ]) : mixed

Since this is the Kronolith_Resource's version of the event, if we delete it, we must also make sure to remove it from the event that it is attached to. Not sure if there is a better way to do this...

Parameters
$eventId : string|Kronolith_Event_Resource

The ID of the event to delete.

$silent : bool = false

Don't send notifications, used when deleting events in bulk from maintenance tasks.

$keep_bound : bool = false

If true, does not remove the resource from the bound event. @since 4.2.2

Tags
throws
Kronolith_Exception
throws
Horde_Exception_NotFound
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
throws
Kronolith_Exception
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
throws
Kronolith_Exception
Return values
mixed

getByUID()

Get an event or events with the given UID value.

public getByUID(string $uid[, array<string|int, mixed> $calendars = null ][, bool $getAll = false ]) : Kronolith_Event
Parameters
$uid : string

The UID to match

$calendars : array<string|int, mixed> = null

A restricted array of calendar ids to search

$getAll : bool = false

Return all matching events?

Tags
throws
Kronolith_Exception
throws
Horde_Exception_NotFound
Return values
Kronolith_Event

getEvent()

Stub to be overridden in the child class.

public getEvent([mixed $eventId = null ]) : mixed
Parameters
$eventId : mixed = null
Tags
throws
Kronolith_Exception
throws
Horde_Exception_NotFound
Return values
mixed

getGroupMemberships()

Obtain the group id for each group the specified resource is a member of.

public getGroupMemberships(int $resource_id) : array<string|int, mixed>
Parameters
$resource_id : int

The resource id to check for.

Tags
throws
Kronolith_Exception
Return values
array<string|int, mixed>

An array of group ids.

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.

getResourceIdByCalendar()

Obtain the resource id associated with the given calendar uid.

public getResourceIdByCalendar(string $calendar) : int
Parameters
$calendar : string

The calendar's uid.

Tags
throws
Kronolith_Exception
Return values
int

The Kronolith_Resource id.

initialize()

Stub to initiate a driver.

public initialize() : mixed
Return values
mixed

isResourceCalendar()

Determine if the provided calendar id represents a resource's calendar.

public isResourceCalendar(string $calendar) : bool
Parameters
$calendar : string

The calendar identifier to check.

Return values
bool

listAlarms()

Stub to be overridden in the child class.

public listAlarms(mixed $date[, mixed $fullevent = false ]) : mixed
Parameters
$date : mixed
$fullevent : mixed = false
Tags
throws
Kronolith_Exception
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
throws
Kronolith_Exception
Return values
mixed

listResources()

Return a list of Kronolith_Resources

public listResources([int $perms = Horde_Perms::READ ][, array<string|int, mixed> $filter = array() ][, string $orderby = null ]) : an

Right now, all users have Horde_Perms::READ, but only system admins have Horde_Perms::EDIT | Horde_Perms::DELETE

Parameters
$perms : int = Horde_Perms::READ

A Horde_Perms::* constant.

$filter : array<string|int, mixed> = array()

A hash of field/values to filter on.

$orderby : string = null

Field to order results by. Null for no ordering.

Tags
throws
Kronolith_Exception
Return values
an

array of Kronolith_Resource objects.

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
throws
Kronolith_Exception
throws
Horde_Exception_NotFound
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
throws
Kronolith_Exception
throws
Horde_Exception_NotFound
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
todo

Remove in Kronolith 4.0

deprecated

Now lives in Kronolith_Application::

throws
Kronolith_Exception
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
throws
Horde_Mime_Exception
throws
Kronolith_Exception
Return values
string

The event id.

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
throws
Kronolith_Exception
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

_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

_buildResourceEvent()

protected _buildResourceEvent(mixed $driver_event) : mixed
Parameters
$driver_event : mixed
Return values
mixed

_deleteEvent()

Stub to be overridden in the child class.

protected _deleteEvent(mixed $eventId) : Kronolith_Event
Parameters
$eventId : mixed

Either the event id to delete, or the event object.

Tags
throws
Kronolith_Exception
throws
Horde_Exception_NotFound
throws
Horde_Mime_Exception
Return values
Kronolith_Event

Returns the deleted event.

_handleNotifications()

Wrapper for sending notifications, so that we can overwrite this action in Kronolith_Driver_Resource.

protected _handleNotifications(Kronolith_Event $event, mixed $action) : mixed
Parameters
$event : Kronolith_Event
$action : mixed
Return values
mixed

_listEvents()

Stub to be overridden in concrete class.

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
throws
Kronolith_Exception
Return values
mixed

_move()

Stub to be overridden in the child class.

protected _move(mixed $eventId, mixed $newCalendar) : mixed
Parameters
$eventId : mixed
$newCalendar : mixed
Tags
throws
Kronolith_Exception
Return values
mixed

_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

Return values
mixed

Search results