aboutsummaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
authorben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-02-24 18:16:43 +0000
committerben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-02-24 18:16:43 +0000
commitdc2073ed2436bfe8ea47d9ca48e058c5dc050897 (patch)
tree2c3628034369ec42c8d35fc277c9d24e9fd8a9fe /engine
parentce90f559254686fca490d91d2539956b748406e7 (diff)
downloadelgg-dc2073ed2436bfe8ea47d9ca48e058c5dc050897.tar.gz
elgg-dc2073ed2436bfe8ea47d9ca48e058c5dc050897.tar.bz2
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
Diffstat (limited to 'engine')
-rw-r--r--engine/lib/relationships.php11
1 files changed, 7 insertions, 4 deletions
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 {