aboutsummaryrefslogtreecommitdiff
path: root/engine/lib
diff options
context:
space:
mode:
Diffstat (limited to 'engine/lib')
-rw-r--r--engine/lib/entities.php27
1 files changed, 27 insertions, 0 deletions
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
@@ -682,6 +682,33 @@ function get_entity($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.
*
* Entities are the basic unit of storage in Elgg. This function