Return the highest role for a project when a user is member of multiple groups

This commit is contained in:
Frederic Guillot
2016-01-18 21:20:35 -05:00
parent bcbb329786
commit ddb73063a7
5 changed files with 62 additions and 2 deletions

View File

@@ -86,6 +86,26 @@ class AccessMap
return $roles;
}
/**
* 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
*