Added required servergroups to use group assigner

This commit is contained in:
Wruczek
2019-10-18 19:58:05 +02:00
parent 15a00998da
commit 58cd3e90dd
4 changed files with 43 additions and 3 deletions

View File

@ -133,4 +133,34 @@ class Assigner {
return 0;
}
public static function getRequiredSgids() {
return Config::get("assigner_required_sgids");
}
public static function canUseAssigner() {
// if there are no required sgids, the user can use assigner and
// we can skip the other, more expensive checks that will require
// fetching user groups from TS3
if (empty(self::getRequiredSgids())) {
return true;
}
$userGroups = Auth::getUserServerGroupIds();
return self::canUseAssignerSgArray($userGroups);
}
public static function canUseAssignerSgArray(array $serverGroups) {
// user needs to be in at least one of those groups to be able
// to use group assigner
$requiredSgid = self::getRequiredSgids();
foreach ($requiredSgid as $sgid) {
if (in_array($sgid, $serverGroups, false)) {
return true;
}
}
return false;
}
}