fix: Add method to map board to file permissions
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
committed by
Julius Knorr
parent
fb236edf8c
commit
cfc804ad21
@@ -19,6 +19,7 @@ use OCA\Deck\NoPermissionException;
|
|||||||
use OCP\AppFramework\Db\DoesNotExistException;
|
use OCP\AppFramework\Db\DoesNotExistException;
|
||||||
use OCP\AppFramework\Db\MultipleObjectsReturnedException;
|
use OCP\AppFramework\Db\MultipleObjectsReturnedException;
|
||||||
use OCP\Cache\CappedMemoryCache;
|
use OCP\Cache\CappedMemoryCache;
|
||||||
|
use OCP\Constants;
|
||||||
use OCP\IConfig;
|
use OCP\IConfig;
|
||||||
use OCP\IGroupManager;
|
use OCP\IGroupManager;
|
||||||
use OCP\IUserManager;
|
use OCP\IUserManager;
|
||||||
@@ -132,6 +133,20 @@ class PermissionService {
|
|||||||
throw new NoPermissionException('Permission denied');
|
throw new NoPermissionException('Permission denied');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function boardToFilePermission(array $permissions): int {
|
||||||
|
$result = 0;
|
||||||
|
foreach ($permissions as $key => $value) {
|
||||||
|
$result |= $value ? match ($key) {
|
||||||
|
Acl::PERMISSION_READ => Constants::PERMISSION_READ,
|
||||||
|
Acl::PERMISSION_EDIT => Constants::PERMISSION_UPDATE | Constants::PERMISSION_DELETE | Constants::PERMISSION_CREATE | Constants::PERMISSION_DELETE,
|
||||||
|
Acl::PERMISSION_SHARE => Constants::PERMISSION_SHARE,
|
||||||
|
default => 0,
|
||||||
|
} : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $boardId
|
* @param $boardId
|
||||||
* @return bool
|
* @return bool
|
||||||
|
|||||||
Reference in New Issue
Block a user