From 2330e92ff935a9fb14147d37ce227c40e3d7c257 Mon Sep 17 00:00:00 2001 From: ben Date: Mon, 9 Feb 2009 16:32:30 +0000 Subject: Added the 'annotate' event on entities. git-svn-id: https://code.elgg.org/elgg/trunk@2694 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/annotations.php | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'engine/lib/annotations.php') diff --git a/engine/lib/annotations.php b/engine/lib/annotations.php index bfac0d557..7a9f2e3c6 100644 --- a/engine/lib/annotations.php +++ b/engine/lib/annotations.php @@ -160,6 +160,8 @@ { global $CONFIG; + $result = false; + $entity_guid = (int)$entity_guid; //$name = sanitise_string(trim($name)); //$value = sanitise_string(trim($value)); @@ -180,16 +182,19 @@ if (!$name) return false; $entity = get_entity($entity_guid); - system_log($entity, 'annotate'); - // If ok then add it - $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', 'annotation', $obj)) { - return true; - } else { - delete_annotation($result); + if (trigger_elgg_event('annotate',$entity->type,$entity)) { + system_log($entity, 'annotate'); + + // If ok then add it + $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', 'annotation', $obj)) { + return true; + } else { + delete_annotation($result); + } } } -- cgit v1.2.3