summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Almdal <tnalmdal@shaw.ca>2009-07-21 15:52:46 -0700
committerTim Almdal <tnalmdal@shaw.ca>2009-07-21 15:52:46 -0700
commitf533aee1cc71e8db739406859ac0cf43dce030ec (patch)
treeb2bfd14ad1bd64b6b620bf6bd855e2ae28933c98
parent9f410ec764cdb8ece4dc6ce1fb1754afad929335 (diff)
Add an API method user_can that allows for checking a specific user has the
specified permission to the item. Changed can to delegate to this method passing in the active user.
-rw-r--r--modules/gallery/helpers/access.php14
1 files changed, 13 insertions, 1 deletions
diff --git a/modules/gallery/helpers/access.php b/modules/gallery/helpers/access.php
index 63324e5d..224b51e0 100644
--- a/modules/gallery/helpers/access.php
+++ b/modules/gallery/helpers/access.php
@@ -78,11 +78,23 @@ class access_Core {
* @return boolean
*/
static function can($perm_name, $item) {
+ return self::user_can(user::active(), $perm_name, $item);
+ }
+
+ /**
+ * Does the user have this permission on this item?
+ *
+ * @param User_Model $user
+ * @param string $perm_name
+ * @param Item_Model $item
+ * @return boolean
+ */
+ static function user_can($user, $perm_name, $item) {
if (!$item->loaded) {
return false;
}
- if (user::active()->admin) {
+ if ($user->admin) {
return true;
}