summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.txt1
-rw-r--r--acl.module20
2 files changed, 21 insertions, 0 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index e2aceeb..7ba7430 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -5,6 +5,7 @@ CHANGELOG for ACL for Drupal 7
acl 7.x-1.x-dev:
Enhancements:
+ - Add acl_get_ids_by_user() API.
- Add support for ACLs with name /and number/.
diff --git a/acl.module b/acl.module
index aa7fad1..a191517 100644
--- a/acl.module
+++ b/acl.module
@@ -199,6 +199,26 @@ function acl_has_user($acl_id, $uid) {
}
/**
+ * Gets an array of acl_ids held by a user
+ */
+function acl_get_ids_by_user($module, $uid, $name = NULL, $number = NULL) {
+ $query = db_select('acl', 'a');
+ $query->join('acl_user', 'au', 'a.acl_id = au.acl_id');
+ $query
+ ->fields('a', array('acl_id'))
+ ->condition('a.module', $module)
+ ->condition('au.uid', $uid);
+ if (isset($name)) {
+ $query->condition('a.name', $name);
+ }
+ if (isset($number)) {
+ $query->condition('a.number', $number);
+ }
+ $acl_ids = $query->execute()->fetchCol();
+ return $acl_ids;
+}
+
+/**
* Gets the uids of an acl
*/
function acl_get_uids($acl_id) {