From 9fd9b0f46299f51cff096fb0a4ff2a09f4a98b91 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 6 May 2023 11:42:06 +0000 Subject: [PATCH] make id public, organigram impl. media password/encryption, settings bug fix, Money->FloatInt change, ... --- Application/Timerecording/Application.php | 6 ++++-- Controller/ApiController.php | 4 ++-- Controller/BackendController.php | 6 +++--- Models/Session.php | 4 ++-- Models/SessionElement.php | 4 ++-- Theme/Backend/private-dashboard.tpl.php | 4 ++-- tests/Controller/ApiControllerTest.php | 4 ++-- tests/Models/NullSessionElementTest.php | 2 +- tests/Models/NullSessionTest.php | 2 +- tests/Models/SessionElementMapperTest.php | 8 ++++---- tests/Models/SessionElementTest.php | 4 ++-- tests/Models/SessionMapperTest.php | 8 ++++---- tests/Models/SessionTest.php | 2 +- 13 files changed, 30 insertions(+), 28 deletions(-) diff --git a/Application/Timerecording/Application.php b/Application/Timerecording/Application.php index 88d2710..854af7d 100755 --- a/Application/Timerecording/Application.php +++ b/Application/Timerecording/Application.php @@ -176,7 +176,7 @@ final class Application $account = $this->loadAccount($request); - if (!($account instanceof NullAccount)) { + if ($account->id > 0) { $response->header->l11n = $account->l11n; } elseif ($this->app->sessionManager->get('language') !== null && $response->header->l11n->getLanguage() !== $this->app->sessionManager->get('language') @@ -186,6 +186,8 @@ final class Application $this->app->sessionManager->get('language'), $this->app->sessionManager->get('country') ?? '*' ); + } else { + $this->app->setResponseLanguage($request, $response, $this->config); } UriFactory::setQuery('/lang', $response->getLanguage()); @@ -201,7 +203,7 @@ final class Application $this->initResponseHead($head, $request, $response); /* Handle not logged in */ - if ($account->getId() < 1) { + if ($account->id < 1) { $this->createLoggedOutResponse($response, $head, $pageView); return; diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 5bed01d..1c8289c 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -100,7 +100,7 @@ final class ApiController extends Controller $type = $request->getDataInt('type') ?? ClockingType::OFFICE; $status = $request->getDataInt('status') ?? ClockingStatus::START; - if ($employee instanceof NullEmployee) { + if ($employee->id === 0) { return null; } @@ -219,7 +219,7 @@ final class ApiController extends Controller $session = SessionMapper::get()->where('id', (int) $request->getData('session'))->execute(); // cannot create session element for none existing session - if ($session === null || $session instanceof NullSession) { + if ($session->id === 0) { return null; } diff --git a/Controller/BackendController.php b/Controller/BackendController.php index e56346e..a307876 100755 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -78,7 +78,7 @@ final class BackendController extends Controller implements DashboardElementInte ->execute(); /** @var \Modules\HumanResourceTimeRecording\Models\Session $lastOpenSession */ - $lastOpenSession = SessionMapper::getMostPlausibleOpenSessionForEmployee($employee->getId()); + $lastOpenSession = SessionMapper::getMostPlausibleOpenSessionForEmployee($employee->id); $start = new SmartDateTime('now'); $start = $start->getEndOfDay(); @@ -86,7 +86,7 @@ final class BackendController extends Controller implements DashboardElementInte $limit->smartModify(0, -2, 0); $list = SessionMapper::getAll() - ->where('employee', $employee->getId()) + ->where('employee', $employee->id) ->where('createdAt', $start->format('Y-m-d H:i:s'), '<=') ->sort('id', OrderType::DESC) ->execute(); @@ -126,7 +126,7 @@ final class BackendController extends Controller implements DashboardElementInte ->where('profile/account', $request->header->account) ->execute(); - if ($session->employee->getId() !== $employee->getId()) { + if ($session->employee->id !== $employee->id) { $view->addData('session', new NullSession()); } else { $view->addData('session', $session); diff --git a/Models/Session.php b/Models/Session.php index e47f1fa..c18849c 100755 --- a/Models/Session.php +++ b/Models/Session.php @@ -33,7 +33,7 @@ class Session implements \JsonSerializable * @var int * @since 1.0.0 */ - protected int $id = 0; + public int $id = 0; /** * Session start @@ -65,7 +65,7 @@ class Session implements \JsonSerializable * @var int * @since 1.0.0 */ - private int $type = ClockingType::OFFICE; + public int $type = ClockingType::OFFICE; /** * Session elements. diff --git a/Models/SessionElement.php b/Models/SessionElement.php index 44ab266..2a3946c 100755 --- a/Models/SessionElement.php +++ b/Models/SessionElement.php @@ -30,7 +30,7 @@ class SessionElement implements \JsonSerializable * @var int * @since 1.0.0 */ - protected int $id = 0; + public int $id = 0; /** * Session element status. @@ -38,7 +38,7 @@ class SessionElement implements \JsonSerializable * @var int * @since 1.0.0 */ - private int $status = ClockingStatus::START; + public int $status = ClockingStatus::START; /** * DateTime diff --git a/Theme/Backend/private-dashboard.tpl.php b/Theme/Backend/private-dashboard.tpl.php index f64676c..7b3a078 100755 --- a/Theme/Backend/private-dashboard.tpl.php +++ b/Theme/Backend/private-dashboard.tpl.php @@ -68,7 +68,7 @@ echo $this->getData('nav')->render(); ?>