aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-06-25 14:46:05 +0000
committermarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-06-25 14:46:05 +0000
commit223e5d08b3333dc93519676580b6d892ff7e19c3 (patch)
tree4a10b29e1dbe7a7493c3d7cbfeef9a652c3e1ea8
parent27009477e3f523721eacc784598a616bf438d772 (diff)
downloadelgg-223e5d08b3333dc93519676580b6d892ff7e19c3.tar.gz
elgg-223e5d08b3333dc93519676580b6d892ff7e19c3.tar.bz2
Fixes #87 & #88
git-svn-id: https://code.elgg.org/elgg/trunk@1125 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r--engine/lib/annotations.php24
-rw-r--r--engine/lib/metadata.php22
2 files changed, 43 insertions, 3 deletions
diff --git a/engine/lib/annotations.php b/engine/lib/annotations.php
index 97ccb6772..8ae9a9340 100644
--- a/engine/lib/annotations.php
+++ b/engine/lib/annotations.php
@@ -176,7 +176,17 @@
system_log($entity, 'annotate');
// If ok then add it
- return insert_data("INSERT into {$CONFIG->dbprefix}annotations (entity_guid, name_id, value_id, value_type, owner_guid, time_created, access_id) VALUES ($entity_guid,'$name',$value,'$value_type', $owner_guid, $time, $access_id)");
+ $result = insert_data("INSERT into {$CONFIG->dbprefix}annotations (entity_guid, name_id, value_id, value_type, owner_guid, time_created, access_id) VALUES ($entity_guid,'$name',$value,'$value_type', $owner_guid, $time, $access_id)");
+ if ($result!==false) {
+ $obj = get_annotation($result);
+ if (trigger_elgg_event('create', $name, $obj)) {
+ return true;
+ } else {
+ delete_annotation($result);
+ }
+ }
+
+ return $result;
}
/**
@@ -213,7 +223,17 @@
if (!$name) return false;
// If ok then add it
- return update_data("UPDATE {$CONFIG->dbprefix}annotations set value_id='$value', value_type='$value_type', access_id=$access_id, owner_guid=$owner_guid where id=$annotation_id and name_id='$name' and $access");
+ $result = update_data("UPDATE {$CONFIG->dbprefix}annotations set value_id='$value', value_type='$value_type', access_id=$access_id, owner_guid=$owner_guid where id=$annotation_id and name_id='$name' and $access");
+ if ($result!==false) {
+ $obj = get_annotation($annotation_id);
+ if (trigger_elgg_event('update', $name, $obj)) {
+ return true;
+ } else {
+ delete_annotation($annotation_id);
+ }
+ }
+
+ return $result;
}
/**
diff --git a/engine/lib/metadata.php b/engine/lib/metadata.php
index 610288f90..11f40e51d 100644
--- a/engine/lib/metadata.php
+++ b/engine/lib/metadata.php
@@ -226,6 +226,16 @@
// If ok then add it
$id = insert_data("INSERT into {$CONFIG->dbprefix}metadata (entity_guid, name_id, value_id, value_type, owner_guid, time_created, access_id) VALUES ($entity_guid, '$name','$value','$value_type', $owner_guid, $time, $access_id)");
+
+ if ($id!==false) {
+ $obj = get_metadata($id);
+ if (trigger_elgg_event('create', $name, $obj)) {
+ return true;
+ } else {
+ delete_metadata($id);
+ }
+ }
+
} else if ($existing) {
// TODO: Check... are you sure you meant to do this Ben? :)
$id = $existing->id;
@@ -282,7 +292,17 @@
if (!$name) return false;
// If ok then add it
- return update_data("UPDATE {$CONFIG->dbprefix}metadata set value_id='$value', value_type='$value_type', access_id=$access_id, owner_guid=$owner_guid where id=$id and name_id='$name'");
+ $result = update_data("UPDATE {$CONFIG->dbprefix}metadata set value_id='$value', value_type='$value_type', access_id=$access_id, owner_guid=$owner_guid where id=$id and name_id='$name'");
+ if ($result!==false) {
+ $obj = get_metadata($id);
+ if (trigger_elgg_event('update', $name, $obj)) {
+ return true;
+ } else {
+ delete_metadata($id);
+ }
+ }
+
+ return $result;
}
/**