Horde_History_Mongo extends Horde_History implements Horde_Mongo_Collection_Index
Provides a MongoDB implementation of the history driver.
Tags
Interfaces, Classes and Traits
- Horde_Mongo_Collection_Index
Table of Contents
- ACTION = 'action'
- Mongo field names.
- DESC = 'desc'
- EXTRA = 'extra'
- MODSEQ = 'modseq'
- MONGO_DATA = 'horde_history_data'
- Mongo collection name.
- MONGO_MODSEQ = 'horde_history_modseq'
- TS = 'ts'
- UID = 'uid'
- WHO = 'who'
- $_auth : string
- The current user.
- $_cache : Horde_Cache
- Cache driver object.
- $_db : MongoDB
- MongoDB object used to manage the history.
- $_indices : array<string|int, mixed>
- The list of indices.
- $_logger : Horde_Log_Logger
- Our log handler.
- __construct() : mixed
- Constructor.
- _getByTimestamp() : array<string|int, mixed>
- Finds history objects by timestamp, and optionally filter on other fields as well.
- _getHistory() : Horde_History_Log
- Returns a Horde_History_Log corresponding to the named history entry, with the data retrieved appropriately.
- checkMongoIndices() : mixed
- createMongoIndices() : mixed
- getActionModSeq() : int
- Gets the modseq of the most recent change to $guid
- getActionTimestamp() : int
- Gets the timestamp of the most recent change to $guid.
- getByModSeq() : array<string|int, mixed>
- Return history objects with changes during a modseq interval, and optionally filtered on other fields as well.
- getByTimestamp() : array<string|int, mixed>
- Finds history objects by timestamp, and optionally filter on other fields as well.
- getHighestModSeq() : int
- Return the maximum modification sequence. To be overridden in concrete class.
- getHistory() : Horde_History_Log
- Returns a Horde_History_Log corresponding to the named history entry, with the data retrieved appropriately.
- getLatestEntry() : array<string|int, mixed>|bool
- Gets the latest entry of $guid
- log() : mixed
- Logs an event to an item's history log.
- removeByNames() : mixed
- Removes one or more history entries by name.
- removeByParent() : mixed
- Remove one or more history entries by parent.
- setCache() : mixed
- Set Cache object.
- setLogger() : null
- Set the log handler.
- _assocQuery() : mixed
- _cursorToRow() : array<string|int, mixed>
- _getByModSeq() : mixed
- _log() : mixed
- Logs an event to an item's history log. Any other details about the event are passed in $attributes.
- _nextModSeq() : mixed
Constants
ACTION
Mongo field names.
public
mixed
ACTION
= 'action'
DESC
public
mixed
DESC
= 'desc'
EXTRA
public
mixed
EXTRA
= 'extra'
MODSEQ
public
mixed
MODSEQ
= 'modseq'
MONGO_DATA
Mongo collection name.
public
mixed
MONGO_DATA
= 'horde_history_data'
MONGO_MODSEQ
public
mixed
MONGO_MODSEQ
= 'horde_history_modseq'
TS
public
mixed
TS
= 'ts'
UID
public
mixed
UID
= 'uid'
WHO
public
mixed
WHO
= 'who'
Properties
$_auth
The current user.
protected
string
$_auth
$_cache
Cache driver object.
protected
Horde_Cache
$_cache
$_db
MongoDB object used to manage the history.
protected
MongoDB
$_db
$_indices
The list of indices.
protected
array<string|int, mixed>
$_indices
= array(self::MONGO_DATA => array('index_action' => array(self::ACTION => 1), 'index_modseq' => array(self::MODSEQ => 1), 'index_ts' => array(self::TS => 1), 'index_uid' => array(self::UID => 1)))
$_logger
Our log handler.
protected
Horde_Log_Logger
$_logger
Methods
__construct()
Constructor.
public
__construct(mixed $auth[, array<string|int, mixed> $params = array() ]) : mixed
Parameters
- $auth : mixed
-
The current user.
- $params : array<string|int, mixed> = array()
-
Configuration parameters:
-
REQUIRED parameters:
- mongo_db: (Horde_Mongo_Client) A MongoDB client object.
-
REQUIRED parameters:
Return values
mixed —_getByTimestamp()
Finds history objects by timestamp, and optionally filter on other fields as well.
public
_getByTimestamp(mixed $cmp, mixed $ts[, array<string|int, mixed> $filters = array() ][, mixed $parent = null ]) : array<string|int, mixed>
Parameters
- $cmp : mixed
-
The comparison operator (<, >, <=, >=, or =) to check the timestamps with.
- $ts : mixed
-
The timestamp to compare against.
- $filters : array<string|int, mixed> = array()
-
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').
- $parent : mixed = null
-
The parent history to start searching at. If non-empty, will be searched for with a LIKE '$parent:%' clause.
Return values
array<string|int, mixed> —An array of history object ids, or an empty array if none matched the criteria.
_getHistory()
Returns a Horde_History_Log corresponding to the named history entry, with the data retrieved appropriately.
public
_getHistory(mixed $guid) : Horde_History_Log
Parameters
- $guid : mixed
-
The name of the history entry to retrieve.
Return values
Horde_History_Log —A Horde_History_Log object.
checkMongoIndices()
public
checkMongoIndices() : mixed
Return values
mixed —createMongoIndices()
public
createMongoIndices() : mixed
Return values
mixed —getActionModSeq()
Gets the modseq of the most recent change to $guid
public
getActionModSeq(string $guid, string $action) : int
Parameters
- $guid : string
-
The name of the history entry to retrieve.
- $action : string
-
An action: 'add', 'modify', 'delete', etc.
Tags
Return values
int —The modseq, or 0 if no matching entry is found.
getActionTimestamp()
Gets the timestamp of the most recent change to $guid.
public
getActionTimestamp(mixed $guid, mixed $action) : int
Parameters
- $guid : mixed
-
The name of the history entry to retrieve.
- $action : mixed
-
An action: 'add', 'modify', 'delete', etc.
Return values
int —The timestamp, or 0 if no matching entry is found.
getByModSeq()
Return history objects with changes during a modseq interval, and optionally filtered on other fields as well.
public
getByModSeq(int $start, int $end[, array<string|int, mixed> $filters = array() ][, string $parent = null ]) : array<string|int, mixed>
Parameters
- $start : int
-
The (exclusive) start of the modseq range.
- $end : int
-
The (inclusive) end of the modseq range.
- $filters : array<string|int, mixed> = array()
-
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').
- $parent : string = null
-
The parent history to start searching at. If non-empty, will be searched for with a LIKE '$parent:%' clause.
Return values
array<string|int, mixed> —An array of history object ids, or an empty array if none matched the criteria.
getByTimestamp()
Finds history objects by timestamp, and optionally filter on other fields as well.
public
getByTimestamp(string $cmp, int $ts[, array<string|int, mixed> $filters = array() ][, string $parent = null ]) : array<string|int, mixed>
Parameters
- $cmp : string
-
The comparison operator (<, >, <=, >=, or =) to check the timestamps with.
- $ts : int
-
The timestamp to compare against.
- $filters : array<string|int, mixed> = array()
-
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').
- $parent : string = null
-
The parent history to start searching at. If non-empty, will be searched for with a LIKE '$parent:%' clause.
Tags
Return values
array<string|int, mixed> —An array of history object ids, or an empty array if none matched the criteria.
getHighestModSeq()
Return the maximum modification sequence. To be overridden in concrete class.
public
getHighestModSeq([mixed $parent = null ]) : int
Parameters
- $parent : mixed = null
-
Restrict to entries a specific parent.
Return values
int —The modseq
getHistory()
Returns a Horde_History_Log corresponding to the named history entry, with the data retrieved appropriately.
public
getHistory(string $guid) : Horde_History_Log
Parameters
- $guid : string
-
The name of the history entry to retrieve.
Tags
Return values
Horde_History_Log —A Horde_History_Log object.
getLatestEntry()
Gets the latest entry of $guid
public
getLatestEntry(mixed $guid[, mixed $use_ts = false ]) : array<string|int, mixed>|bool
Parameters
- $guid : mixed
-
The name of the history entry to retrieve.
- $use_ts : mixed = false
-
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.
Return values
array<string|int, mixed>|bool —The latest history entry, or false if $guid does not exist.
log()
Logs an event to an item's history log.
public
log(string $guid[, array<string|int, mixed> $attributes = array() ][, bool $replaceAction = false ]) : mixed
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
- $guid : string
-
The unique identifier of the entry to add to.
- $attributes : array<string|int, mixed> = array()
-
The hash of name => value entries that describe this event.
- $replaceAction : bool = false
-
If $attributes['action'] is already present in the item's history log, update that entry instead of creating a new one.
Tags
Return values
mixed —removeByNames()
Removes one or more history entries by name.
public
removeByNames(array<string|int, mixed> $names) : mixed
Parameters
- $names : array<string|int, mixed>
-
The history entries to remove.
Return values
mixed —removeByParent()
Remove one or more history entries by parent.
public
removeByParent(string $parent) : mixed
Parameters
- $parent : string
-
The parent name to remove.
Tags
Return values
mixed —setCache()
Set Cache object.
public
setCache(Horde_Cache $cache) : mixed
Parameters
- $cache : Horde_Cache
-
The cache instance.
Tags
Return values
mixed —setLogger()
Set the log handler.
public
setLogger(Horde_Log_Logger $logger) : null
Parameters
- $logger : Horde_Log_Logger
-
The log handler.
Return values
null —_assocQuery()
protected
_assocQuery(mixed $query, mixed $filters, mixed $parent) : mixed
Parameters
- $query : mixed
- $filters : mixed
- $parent : mixed
Return values
mixed —_cursorToRow()
protected
_cursorToRow(MongoCursor $cursor) : array<string|int, mixed>
Parameters
- $cursor : MongoCursor
Return values
array<string|int, mixed> —_getByModSeq()
protected
_getByModSeq(mixed $start, mixed $end[, mixed $filters = array() ][, mixed $parent = null ]) : mixed
Parameters
- $start : mixed
- $end : mixed
- $filters : mixed = array()
- $parent : mixed = null
Return values
mixed —_log()
Logs an event to an item's history log. Any other details about the event are passed in $attributes.
protected
_log(Horde_History_Log $history, array<string|int, mixed> $attributes[, mixed $replaceAction = false ]) : mixed
Parameters
- $history : Horde_History_Log
-
The history item to add to.
- $attributes : array<string|int, mixed>
-
The hash of name => value entries that describe this event.
- $replaceAction : mixed = false
-
If $attributes['action'] is already present in the item's history log, update that entry instead of creating a new one.
Return values
mixed —_nextModSeq()
protected
_nextModSeq() : mixed