From cfc804ad21cb1457c4d77494d01dd4b533c7cd5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Mon, 15 Jul 2024 20:19:46 +0200 Subject: [PATCH] fix: Add method to map board to file permissions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- lib/Service/PermissionService.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/Service/PermissionService.php b/lib/Service/PermissionService.php index e8bf4116f..53ea1725d 100644 --- a/lib/Service/PermissionService.php +++ b/lib/Service/PermissionService.php @@ -19,6 +19,7 @@ use OCA\Deck\NoPermissionException; use OCP\AppFramework\Db\DoesNotExistException; use OCP\AppFramework\Db\MultipleObjectsReturnedException; use OCP\Cache\CappedMemoryCache; +use OCP\Constants; use OCP\IConfig; use OCP\IGroupManager; use OCP\IUserManager; @@ -132,6 +133,20 @@ class PermissionService { 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 * @return bool