diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-01-18 21:20:35 -0500 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-01-18 21:20:35 -0500 |
commit | ddb73063a7889c8dad79dd7148c01c9bc845d9f0 (patch) | |
tree | 89fcc0a11721b75c6ac823f6229ef2e836917e90 /app/Core/Security/AccessMap.php | |
parent | bcbb3297860a8fe106094fefc04f74af4e30aed2 (diff) |
Return the highest role for a project when a user is member of multiple groups
Diffstat (limited to 'app/Core/Security/AccessMap.php')
-rw-r--r-- | app/Core/Security/AccessMap.php | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/app/Core/Security/AccessMap.php b/app/Core/Security/AccessMap.php index 02a4ca45..f34c4b00 100644 --- a/app/Core/Security/AccessMap.php +++ b/app/Core/Security/AccessMap.php @@ -87,6 +87,26 @@ class AccessMap } /** + * Get the highest role from a list + * + * @access public + * @param array $roles + * @return string + */ + public function getHighestRole(array $roles) + { + $rank = array(); + + foreach ($roles as $role) { + $rank[$role] = count($this->getRoleHierarchy($role)); + } + + asort($rank); + + return key($rank); + } + + /** * Add new access rules * * @access public |