aboutsummaryrefslogtreecommitdiff
path: root/engine/lib
diff options
context:
space:
mode:
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-03-15 11:36:39 +0000
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-03-15 11:36:39 +0000
commit377169a08d31e1b058d35995cdf05b394b82800a (patch)
tree5a032a032a79c64a43223b8b0ae3f80e4b4f339e /engine/lib
parentb0e03ebf8e23db1c52b6c530328cf44f8accbd91 (diff)
downloadelgg-377169a08d31e1b058d35995cdf05b394b82800a.tar.gz
elgg-377169a08d31e1b058d35995cdf05b394b82800a.tar.bz2
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
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