From 5a850e43d350005392c2c9d51d5c97c05c4801bd Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Thu, 26 Jan 2023 21:54:13 +0100 Subject: [PATCH] org -> unit change, some new functionality --- Admin/Install/db.json | 4 ++-- Controller/ApiController.php | 12 ++++++------ Controller/BackendController.php | 2 +- tests/Controller/ApiControllerTest.php | 2 +- tests/ControllerTestTemp.php | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Admin/Install/db.json b/Admin/Install/db.json index 9abcf1c..9bb0a81 100755 --- a/Admin/Install/db.json +++ b/Admin/Install/db.json @@ -67,8 +67,8 @@ "name": "helper_template_unit", "type": "INT", "null": true, - "foreignTable": "organization_unit", - "foreignKey": "organization_unit_id" + "foreignTable": "unit", + "foreignKey": "unit_id" }, "helper_template_created": { "name": "helper_template_created", diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 8c2271f..c2f0a9d 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -92,8 +92,8 @@ final class ApiController extends Controller $isExport = \in_array($request->getData('type'), ['xlsx', 'pdf', 'docx', 'pptx', 'csv', 'json']); // is allowed to read - if (!$this->app->accountManager->get($accountId)->hasPermission(PermissionType::READ, $this->app->orgId, null, self::NAME, PermissionCategory::REPORT, $template->getId()) - || ($isExport && !$this->app->accountManager->get($accountId)->hasPermission(PermissionType::READ, $this->app->orgId, $this->app->appName, self::NAME, PermissionCategory::EXPORT)) + if (!$this->app->accountManager->get($accountId)->hasPermission(PermissionType::READ, $this->app->unitId, null, self::NAME, PermissionCategory::REPORT, $template->getId()) + || ($isExport && !$this->app->accountManager->get($accountId)->hasPermission(PermissionType::READ, $this->app->unitId, $this->app->appName, self::NAME, PermissionCategory::EXPORT)) ) { $response->header->status = RequestStatusCode::R_403; @@ -409,7 +409,7 @@ final class ApiController extends Controller } // is allowed to create - if (!$this->app->accountManager->get($request->header->account)->hasPermission(PermissionType::CREATE, $this->app->orgId, null, self::NAME, PermissionCategory::TEMPLATE)) { + if (!$this->app->accountManager->get($request->header->account)->hasPermission(PermissionType::CREATE, $this->app->unitId, null, self::NAME, PermissionCategory::TEMPLATE)) { $response->header->status = RequestStatusCode::R_403; return; @@ -465,7 +465,7 @@ final class ApiController extends Controller $this->app->moduleManager->get('Admin')->createAccountModelPermission( new AccountPermission( $request->header->account, - $this->app->orgId, + $this->app->unitId, $this->app->appName, self::NAME, self::NAME, @@ -579,7 +579,7 @@ final class ApiController extends Controller } // is allowed to create - if (!$this->app->accountManager->get($request->header->account)->hasPermission(PermissionType::CREATE, $this->app->orgId, null, self::NAME, PermissionCategory::REPORT)) { + if (!$this->app->accountManager->get($request->header->account)->hasPermission(PermissionType::CREATE, $this->app->unitId, null, self::NAME, PermissionCategory::REPORT)) { $response->header->status = RequestStatusCode::R_403; return; @@ -617,7 +617,7 @@ final class ApiController extends Controller $this->app->moduleManager->get('Admin')->createAccountModelPermission( new AccountPermission( $request->header->account, - $this->app->orgId, + $this->app->unitId, $this->app->appName, self::NAME, self::NAME, diff --git a/Controller/BackendController.php b/Controller/BackendController.php index b162392..79f7cb5 100755 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -224,7 +224,7 @@ final class BackendController extends Controller $view->addData('rcoll', $rcoll); } - $view->addData('unit', $this->app->orgId); + $view->addData('unit', $this->app->unitId); $view->addData('tcoll', $tcoll); $view->addData('lang', $request->getData('lang') ?? $request->getLanguage()); $view->addData('template', $template); diff --git a/tests/Controller/ApiControllerTest.php b/tests/Controller/ApiControllerTest.php index 6c45bec..74c6fac 100755 --- a/tests/Controller/ApiControllerTest.php +++ b/tests/Controller/ApiControllerTest.php @@ -62,7 +62,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase }; $this->app->dbPool = $GLOBALS['dbpool']; - $this->app->orgId = 1; + $this->app->unitId = 1; $this->app->accountManager = new AccountManager($GLOBALS['session']); $this->app->appSettings = new CoreSettings(); $this->app->moduleManager = new ModuleManager($this->app, __DIR__ . '/../../../../Modules/'); diff --git a/tests/ControllerTestTemp.php b/tests/ControllerTestTemp.php index 9295b1e..67cbc7b 100755 --- a/tests/ControllerTestTemp.php +++ b/tests/ControllerTestTemp.php @@ -46,7 +46,7 @@ class ControllerTest extends \PHPUnit\Framework\TestCase }; $this->app->dbPool = $GLOBALS['dbpool']; - $this->app->orgId = 1; + $this->app->unitId = 1; $this->app->accountManager = new AccountManager($GLOBALS['session']); $this->app->appSettings = new CoreSettings(); $this->app->moduleManager = new ModuleManager($this->app, __DIR__ . '/../../../Modules/');