.. contents:: Contents .. section-numbering:: =============== Horde_History =============== Horde_History is a library to track and find change events for arbitrary resources. Histories can be saved to SQL or MongoDb, a Composite backend also exists. Possible use cases are sync protocols, undo/rewind features or human consumable history information. The Horde_Activesync implementation uses Horde_Histories to track create/delete/update events of syncable items. --------------- General Usage --------------- Create an implementation of the Horde_History class and fulfill its dependencies :: $history = new Horde_History_Sql($username, Horde_Db_Adapter $db); Log events related to a $guid identifying the resource tracked :: $history->log('room1:shelf1:item100', array( 'who' => 'someuser', // defaults to the user provided at construction of the object 'action' => 'create', )); $history->log('room1:shelf1:item100', array( 'who' => 'someotheruser', // defaults to the user provided at construction of the object 'action' => 'modify', 'ts' => 1287666089, // Defaults to now, 'desc' => 'Human Readble Description' )); $history->log('room1:shelf1:item100', array('action' => 'delete')); Retrieve the whole history of some guid :: $log = $history->getHistory("room1:shelf1:item100"); // returns a Horde_History_Log object Retrieve the list of history items compared to a certain timestamp :: $ids = $history->getByTimestamp('>=', 1287666089); // returns an array of integers Or add filters :: $ids = $history->getByTimestamp('>=', 1287666089, array( array('action', '==', 'delete') ) ); // returns an array of integers Get events between some changesets, allowing filters :: $ids = $history->getByModSeq(1287, 1305); // returns an array of integers $ids = $history->getByModSeq(1287, 1305, array(array('action', '==', 'create'))); // returns an array of integers Limit to events within a parent resource :: $ids = $history->getByModSeq(12876, 1305, array(), 'room1:shelf1'); // returns an array of integers $ids = $history->getByModSeq(12876, 1305, array(array('action', '==', 'create')), 'room1:shelf1'); // returns an array of integers Get the last time a certain action happened to a resource :: $ts = $history->getActionTimestamp('room1:shelf1', 'createitem'); Remove all histories for a certain parent guid, for example because a collection gets deleted :: $history->removeByParent('room12'); Or remove a list of guids from history (not including child resources) :: $history->removeByNames(array('room12:shelf1', 'room12:shelf2', 'room12:shelf3')); Get the last change to any child guid below a parent guid :: $modseq = $history->getHighestModSeq('room1'); Get the latest entry for a guid by modseq :: $entry = $history->getLatestEntry('room1'); or by timestamp :: $entry = $history->getLatestEntry('room1', true); --------------------------------- Usage inside Horde applications --------------------------------- Use the Injector to get a configured instance of Horde_Core_History. :: $history = $GLOBALS['injector']->getInstance('Horde_History'); Horde_Core_History wraps Horde_History instances. It defaults to the logged in user and delegates most calls to the actual backends. ---- Back to the ((Project|Project List)