diff options
author | icewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-05-22 16:21:54 +0000 |
---|---|---|
committer | icewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-05-22 16:21:54 +0000 |
commit | 47609ded6a50771f20bce62ce050d4d4dc04ee20 (patch) | |
tree | 07af598e4fe8dfcad2beb28c15962fe71df3fd48 | |
parent | dcda9c67353233750d2552cafcb4f65abe78e5c3 (diff) | |
download | elgg-47609ded6a50771f20bce62ce050d4d4dc04ee20.tar.gz elgg-47609ded6a50771f20bce62ce050d4d4dc04ee20.tar.bz2 |
Marcus Povey <marcus@dushka.co.uk>
* Moving back to desktop
git-svn-id: https://code.elgg.org/elgg/trunk@685 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r-- | engine/lib/river.php | 4 | ||||
-rw-r--r-- | engine/lib/system_log.php | 74 |
2 files changed, 77 insertions, 1 deletions
diff --git a/engine/lib/river.php b/engine/lib/river.php index 5d2490596..d1b55ad11 100644 --- a/engine/lib/river.php +++ b/engine/lib/river.php @@ -1,7 +1,7 @@ <?php /** * Elgg river. - * Functions for listening for and generating the river. + * Functions for listening for and generating the river out of the system log. * * @package Elgg * @subpackage Core @@ -10,4 +10,6 @@ * @copyright Curverider Ltd 2008 * @link http://elgg.org/ */ + + // event listener ?>
\ No newline at end of file diff --git a/engine/lib/system_log.php b/engine/lib/system_log.php new file mode 100644 index 000000000..8c820cbee --- /dev/null +++ b/engine/lib/system_log.php @@ -0,0 +1,74 @@ +<?php + /** + * Elgg system log. + * Listens to events and writes crud events into the system log database. + * + * @package Elgg + * @subpackage Core + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Marcus Povey + * @copyright Curverider Ltd 2008 + * @link http://elgg.org/ + */ + + /** + * Interface that provides an interface which must be implemented by all objects wishing to be + * recorded in the system log (and by extension the river). + * @author Marcus Povey + */ + interface Loggable + { + /** + * Return an identification for the object for storage in the system log. This id must be an integer. + * + * @return int + */ + public abstract function getSystemLogID(); + + // get object from ID .. ? + } + + /** + * Log a system event related to a specific object. + * + * @param $object The object you're talking about. + * @param $event String The event being logged + */ + function system_log($object, $event) + { + global $CONFIG; + + if ($object instanceof Loggable) + { + // Has loggable interface, extract the necessary information and store + $object_id = (int)$object->getSystemLogID(); + $object_class = santisise_string(get_class($object)); + $event = sanitise_string($event); + $time_created = time(); + + // Create log + return insert_data("INSERT into {$CONFIG->dbprefix}system_log (object_id, object_class, event, time_created) VALUES ('$object_id','$object_class','$event','$time')"); + } + } + + /** + * System log listener. + * This function listens to all events in the system and logs anything appropriate. + * + * @param String $event + * @param String $object_type + * @param mixed $object + */ + function system_log_listener($event, $object_type, $object) + { + if ($object instanceof Loggable) + { + system_log($object, $event); + } + + return true; + } + + /** Register event to listen to all events **/ + register_event_handler('all','all','system_log_listener'); +?>
\ No newline at end of file |