From 377169a08d31e1b058d35995cdf05b394b82800a Mon Sep 17 00:00:00 2001 From: cash Date: Tue, 15 Mar 2011 11:36:39 +0000 Subject: Refs #2814 can now check if an entity exists indepedent of access permissions git-svn-id: http://code.elgg.org/elgg/trunk@8720 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/entities.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'engine/lib') diff --git a/engine/lib/entities.php b/engine/lib/entities.php index 85ab527e7..7f07f7359 100644 --- a/engine/lib/entities.php +++ b/engine/lib/entities.php @@ -681,6 +681,33 @@ function get_entity($guid) { return entity_row_to_elggstar(get_entity_as_row($guid)); } +/** + * Does an entity exist? + * + * This function checks for the existence of an entity independent of access + * permissions. It is useful for situations when a user cannot access an entity + * and it must be determined whether entity has been deleted or the access level + * has changed. + * + * @param int $guid The GUID of the entity + * + * @return bool + * @since 1.8.0 + */ +function elgg_entity_exists($guid) { + global $CONFIG; + + $guid = sanitize_int($guid); + + $query = "SELECT count(*) as total FROM {$CONFIG->dbprefix}entities WHERE guid = $guid"; + $result = get_data_row($query); + if ($result->total == 0) { + return false; + } else { + return true; + } +} + /** * Returns an array of entities with optional filtering. * -- cgit v1.2.3