From a3268733c6f2c503d92eb42b7665b428ef8b5588 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 8 Apr 2023 04:36:26 +0200 Subject: [PATCH] fix billing process --- .github/user_bug_report.md | 14 ++++++++++---- Controller/ApiController.php | 6 +++--- Controller/BackendController.php | 4 ++-- tests/Controller/ApiControllerTest.php | 2 +- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/.github/user_bug_report.md b/.github/user_bug_report.md index 9e5f2a5..4b92a8e 100755 --- a/.github/user_bug_report.md +++ b/.github/user_bug_report.md @@ -8,9 +8,11 @@ assignees: '' --- # Bug Description + A clear and concise description of what the bug is. # How to Reproduce + Steps to reproduce the behavior: 1. Go to '...' @@ -19,16 +21,20 @@ Steps to reproduce the behavior: 4. See error # Expected Behavior + A clear and concise description of what you expected to happen. # Screenshots + If applicable, add screenshots to help explain your problem. # System Information - - System: [e.g. PC or iPhone11, ...] - - OS: [e.g. iOS] - - Browser [e.g. chrome, safari] - - KarakaVersion [e.g. 22] + +- System: [e.g. PC or iPhone11, ...] +- OS: [e.g. iOS] +- Browser [e.g. chrome, safari] +- KarakaVersion [e.g. 22] # Additional Information + Add any other context about the problem here. diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 4049458..fb08117 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -59,8 +59,8 @@ final class ApiController extends Controller private function validateNewsCreate(RequestAbstract $request) : array { $val = []; - if (($val['title'] = empty($request->getData('title'))) - || ($val['plain'] = empty($request->getData('plain'))) + if (($val['title'] = !$request->hasData('title')) + || ($val['plain'] = !$request->hasData('plain')) || ($val['lang'] = ( $request->hasData('lang') && !ISO639x1Enum::isValidValue(\strtolower((string) $request->getData('lang'))) @@ -334,7 +334,7 @@ final class ApiController extends Controller $newsArticle->isFeatured = $request->getDataBool('featured') ?? true; // allow comments - if (!empty($request->getData('allow_comments')) + if ($request->hasData('allow_comments') && !(($commentApi = $this->app->moduleManager->get('Comments')) instanceof NullModule) ) { /** @var \Modules\Comments\Controller\ApiController $commentApi */ diff --git a/Controller/BackendController.php b/Controller/BackendController.php index f8c0aeb..7e86024 100755 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -173,7 +173,7 @@ final class BackendController extends Controller implements DashboardElementInte if ($article->createdBy->getId() !== $accountId && !$this->app->accountManager->get($accountId)->hasPermission( - PermissionType::READ, $this->app->unitId, $this->app->appName, self::NAME, PermissionCategory::NEWS, $article->getId()) + PermissionType::READ, $this->app->unitId, $this->app->appId, self::NAME, PermissionCategory::NEWS, $article->getId()) ) { $view->setTemplate('/Web/Backend/Error/403_inline'); $response->header->status = RequestStatusCode::R_403; @@ -199,7 +199,7 @@ final class BackendController extends Controller implements DashboardElementInte $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1000601001, $request, $response)); $view->addData('news', $article); $view->addData('editable', $this->app->accountManager->get($accountId)->hasPermission( - PermissionType::MODIFY, $this->app->unitId, $this->app->appName, self::NAME, PermissionCategory::NEWS, $article->getId()) + PermissionType::MODIFY, $this->app->unitId, $this->app->appId, self::NAME, PermissionCategory::NEWS, $article->getId()) ); // allow comments diff --git a/tests/Controller/ApiControllerTest.php b/tests/Controller/ApiControllerTest.php index 5c2f764..531553d 100755 --- a/tests/Controller/ApiControllerTest.php +++ b/tests/Controller/ApiControllerTest.php @@ -62,7 +62,7 @@ final class ControllerTest extends \PHPUnit\Framework\TestCase $permission = new AccountPermission(); $permission->setUnit(1); - $permission->setApp('backend'); + $permission->setApp(2); $permission->setPermission( PermissionType::READ | PermissionType::CREATE