diff options
author | icewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-05-23 10:38:02 +0000 |
---|---|---|
committer | icewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-05-23 10:38:02 +0000 |
commit | f5c0093da9c466df97e0049b4dc4251e12f04faf (patch) | |
tree | c7ae28f30c3d112192b973ffc9c480d7bd0a8568 | |
parent | d28d94b3a8e19ba3cbf79db042d6f786f50e27b2 (diff) | |
download | elgg-f5c0093da9c466df97e0049b4dc4251e12f04faf.tar.gz elgg-f5c0093da9c466df97e0049b4dc4251e12f04faf.tar.bz2 |
Marcus Povey <marcus@dushka.co.uk>
* System log event code
git-svn-id: https://code.elgg.org/elgg/trunk@691 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r-- | engine/lib/entities.php | 16 | ||||
-rw-r--r-- | engine/lib/extender.php | 16 | ||||
-rw-r--r-- | engine/lib/relationships.php | 16 | ||||
-rw-r--r-- | engine/lib/system_log.php | 22 | ||||
-rw-r--r-- | engine/start.php | 8 |
5 files changed, 64 insertions, 14 deletions
diff --git a/engine/lib/entities.php b/engine/lib/entities.php index 7ce4047bb..674a6a8fe 100644 --- a/engine/lib/entities.php +++ b/engine/lib/entities.php @@ -22,6 +22,7 @@ abstract class ElggEntity implements Exportable, // Allow export of data Importable, // Allow import of data + Loggable, // Can events related to this object class be logged Iterator, // Override foreach behaviour ArrayAccess // Override for array access { @@ -533,6 +534,21 @@ return true; } + + // SYSTEM LOG INTERFACE //////////////////////////////////////////////////////////// + + /** + * Return an identification for the object for storage in the system log. + * This id must be an integer. + * + * @return int + */ + public function getSystemLogID() { return $this->getGUID(); } + + /** + * Return the class name of the object. + */ + public function getClassName() { return get_class($this); } // ITERATOR INTERFACE ////////////////////////////////////////////////////////////// /* diff --git a/engine/lib/extender.php b/engine/lib/extender.php index 5858d6432..a4e8af879 100644 --- a/engine/lib/extender.php +++ b/engine/lib/extender.php @@ -20,6 +20,7 @@ */ abstract class ElggExtender implements Exportable, + Loggable, // Can events related to this object class be logged Iterator, // Override foreach behaviour ArrayAccess // Override for array access { @@ -130,6 +131,21 @@ return $meta; } + // SYSTEM LOG INTERFACE //////////////////////////////////////////////////////////// + + /** + * Return an identification for the object for storage in the system log. + * This id must be an integer. + * + * @return int + */ + public function getSystemLogID() { return $this->id; } + + /** + * Return the class name of the object. + */ + public function getClassName() { return get_class($this); } + // ITERATOR INTERFACE ////////////////////////////////////////////////////////////// /* * This lets an entity's attributes be displayed using foreach as a normal array. diff --git a/engine/lib/relationships.php b/engine/lib/relationships.php index 519f28566..5b9627860 100644 --- a/engine/lib/relationships.php +++ b/engine/lib/relationships.php @@ -21,6 +21,7 @@ class ElggRelationship implements Importable, Exportable, + Loggable, // Can events related to this object class be logged Iterator, // Override foreach behaviour ArrayAccess // Override for array access { @@ -168,6 +169,21 @@ } } + // SYSTEM LOG INTERFACE //////////////////////////////////////////////////////////// + + /** + * Return an identification for the object for storage in the system log. + * This id must be an integer. + * + * @return int + */ + public function getSystemLogID() { return $this->id; } + + /** + * Return the class name of the object. + */ + public function getClassName() { return get_class($this); } + // ITERATOR INTERFACE ////////////////////////////////////////////////////////////// /* * This lets an entity's attributes be displayed using foreach as a normal array. diff --git a/engine/lib/system_log.php b/engine/lib/system_log.php index 80fc1b27f..827c79927 100644 --- a/engine/lib/system_log.php +++ b/engine/lib/system_log.php @@ -19,13 +19,17 @@ interface Loggable { /** - * Return an identification for the object for storage in the system log. This id must be an integer. + * Return an identification for the object for storage in the system log. + * This id must be an integer. * * @return int */ public function getSystemLogID(); - - // get object from ID .. ? + + /** + * Return the class name of the object. Added as a function because get_class causes errors for some reason. + */ + public function getClassName(); } /** @@ -42,9 +46,9 @@ { // Has loggable interface, extract the necessary information and store $object_id = (int)$object->getSystemLogID(); - $object_class = santisise_string(get_class($object)); + $object_class = $object->getClassName(); $event = sanitise_string($event); - $time_created = time(); + $time = 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')"); @@ -61,14 +65,12 @@ */ function system_log_listener($event, $object_type, $object) { - if ($object instanceof Loggable) - { - system_log($object, $event); - } + 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 diff --git a/engine/start.php b/engine/start.php index d586a3fb2..8b0e7dd14 100644 --- a/engine/start.php +++ b/engine/start.php @@ -19,7 +19,8 @@ if (!@include_once(dirname(__FILE__) . "/lib/exceptions.php")) { // Exceptions
echo "Error in installation: could not load the Exceptions library.";
exit;
- }
+ } +
if (!@include_once(dirname(__FILE__) . "/lib/elgglib.php")) { // Main Elgg library
throw new InstallationException("Elgg could not load its main library.");
} @@ -27,13 +28,12 @@ if (!@include_once(dirname(__FILE__) . "/lib/system_log.php")) { // Logging library echo "Error in installation: could not load the System Log library."; exit; - }
-
+ } +
if (!@include_once(dirname(__FILE__) . "/lib/export.php")) { // Export library
echo "Error in installation: could not load the Export library.";
exit;
}
-
/**
* Set light mode default
|