Move to int values for permission type checks
This commit is contained in:
@@ -83,10 +83,6 @@ class Acl extends RelationalEntity implements \JsonSerializable {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* FIXME: migrate other code to const PERMISSION_TYPE_ instead of strings
|
|
||||||
* iirc js uses those strings as well
|
|
||||||
*/
|
|
||||||
public function getTypeString() {
|
public function getTypeString() {
|
||||||
if ($this->type === Acl::PERMISSION_TYPE_GROUP) {
|
if ($this->type === Acl::PERMISSION_TYPE_GROUP) {
|
||||||
return 'group';
|
return 'group';
|
||||||
|
|||||||
@@ -127,14 +127,14 @@ class PermissionService {
|
|||||||
public function userCan(array $acls, $permission) {
|
public function userCan(array $acls, $permission) {
|
||||||
// check for users
|
// check for users
|
||||||
foreach ($acls as $acl) {
|
foreach ($acls as $acl) {
|
||||||
if ($acl->getType() === "user" && $acl->getParticipant() === $this->userId) {
|
if ($acl->getType() === Acl::PERMISSION_TYPE_USER && $acl->getParticipant() === $this->userId) {
|
||||||
return $acl->getPermission($permission);
|
return $acl->getPermission($permission);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// check for groups
|
// check for groups
|
||||||
$hasGroupPermission = false;
|
$hasGroupPermission = false;
|
||||||
foreach ($acls as $acl) {
|
foreach ($acls as $acl) {
|
||||||
if (!$hasGroupPermission && $acl->getType() === "group" && $this->groupManager->isInGroup($this->userId, $acl->getParticipant())) {
|
if (!$hasGroupPermission && $acl->getType() === Acl::PERMISSION_TYPE_GROUP && $this->groupManager->isInGroup($this->userId, $acl->getParticipant())) {
|
||||||
$hasGroupPermission = $acl->getPermission($permission);
|
$hasGroupPermission = $acl->getPermission($permission);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user