From 64be91148a881f65224c583b92c407205db24634 Mon Sep 17 00:00:00 2001 From: dave Date: Sun, 21 Mar 2010 16:22:19 +0000 Subject: generic like this functionality added git-svn-id: http://code.elgg.org/elgg/trunk@5456 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/annotations.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'engine/lib/annotations.php') diff --git a/engine/lib/annotations.php b/engine/lib/annotations.php index b18475d57..b7dc1b9d3 100644 --- a/engine/lib/annotations.php +++ b/engine/lib/annotations.php @@ -1250,6 +1250,29 @@ function get_annotation_url($id) { return false; } +/** + * Check to see if a user has already created an annotation on an object + * + * @param ElggEntity $entity + * @return true | false + */ +function elgg_already_created_annotation($entity_guid, $annotation_type) { + global $CONFIG; + $entity_guid = (int)$entity_guid; + $annotation_type = sanitise_string($annotation_type); + $owner_guid = get_loggedin_userid(); + $sql = "select a.id" . + " FROM {$CONFIG->dbprefix}annotations a, {$CONFIG->dbprefix}metastrings m " . + " WHERE a.owner_guid={$owner_guid} AND a.entity_guid={$entity_guid} " . + " AND a.name_id=m.id AND m.string='{$annotation_type}'"; + //get the annotation type id + $check_annotation = get_data_row($sql); + //check to see if the user has already liked + if($check_annotation) + return true; + else + return false; +} /** * Register an annotation url handler. -- cgit v1.2.3