aboutsummaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
authormarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-10-06 15:06:42 +0000
committermarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-10-06 15:06:42 +0000
commit29dac199c057827876374038993da55c8c35267f (patch)
tree8409cc062309fdddaf14c7f49ab819daf71323a8 /engine
parentcd536030453e7390573d16bca824e6edd8d0bfa4 (diff)
downloadelgg-29dac199c057827876374038993da55c8c35267f.tar.gz
elgg-29dac199c057827876374038993da55c8c35267f.tar.bz2
Refs #402 and #407: Extra fields added to system_log
git-svn-id: https://code.elgg.org/elgg/trunk@2188 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine')
-rw-r--r--engine/lib/extender.php10
-rw-r--r--engine/lib/relationships.php10
-rw-r--r--engine/lib/system_log.php24
-rw-r--r--engine/schema/mysql.sql3
-rw-r--r--engine/schema/upgrades/2008100601.sql2
5 files changed, 47 insertions, 2 deletions
diff --git a/engine/lib/extender.php b/engine/lib/extender.php
index c84f7aef1..f1077b454 100644
--- a/engine/lib/extender.php
+++ b/engine/lib/extender.php
@@ -161,6 +161,16 @@
*/
public function getObjectOwnerGUID() { return $this->owner_guid; }
+ /**
+ * Return a type of the object - eg. object, group, user, relationship, metadata, annotation etc
+ */
+ public function getType() { return $this->type; }
+
+ /**
+ * Return a subtype. For metadata & annotations this is the 'name' and for relationship this is the relationship type.
+ */
+ public function getSubtype() { return $this->name; }
+
// ITERATOR INTERFACE //////////////////////////////////////////////////////////////
/*
diff --git a/engine/lib/relationships.php b/engine/lib/relationships.php
index 28f8b81f7..485732a59 100644
--- a/engine/lib/relationships.php
+++ b/engine/lib/relationships.php
@@ -211,6 +211,16 @@
*/
public function getObjectOwnerGUID() { return $this->owner_guid; }
+ /**
+ * Return a type of the object - eg. object, group, user, relationship, metadata, annotation etc
+ */
+ public function getType() { return 'relationship'; }
+
+ /**
+ * Return a subtype. For metadata & annotations this is the 'name' and for relationship this is the relationship type.
+ */
+ public function getSubtype() { return $this->relationship; }
+
// 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 1cbc5265f..d315d453f 100644
--- a/engine/lib/system_log.php
+++ b/engine/lib/system_log.php
@@ -39,6 +39,16 @@
public function getClassName();
/**
+ * Return a type of the object - eg. object, group, user, relationship, metadata, annotation etc
+ */
+ public function getType();
+
+ /**
+ * Return a subtype. For metadata & annotations this is the 'name' and for relationship this is the relationship type.
+ */
+ public function getSubtype();
+
+ /**
* For a given ID, return the object associated with it.
* This is used by the river functionality primarily.
* This is useful for checking access permissions etc on objects.
@@ -57,11 +67,13 @@
* @param int $by_user The user who initiated the event.
* @param string $event The event you are searching on.
* @param string $class The class of object it effects.
+ * @param string $type The type
+ * @param string $subtype The subtype.
* @param int $limit Maximum number of responses to return.
* @param int $offset Offset of where to start.
* @param bool $count Return count or not
*/
- function get_system_log($by_user = "", $event = "", $class = "", $limit = 10, $offset = 0, $count = false, $timebefore = 0, $timeafter = 0, $object_id = 0)
+ function get_system_log($by_user = "", $event = "", $class = "", $type = "", $subtype = "", $limit = 10, $offset = 0, $count = false, $timebefore = 0, $timeafter = 0, $object_id = 0)
{
global $CONFIG;
@@ -75,6 +87,8 @@
}
$event = sanitise_string($event);
$class = sanitise_string($class);
+ $type = sanitise_string($type);
+ $subtype = sanitise_string($subtype);
$limit = (int)$limit;
$offset = (int)$offset;
@@ -92,6 +106,10 @@
$where[] = "event='$event'";
if ($class!=="")
$where[] = "object_class='$class'";
+ if ($type != "")
+ $where[] = "object_type='$type'";
+ if ($subtype!=="")
+ $where[] = "object_subtype='$subtype'";
if ($timebefore)
$where[] = "time_created < " . ((int) $timebefore);
@@ -180,13 +198,15 @@
// Has loggable interface, extract the necessary information and store
$object_id = (int)$object->getSystemLogID();
$object_class = $object->getClassName();
+ $object_type = $object->getType();
+ $object_subtype = $object->getSubtype();
$event = sanitise_string($event);
$time = time();
$performed_by = (int)$_SESSION['guid'];
// Create log if we haven't already created it
if (!isset($logcache[$time][$object_id][$event])) {
- if (insert_data("INSERT DELAYED into {$CONFIG->dbprefix}system_log (object_id, object_class, event, performed_by_guid, time_created) VALUES ('$object_id','$object_class','$event',$performed_by, '$time')")) {
+ if (insert_data("INSERT DELAYED into {$CONFIG->dbprefix}system_log (object_id, object_class, object_type, object_subtype, event, performed_by_guid, time_created) VALUES ('$object_id','$object_class','$object_type', '$object_subtype', '$event',$performed_by, '$time')")) {
$logcache[$time][$object_id][$event] = true;
return true;
}
diff --git a/engine/schema/mysql.sql b/engine/schema/mysql.sql
index b756ed427..bdc711d68 100644
--- a/engine/schema/mysql.sql
+++ b/engine/schema/mysql.sql
@@ -282,7 +282,10 @@ CREATE TABLE `prefix_system_log` (
`id` int(11) NOT NULL auto_increment,
`object_id` int(11) NOT NULL,
+
`object_class` varchar(128) NOT NULL,
+ `object_type` varchar(128) NOT NULL,
+ `object_subtype` varchar(128) NOT NULL,
`event` varchar(128) NOT NULL,
`performed_by_guid` int(11) NOT NULL,
diff --git a/engine/schema/upgrades/2008100601.sql b/engine/schema/upgrades/2008100601.sql
new file mode 100644
index 000000000..89cce2e0e
--- /dev/null
+++ b/engine/schema/upgrades/2008100601.sql
@@ -0,0 +1,2 @@
+ALTER TABLE `prefix_system_log` ADD COLUMN `object_type` varchar(128) NOT NULL AFTER `object_class`;
+ALTER TABLE `prefix_system_log` ADD COLUMN `object_subtype` varchar(128) NOT NULL AFTER `object_type`; \ No newline at end of file