\Horde_History_Composite

A composite implementation of the history storage backend.

Summary

Methods
Properties
Constants
__construct()
setLogger()
setCache()
log()
getHistory()
_getHistory()
getByTimestamp()
getByModSeq()
_getByTimestamp()
getActionTimestamp()
removeByParent()
removeByNames()
getHighestModSeq()
getActionModSeq()
getLatestEntry()
No public properties found
No constants found
_log()
$_auth
$_cache
$_logger
$_drivers
N/A
No private methods found
No private properties found
N/A

Properties

$_auth

$_auth : string

The current user.

Type

string

$_cache

$_cache : \Horde_Cache

Cache driver object.

Type

\Horde_Cache

$_logger

$_logger : \Horde_Log_Logger

Our log handler.

Type

\Horde_Log_Logger

$_drivers

$_drivers : array

Driver list.

Type

array

Methods

__construct()

__construct(string  $auth, array  $params = array()) 

Constructor.

Parameters

string $auth

The current user.

array $params

Configuration parameters:

REQUIRED parameters:
  - drivers: (array) An array of Horde_History objects.

setLogger()

setLogger(\Horde_Log_Logger  $logger) : NULL

Set the log handler.

Parameters

\Horde_Log_Logger $logger

The log handler.

Returns

NULL

setCache()

setCache(\Horde_Cache  $cache) 

Set Cache object.

Parameters

\Horde_Cache $cache

The cache instance.

log()

log(string  $guid, array  $attributes = array(), boolean  $replaceAction = false) 

Logs an event to an item's history log.

The item must be uniquely identified by $guid. Any other details about the event are passed in $attributes. Standard suggested attributes are:

  • who: The id of the user that performed the action (will be added automatically if not present).
  • ts: Timestamp of the action (this will be added automatically if it is not present).

Parameters

string $guid

The unique identifier of the entry to add to.

array $attributes

The hash of name => value entries that describe this event.

boolean $replaceAction

If $attributes['action'] is already present in the item's history log, update that entry instead of creating a new one.

getHistory()

getHistory(string  $guid) : \Horde_History_Log

Returns a Horde_History_Log corresponding to the named history entry, with the data retrieved appropriately.

Parameters

string $guid

The name of the history entry to retrieve.

Returns

\Horde_History_Log

A Horde_History_Log object.

_getHistory()

_getHistory(string  $guid) : \Horde_History_Log

Returns a Horde_History_Log corresponding to the named history entry, with the data retrieved appropriately.

Parameters

string $guid

The name of the history entry to retrieve.

Returns

\Horde_History_Log

A Horde_History_Log object.

getByTimestamp()

getByTimestamp(string  $cmp, integer  $ts, array  $filters = array(), string  $parent = null) : array

Finds history objects by timestamp, and optionally filter on other fields as well.

Parameters

string $cmp

The comparison operator (<, >, <=, >=, or =) to check the timestamps with.

integer $ts

The timestamp to compare against.

array $filters

An array of additional (ANDed) criteria. Each array value should be an array with 3 entries:

  • field: the history field being compared (i.e. 'action').
  • op: the operator to compare this field with.
  • value: the value to check for (i.e. 'add').
string $parent

The parent history to start searching at. If non-empty, will be searched for with a LIKE '$parent:%' clause.

Throws

\Horde_History_Exception

Returns

array —

An array of history object ids, or an empty array if none matched the criteria.

getByModSeq()

getByModSeq(integer  $start, integer  $end, array  $filters = array(), string  $parent = null) : array

Return history objects with changes during a modseq interval, and optionally filtered on other fields as well.

Parameters

integer $start

The (exclusive) start of the modseq range.

integer $end

The (inclusive) end of the modseq range.

array $filters

An array of additional (ANDed) criteria. Each array value should be an array with 3 entries:

  • field: the history field being compared (i.e. 'action').
  • op: the operator to compare this field with.
  • value: the value to check for (i.e. 'add').
string $parent

The parent history to start searching at. If non-empty, will be searched for with a LIKE '$parent:%' clause.

Returns

array —

An array of history object ids, or an empty array if none matched the criteria.

_getByTimestamp()

_getByTimestamp(string  $cmp, integer  $ts, array  $filters = array(), string  $parent = null) : array

Finds history objects by timestamp, and optionally filter on other fields as well.

Parameters

string $cmp

The comparison operator (<, >, <=, >=, or =) to check the timestamps with.

integer $ts

The timestamp to compare against.

array $filters

An array of additional (ANDed) criteria. Each array value should be an array with 3 entries:

  • field: the history field being compared (i.e. 'action').
  • op: the operator to compare this field with.
  • value: the value to check for (i.e. 'add').
string $parent

The parent history to start searching at. If non-empty, will be searched for with a LIKE '$parent:%' clause.

Returns

array —

An array of history object ids, or an empty array if none matched the criteria.

getActionTimestamp()

getActionTimestamp(string  $guid, string  $action) : integer

Gets the timestamp of the most recent change to $guid.

Parameters

string $guid

The name of the history entry to retrieve.

string $action

An action: 'add', 'modify', 'delete', etc.

Throws

\Horde_History_Exception

Returns

integer —

The timestamp, or 0 if no matching entry is found.

removeByParent()

removeByParent(string  $parent) 

Remove one or more history entries by parent.

Parameters

string $parent

The parent name to remove.

Throws

\Horde_History_Exception

removeByNames()

removeByNames(array  $names) 

Removes one or more history entries by name.

Parameters

array $names

The history entries to remove.

getHighestModSeq()

getHighestModSeq(string  $parent = null) : integer

Return the maximum modification sequence. To be overridden in concrete class.

Parameters

string $parent

Restrict to entries a specific parent.

Returns

integer —

The modseq

getActionModSeq()

getActionModSeq(string  $guid, string  $action) : integer

Gets the modseq of the most recent change to $guid

Parameters

string $guid

The name of the history entry to retrieve.

string $action

An action: 'add', 'modify', 'delete', etc.

Throws

\Horde_History_Exception

Returns

integer —

The modseq, or 0 if no matching entry is found.

getLatestEntry()

getLatestEntry(string  $guid, boolean  $use_ts = false) : array|boolean

Gets the latest entry of $guid

Parameters

string $guid

The name of the history entry to retrieve.

boolean $use_ts

If false we use the 'modseq' field to determine the latest entry. If true we use the timestamp instead of modseq to determine the latest entry. Note: Only 'modseq' can give a definitive answer.

Throws

\Horde_History_Exception

Returns

array|boolean —

The latest history entry, or false if $guid does not exist.

_log()

_log(\Horde_History_Log  $history, array  $attributes, boolean  $replaceAction = false) 

Logs an event to an item's history log. Any other details about the event are passed in $attributes.

Parameters

\Horde_History_Log $history

The history item to add to.

array $attributes

The hash of name => value entries that describe this event.

boolean $replaceAction

If $attributes['action'] is already present in the item's history log, update that entry instead of creating a new one.