Documentation

Kronolith_Driver_Sql extends Kronolith_Driver
in package

The Kronolith_Driver_Sql class implements the Kronolith_Driver API for a SQL backend.

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

Luc Saillard luc.saillard@fr.alcove.com

author

Chuck Hagenbuch chuck@horde.org

author

Jan Schneider jan@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.
$_cache  : array<string|int, mixed>
Cache events as we fetch them to avoid fetching the same event from the DB twice.
$_columns  : array<string|int, mixed>
Column information as Horde_Db_Adapter_Base_Column objects.
$_db  : Horde_Db_Adapter
The object handle for the current database connection.
$_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.
backgroundColor()  : string
Returns the background color of the current calendar.
colors()  : array<string|int, mixed>
Returns the colors of the current calendar.
convertBlobs()  : array<string|int, mixed>
Converts TEXT/CLOB fields in an event.
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
Delete all of a calendar's events.
deleteEvent()  : mixed
Deletes an event.
exists()  : string|bool
Checks if the event's UID already exists and returns all event ids with that UID.
filterEventsByCalendar()  : array<string|int, mixed>
Filters a list of events to return only those that belong to certain calendars.
getByUID()  : Kronolith_Event
Get an event or events with the given UID value.
getEvent()  : mixed
Stub to be overridden in the child class.
getParam()  : mixed
Returns a configuration for this driver.
initialize()  : mixed
Attempts to open a connection to the SQL server.
listAlarms()  : array<string|int, 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()  : 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.
_buildEventHistory()  : array<string|int, mixed>
Builds a history hash for a modified event.
_deleteEvent()  : Kronolith_Event
Deletes an event.
_handleNotifications()  : mixed
Wrapper for sending notifications, so that we can overwrite this action in Kronolith_Driver_Resource.
_listEvents()  : mixed
Lists all events in the time range, optionally restricting results to only events with alarms.
_move()  : Kronolith_Event
Moves an event to a new calendar.
_updateEvent()  : string
Updates an existing event in the backend.
_updateTags()  : mixed
Helper function to update an existing event's tags to tagger storage.
_listEventsConditional()  : array<string|int, mixed>
Lists all events that satisfy the given conditions.

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 the same event from the DB twice.

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

$_columns

Column information as Horde_Db_Adapter_Base_Column objects.

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

$_db

The object handle for the current database connection.

protected Horde_Db_Adapter $_db

$_eventClass

The class name of the event object to instantiate.

protected string $_eventClass = 'Kronolith_Event_Sql'

Can be overwritten by sub-classes.

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

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.

convertBlobs()

Converts TEXT/CLOB fields in an event.

public convertBlobs(array<string|int, mixed> $event) : array<string|int, mixed>
Parameters
$event : array<string|int, mixed>

An event hash with TEXT/CLOB columns.

Return values
array<string|int, mixed>

The event with TEXT/CLOB columns converted to strings.

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()

Delete all of a calendar's events.

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

The name of the calendar to delete.

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

exists()

Checks if the event's UID already exists and returns all event ids with that UID.

public exists(string $uid[, string $calendar_id = null ]) : string|bool
Parameters
$uid : string

The event's uid.

$calendar_id : string = null

Calendar to search in.

Tags
throws
Kronolith_Exception
Return values
string|bool

Returns a string with event_id or false if not found.

filterEventsByCalendar()

Filters a list of events to return only those that belong to certain calendars.

public filterEventsByCalendar(array<string|int, mixed> $uids, array<string|int, mixed> $calendar) : array<string|int, mixed>
Parameters
$uids : array<string|int, mixed>

A list of event UIDs.

$calendar : array<string|int, mixed>

A list of calendar IDs.

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

Event UIDs filtered by calendar IDs.

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

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.

initialize()

Attempts to open a connection to the SQL server.

public initialize() : mixed
Tags
throws
Kronolith_Exception
Return values
mixed

listAlarms()

Stub to be overridden in the child class.

public listAlarms(Horde_Date $date[, bool $fullevent = false ]) : array<string|int, mixed>
Parameters
$date : Horde_Date

The date to list alarms for

$fullevent : bool = false

Return the full event objects?

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

An array of event ids, or Kronolith_Event objects

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

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 ]) : 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
mixed

An array of Kronolith_Events.

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

_buildEventHistory()

Builds a history hash for a modified event.

protected _buildEventHistory(Kronolith_Event $event) : array<string|int, mixed>

We don't write it in here because we don't want to commit history before the actual changes are made.

Parameters
$event : Kronolith_Event

The event to log.

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

The change log.

_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
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, string $action) : mixed
Parameters
$event : Kronolith_Event
$action : string
Return values
mixed

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

_move()

Moves an event to a new calendar.

protected _move(string $eventId, string $newCalendar) : Kronolith_Event
Parameters
$eventId : string

The event to move.

$newCalendar : string

The new calendar.

Tags
throws
Kronolith_Exception
throws
Horde_Exception_NotFound
Return values
Kronolith_Event

The old event.

_updateEvent()

Updates an existing event in the backend.

protected _updateEvent(Kronolith_Event $event) : string
Parameters
$event : Kronolith_Event

The event to save.

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

Return values
mixed

_listEventsConditional()

Lists all events that satisfy the given conditions.

private _listEventsConditional([Horde_Date $startInterval = null ][, Horde_Date $endInterval = null ][, string $conditions = '' ][, array<string|int, mixed> $vals = array() ]) : array<string|int, mixed>
Parameters
$startInterval : Horde_Date = null

Start of range date object.

$endInterval : Horde_Date = null

End of range data object.

$conditions : string = ''

Conditions, given as SQL clauses.

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

SQL bind variables for use with $conditions clauses.

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

Events in the given time range satisfying the given conditions.

Search results