diff options
author | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-12-16 20:33:13 +0100 |
---|---|---|
committer | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-12-17 17:41:57 +0100 |
commit | 6779bf113d27eca305661c5da67f685ddf2147df (patch) | |
tree | cf483aac5891ce370441298b16be273bfe30be69 /lib/private/group | |
parent | 0f535e38665f21ee92d41d19a51adec4459614bc (diff) | |
download | nextcloud-server-6779bf113d27eca305661c5da67f685ddf2147df.tar.gz nextcloud-server-6779bf113d27eca305661c5da67f685ddf2147df.zip |
add isAdmin and isInGroup methods for the group manager
Diffstat (limited to 'lib/private/group')
-rw-r--r-- | lib/private/group/manager.php | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/lib/private/group/manager.php b/lib/private/group/manager.php index be7bf972693..8dcf14fc1d2 100644 --- a/lib/private/group/manager.php +++ b/lib/private/group/manager.php @@ -170,7 +170,14 @@ class Manager extends PublicEmitter implements IGroupManager { * @return \OC\Group\Group[] */ public function getUserGroups($user) { - $uid = $user->getUID(); + return $this->getUserIdGroups($user->getUID()); + } + + /** + * @param string $uid the user id + * @return \OC\Group\Group[] + */ + public function getUserIdGroups($uid) { if (isset($this->cachedUserGroups[$uid])) { return $this->cachedUserGroups[$uid]; } @@ -184,7 +191,26 @@ class Manager extends PublicEmitter implements IGroupManager { $this->cachedUserGroups[$uid] = $groups; return $this->cachedUserGroups[$uid]; } - + + /** + * Checks if a userId is in the admin group + * @param string $userId + * @return bool if admin + */ + public function isAdmin($userId) { + return $this->isInGroup($userId, 'admin'); + } + + /** + * Checks if a userId is in a group + * @param string $userId + * @param group $group + * @return bool if in group + */ + public function isInGroup($userId, $group) { + return array_key_exists($group, $this->getUserIdGroups($userId)); + } + /** * get a list of group ids for a user * @param \OC\User\User $user |