diff options
| author | cash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-03-15 11:36:39 +0000 | 
|---|---|---|
| committer | cash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-03-15 11:36:39 +0000 | 
| commit | 377169a08d31e1b058d35995cdf05b394b82800a (patch) | |
| tree | 5a032a032a79c64a43223b8b0ae3f80e4b4f339e | |
| parent | b0e03ebf8e23db1c52b6c530328cf44f8accbd91 (diff) | |
| download | elgg-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
| -rw-r--r-- | engine/lib/entities.php | 27 | 
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  | 
