From f73b35f3726a4d5a5f78882ebdf241420e38f8a1 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 ++++++++++---- Admin/Install/Application/QA/Application.php | 12 ++++-------- Controller/ApiController.php | 12 ++++++------ tests/Controller/ApiControllerTest.php | 2 +- 4 files changed, 21 insertions(+), 19 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/Admin/Install/Application/QA/Application.php b/Admin/Install/Application/QA/Application.php index ba55a7b..b54b56d 100755 --- a/Admin/Install/Application/QA/Application.php +++ b/Admin/Install/Application/QA/Application.php @@ -153,18 +153,14 @@ final class Application if (!($account instanceof NullAccount)) { $response->header->l11n = $account->l11n; - } elseif ($this->app->sessionManager->get('language') !== null) { + } elseif ($this->app->sessionManager->get('language') !== null + && $response->header->l11n->getLanguage() !== $this->app->sessionManager->get('language') + ) { $response->header->l11n ->loadFromLanguage( $this->app->sessionManager->get('language'), $this->app->sessionManager->get('country') ?? '*' ); - } elseif ($this->app->cookieJar->get('language') !== null) { - $response->header->l11n - ->loadFromLanguage( - $this->app->cookieJar->get('language'), - $this->app->cookieJar->get('country') ?? '*' - ); } if (!\in_array($response->getLanguage(), $this->config['language'])) { @@ -212,7 +208,7 @@ final class Application $request->uri->getRoute(), $request->getDataString('CSRF'), $request->getRouteVerb(), - $this->app->appName, + $this->app->appId, $this->app->unitId, $account, $request->getData() diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 0b67a45..480fc46 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -210,9 +210,9 @@ final class ApiController extends Controller private function validateQAQuestionCreate(RequestAbstract $request) : array { $val = []; - if (($val['title'] = empty($request->getData('title'))) - || ($val['plain'] = empty($request->getData('plain'))) - || ($val['language'] = empty($request->getData('language'))) + if (($val['title'] = !$request->hasData('title')) + || ($val['plain'] = !$request->hasData('plain')) + || ($val['language'] = !$request->hasData('language')) || ($val['status'] = ( $request->hasData('status') && !QAQuestionStatus::isValidValue((int) $request->getData('status')) @@ -308,8 +308,8 @@ final class ApiController extends Controller private function validateQAAnswerCreate(RequestAbstract $request) : array { $val = []; - if (($val['plain'] = empty($request->getData('plain'))) - || ($val['question'] = empty($request->getData('question'))) + if (($val['plain'] = !$request->hasData('plain')) + || ($val['question'] = !$request->hasData('question')) || ($val['status'] = ( $request->hasData('status') && !QAAnswerStatus::isValidValue((int) $request->getData('status')) @@ -437,7 +437,7 @@ final class ApiController extends Controller private function validateQAAppCreate(RequestAbstract $request) : array { $val = []; - if (($val['name'] = empty($request->getData('name')))) { + if (($val['name'] = !$request->hasData('name'))) { return $val; } diff --git a/tests/Controller/ApiControllerTest.php b/tests/Controller/ApiControllerTest.php index be068a1..3c5268a 100755 --- a/tests/Controller/ApiControllerTest.php +++ b/tests/Controller/ApiControllerTest.php @@ -75,7 +75,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase $permission = new AccountPermission(); $permission->setUnit(1); - $permission->setApp('backend'); + $permission->setApp(2); $permission->setPermission( PermissionType::READ | PermissionType::CREATE