aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/access.php
diff options
context:
space:
mode:
authorkevinjardine <kevinjardine@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-03-04 13:17:20 +0000
committerkevinjardine <kevinjardine@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-03-04 13:17:20 +0000
commit8587c6d80aed5e978b52325f80175392c3961eea (patch)
treef9d448c2d85eef61f96106635b22192b92c339ef /engine/lib/access.php
parent6729b0e5387edd6edf76df5fb2f0a9dad7cf54e0 (diff)
downloadelgg-8587c6d80aed5e978b52325f80175392c3961eea.tar.gz
elgg-8587c6d80aed5e978b52325f80175392c3961eea.tar.bz2
Added has_access_to_entity function
git-svn-id: https://code.elgg.org/elgg/trunk@3068 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/access.php')
-rw-r--r--engine/lib/access.php27
1 files changed, 27 insertions, 0 deletions
diff --git a/engine/lib/access.php b/engine/lib/access.php
index 8f8373524..ecdcaad3b 100644
--- a/engine/lib/access.php
+++ b/engine/lib/access.php
@@ -260,6 +260,33 @@ END;
}
/**
+ * Determines whether the given user has access to the given entity
+ *
+ * @param ElggEntity $entity The entity to check access for.
+ * @param ElggUser $user Optionally the user to check access for.
+ *
+ * @return boolean True if the user can access the entity
+ */
+
+ function has_access_to_entity($entity,$user = null) {
+ global $CONFIG;
+
+ if (!isset($user)) {
+ $access_bit = get_access_sql_suffix("e");
+ } else {
+ $access_bit = get_access_sql_suffix("e",$user->getGUID());
+ }
+
+ $query = "SELECT guid from {$CONFIG->dbprefix}entities e WHERE e.guid = ".$entity->getGUID();
+ $query .= " AND ".$access_bit; // Add access controls
+ if (get_data($query)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
* Returns an array of access permissions that the specified user is allowed to save objects with.
* Permissions are of the form ('id' => 'Description')
*