summaryrefslogtreecommitdiff
path: root/app/Core
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-01-18 21:20:35 -0500
committerFrederic Guillot <fred@kanboard.net>2016-01-18 21:20:35 -0500
commitddb73063a7889c8dad79dd7148c01c9bc845d9f0 (patch)
tree89fcc0a11721b75c6ac823f6229ef2e836917e90 /app/Core
parentbcbb3297860a8fe106094fefc04f74af4e30aed2 (diff)
Return the highest role for a project when a user is member of multiple groups
Diffstat (limited to 'app/Core')
-rw-r--r--app/Core/Security/AccessMap.php20
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