From dc2073ed2436bfe8ea47d9ca48e058c5dc050897 Mon Sep 17 00:00:00 2001 From: ben Date: Tue, 24 Feb 2009 18:16:43 +0000 Subject: Fix for previous, including a change to check_entity_relationships that actually returns the relationship object. git-svn-id: https://code.elgg.org/elgg/trunk@2934 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/relationships.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'engine/lib/relationships.php') diff --git a/engine/lib/relationships.php b/engine/lib/relationships.php index d8e7d7abe..600bb2f0a 100644 --- a/engine/lib/relationships.php +++ b/engine/lib/relationships.php @@ -382,12 +382,12 @@ } /** - * Determine whether or not a relationship between two entities exists + * Determine whether or not a relationship between two entities exists and returns the relationship object if it does * * @param int $guid_one The GUID of the entity "owning" the relationship * @param string $relationship The type of relationship * @param int $guid_two The GUID of the entity the relationship is with - * @return true|false + * @return object|false Depending on success */ function check_entity_relationship($guid_one, $relationship, $guid_two) { @@ -397,8 +397,8 @@ $relationship = sanitise_string($relationship); $guid_two = (int)$guid_two; - if ($row = get_data_row("SELECT guid_one FROM {$CONFIG->dbprefix}entity_relationships WHERE guid_one=$guid_one AND relationship='$relationship' AND guid_two=$guid_two limit 1")) { - return true; + if ($row = get_data_row("SELECT * FROM {$CONFIG->dbprefix}entity_relationships WHERE guid_one=$guid_one AND relationship='$relationship' AND guid_two=$guid_two limit 1")) { + return $row; } return false; } @@ -418,6 +418,9 @@ $relationship = sanitise_string($relationship); $guid_two = (int)$guid_two; + $obj = check_entity_relationship($guid_one, $relationship, $guid_two); + if ($obj == false) return false; + if (trigger_elgg_event('delete', $relationship, $obj)) { return delete_data("DELETE from {$CONFIG->dbprefix}entity_relationships where guid_one=$guid_one and relationship='$relationship' and guid_two=$guid_two"); } else { -- cgit v1.2.3