From 375df875b48cb1733cf3074c3c7aef349d29612e Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 6 May 2023 11:42:05 +0000 Subject: [PATCH] make id public, organigram impl. media password/encryption, settings bug fix, Money->FloatInt change, ... --- Admin/Install/Messages.install.json | 45 ++++- Admin/Install/db.json | 5 + Admin/Install/settings.php | 3 + Admin/Installer.php | 1 + Admin/Settings/Theme/Backend/settings.tpl.php | 8 +- Controller/ApiController.php | 159 +++++++++--------- Controller/BackendController.php | 6 +- Models/Account.php | 56 +----- Models/AccountExternal.php | 6 +- Models/AccountMapper.php | 36 ++-- Models/AccountPermission.php | 2 +- Models/ApiKey.php | 4 +- Models/App.php | 2 +- Models/Contact.php | 4 +- Models/DataChange.php | 2 +- Models/Group.php | 2 +- Models/GroupPermission.php | 2 +- Models/Module.php | 2 +- Models/PermissionQueryBuilder.php | 2 +- Models/SettingsEnum.php | 3 +- .../GroupTagSelector/GroupTagSelectorView.php | 2 +- .../GroupTagSelector/group-selector.tpl.php | 32 ++-- Theme/Backend/accounts-list.tpl.php | 4 +- Theme/Backend/accounts-single.tpl.php | 22 +-- Theme/Backend/groups-list.tpl.php | 6 +- Theme/Backend/groups-single.tpl.php | 18 +- Theme/Backend/modules-list.tpl.php | 2 +- Theme/Backend/modules-log.tpl.php | 8 +- Theme/Backend/modules-settings.tpl.php | 2 +- Theme/Backend/page-list.tpl.php | 8 +- Theme/Backend/settings-general.tpl.php | 8 +- .../Api/ApiControllerAccountTrait.php | 12 +- .../Api/ApiControllerGroupTrait.php | 8 +- .../Api/ApiControllerPermissionTrait.php | 24 +-- tests/Models/AccountMapperTest.php | 6 +- tests/Models/AddressMapperTest.php | 6 +- tests/Models/AppMapperTest.php | 6 +- tests/Models/AppTest.php | 2 +- tests/Models/GroupMapperTest.php | 2 +- tests/Models/GroupTest.php | 4 +- tests/Models/ModuleTest.php | 2 +- tests/Models/NullAccountPermissionTest.php | 2 +- tests/Models/NullAccountTest.php | 2 +- tests/Models/NullAddressTest.php | 2 +- tests/Models/NullGroupPermissionTest.php | 2 +- tests/Models/NullGroupTest.php | 2 +- tests/Models/NullModuleTest.php | 2 +- 47 files changed, 253 insertions(+), 293 deletions(-) diff --git a/Admin/Install/Messages.install.json b/Admin/Install/Messages.install.json index 31bf6bc..b9a3437 100755 --- a/Admin/Install/Messages.install.json +++ b/Admin/Install/Messages.install.json @@ -5,10 +5,19 @@ "to": "", "cc": "", "bcc": "", - "subject": "Registration confirmation", "ishtml": true, - "body": "Registration Confirmation

Registration Confirmation

Dear {user_name},

Thank you for registering for our service. Your account has been successfully created.

Your username is: {user_name}

To get started, please click on the following confirmation link:

Confirm
", - "bodyalt": "Dear {user_name},\n\nThank you for registering for our service. Your account has been successfully created.\n\nYour username is: {user_name}\n\nTo get started, please click on the following confirmation link: {confirmation_link}.\n\nThank you,\n\n[Your Company]", + "l11n": { + "en": { + "subject": "Registration confirmation", + "body": "Registration Confirmation

Registration Confirmation

Dear {user_name},

Thank you for registering for our service. Your account has been successfully created.

Your username is: {user_name}

To get started, please click on the following confirmation link:

Confirm

Jingga e.K. - www.jingga.app - CEO Dennis Eichhorn

", + "bodyalt": "Dear {user_name},\n\nThank you for registering for our service. Your account has been successfully created.\n\nYour username is: {user_name}\n\nTo get started, please click on the following confirmation link: {confirmation_link}\n\n\nJingga e.K. - www.jingga.app - CEO Dennis Eichhorn" + }, + "de": { + "subject": "Registrierungsbestätigung", + "body": "Registrierungsbestätigung

Registrierungsbestätigung

Liebe(r) {user_name},

Vielen Dank für Ihre Registrierung bei unserem Service. Ihr Konto wurde erfolgreich erstellt.

Ihr Benutzername lautet: {user_name}

Um loszulegen, klicken Sie bitte auf den folgenden Bestätigungslink:

Bestätigen

Jingga e.K. - www.jingga.app - CEO Dennis Eichhorn

", + "bodyalt": "Liebe(r) {user_name},\n\nvielen Dank für Ihre Registrierung bei unserem Service. Ihr Konto wurde erfolgreich erstellt.\n\nIhr Benutzername lautet: {user_name}\n\nUm loszulegen, klicken Sie bitte auf den folgenden Bestätigungslink: {confirmation_link}\n\n\nJingga e.K. - www.jingga.app - CEO Dennis Eichhorn" + } + }, "send": false }, { @@ -17,10 +26,19 @@ "to": "", "cc": "", "bcc": "", - "subject": "Account recovery", "ishtml": true, - "body": "Registration Confirmation

Registration Confirmation

Dear [Name],

Thank you for registering for our service. Your account has been successfully created.

Your username is: [Username]

To get started, please click on the following confirmation link:

Confirm
", - "bodyalt": "Dear [Name],\n\nThank you for registering for our service. Your account has been successfully created.\n\nYour username is: [Username]\n\nTo get started, please click on the following confirmation link: [Login Link].\n\nThank you,\n\n[Your Company]", + "l11n": { + "en": { + "subject": "Account recovery", + "body": "Registration Confirmation

Registration Confirmation

Dear [Name],

Thank you for registering for our service. Your account has been successfully created.

Your username is: [Username]

To get started, please click on the following confirmation link:

Confirm

Jingga e.K. - www.jingga.app - CEO Dennis Eichhorn

", + "bodyalt": "Dear [Name],\n\nThank you for registering for our service. Your account has been successfully created.\n\nYour username is: [Username]\n\nTo get started, please click on the following confirmation link: [Login Link].\n\n\nJingga e.K. - www.jingga.app - CEO Dennis Eichhorn" + }, + "de": { + "subject": "Account recovery", + "body": "Registration Confirmation

Registration Confirmation

Dear [Name],

Thank you for registering for our service. Your account has been successfully created.

Your username is: [Username]

To get started, please click on the following confirmation link:

Confirm

Jingga e.K. - www.jingga.app - CEO Dennis Eichhorn

", + "bodyalt": "Dear [Name],\n\nThank you for registering for our service. Your account has been successfully created.\n\nYour username is: [Username]\n\nTo get started, please click on the following confirmation link: [Login Link].\n\n\nJingga e.K. - www.jingga.app - CEO Dennis Eichhorn" + } + }, "send": false }, { @@ -29,10 +47,19 @@ "to": "", "cc": "", "bcc": "", - "subject": "Failed login", "ishtml": true, - "body": "Registration Confirmation

Registration Confirmation

Dear [Name],

Thank you for registering for our service. Your account has been successfully created.

Your username is: [Username]

To get started, please click on the following confirmation link:

Confirm
", - "bodyalt": "Dear [Name],\n\nThank you for registering for our service. Your account has been successfully created.\n\nYour username is: [Username]\n\nTo get started, please click on the following confirmation link: [Login Link].\n\nThank you,\n\n[Your Company]", + "l11n": { + "en": { + "subject": "Failed login", + "body": "Registration Confirmation

Registration Confirmation

Dear [Name],

Thank you for registering for our service. Your account has been successfully created.

Your username is: [Username]

To get started, please click on the following confirmation link:

Confirm

Jingga e.K. - www.jingga.app - CEO Dennis Eichhorn

", + "bodyalt": "Dear [Name],\n\nThank you for registering for our service. Your account has been successfully created.\n\nYour username is: [Username]\n\nTo get started, please click on the following confirmation link: [Login Link].\n\n\nJingga e.K. - www.jingga.app - CEO Dennis Eichhorn" + }, + "de": { + "subject": "Failed login", + "body": "Registration Confirmation

Registration Confirmation

Dear [Name],

Thank you for registering for our service. Your account has been successfully created.

Your username is: [Username]

To get started, please click on the following confirmation link:

Confirm

Jingga e.K. - www.jingga.app - CEO Dennis Eichhorn

", + "bodyalt": "Dear [Name],\n\nThank you for registering for our service. Your account has been successfully created.\n\nYour username is: [Username]\n\nTo get started, please click on the following confirmation link: [Login Link].\n\n\nJingga e.K. - www.jingga.app - CEO Dennis Eichhorn" + } + }, "send": false } ] \ No newline at end of file diff --git a/Admin/Install/db.json b/Admin/Install/db.json index 76f8f48..4ebbd25 100755 --- a/Admin/Install/db.json +++ b/Admin/Install/db.json @@ -1473,6 +1473,11 @@ "null": true, "foreignTable": "account", "foreignKey": "account_id" + }, + "settings_encrypted": { + "name": "settings_encrypted", + "type": "TINYINT(1)", + "null": false } } }, diff --git a/Admin/Install/settings.php b/Admin/Install/settings.php index 11c87b5..1aa0593 100755 --- a/Admin/Install/settings.php +++ b/Admin/Install/settings.php @@ -146,6 +146,7 @@ return [ 'name' => SettingsEnum::MAIL_SERVER_PASS, 'content' => '', 'module' => 'Admin', + 'encrypted' => true, ], [ 'type' => 'setting', @@ -158,12 +159,14 @@ return [ 'name' => SettingsEnum::MAIL_SERVER_KEY, 'content' => '', 'module' => 'Admin', + 'encrypted' => true, ], [ 'type' => 'setting', 'name' => SettingsEnum::MAIL_SERVER_KEYPASS, 'content' => '', 'module' => 'Admin', + 'encrypted' => true, ], [ 'type' => 'setting', diff --git a/Admin/Installer.php b/Admin/Installer.php index 8f8221f..71559bf 100755 --- a/Admin/Installer.php +++ b/Admin/Installer.php @@ -304,6 +304,7 @@ final class Installer extends InstallerAbstract $request->setData('module', $data['module'] ?? null); $request->setData('group', $data['group'] ?? null); $request->setData('account', $data['account'] ?? null); + $request->setData('encrypted', $data['encrypted'] ?? false); $module->apiSettingsCreate($request, $response); diff --git a/Admin/Settings/Theme/Backend/settings.tpl.php b/Admin/Settings/Theme/Backend/settings.tpl.php index 24c719e..aad9d8f 100755 --- a/Admin/Settings/Theme/Backend/settings.tpl.php +++ b/Admin/Settings/Theme/Backend/settings.tpl.php @@ -64,7 +64,7 @@ echo $this->getData('nav')->render(); @@ -790,14 +790,14 @@ echo $this->getData('nav')->render(); getId() . '&ptype=p'; - $nextSettings = empty($settings) ? 'admin/settings/general' : 'admin/settings/general?{?}&sid=' . \end($settings)->getId() . '&ptype=n'; + $previousSettings = empty($settings) ? 'admin/settings/general' : 'admin/settings/general?{?}&sid=' . \reset($settings)->id . '&ptype=p'; + $nextSettings = empty($settings) ? 'admin/settings/general' : 'admin/settings/general?{?}&sid=' . \end($settings)->id . '&ptype=n'; foreach ($settings as $key => $setting) : ++$count; ?> - getId(); ?> + id; ?> name; diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 057ca18..9693878 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -36,7 +36,6 @@ use Modules\Admin\Models\Module; use Modules\Admin\Models\ModuleMapper; use Modules\Admin\Models\ModuleStatusUpdateType; use Modules\Admin\Models\NullAccount; -use Modules\Admin\Models\NullDataChange; use Modules\Admin\Models\PermissionCategory; use Modules\Admin\Models\SettingsEnum; use Modules\Media\Models\Collection; @@ -71,6 +70,7 @@ use phpOMS\Model\Message\FormValidation; use phpOMS\Model\Message\Reload; use phpOMS\Module\ModuleInfo; use phpOMS\Module\ModuleStatus; +use phpOMS\Security\EncryptionHelper; use phpOMS\System\File\Local\File; use phpOMS\System\MimeType; use phpOMS\System\OperatingSystem; @@ -238,7 +238,9 @@ final class ApiController extends Controller $handler->host = $emailSettings[SettingsEnum::MAIL_SERVER_OUT]->content ?? 'localhost'; $handler->hostname = $emailSettings[SettingsEnum::MAIL_SERVER_OUT]->content ?? ''; $handler->username = $emailSettings[SettingsEnum::MAIL_SERVER_USER]->content ?? ''; - $handler->password = $emailSettings[SettingsEnum::MAIL_SERVER_PASS]->content ?? ''; + $handler->password = $emailSettings[SettingsEnum::MAIL_SERVER_PASS]->isEncrypted && !empty($_SERVER['OMS_PRIVATE_KEY_I'] ?? '') + ? EncryptionHelper::decryptShared($emailSettings[SettingsEnum::MAIL_SERVER_PASS]->content ?? '', $_SERVER['OMS_PRIVATE_KEY_I']) + : $emailSettings[SettingsEnum::MAIL_SERVER_PASS]->content ?? ''; return $handler; } @@ -267,7 +269,7 @@ final class ApiController extends Controller $forgotten = $this->app->appSettings->get( names: [SettingsEnum::LOGIN_FORGOTTEN_DATE, SettingsEnum::LOGIN_FORGOTTEN_COUNT], module: 'Admin', - account: $account->getId() + account: $account->id ); $emailSettings = $this->app->appSettings->get( @@ -287,7 +289,7 @@ final class ApiController extends Controller $token = (string) \random_bytes(64); $handler = $this->setUpServerMailHandler(); - $resetLink = UriFactory::build('{/base}/reset?user=' . $account->getId() . '&token=' . $token); + $resetLink = UriFactory::build('{/base}/reset?user=' . $account->id . '&token=' . $token); $mail = new Email(); $mail->setFrom($emailSettings->content); @@ -300,19 +302,19 @@ final class ApiController extends Controller [ 'name' => SettingsEnum::LOGIN_FORGOTTEN_DATE, 'module' => self::NAME, - 'account' => $account->getId(), + 'account' => $account->id, 'content' => (string) \time(), ], [ 'name' => SettingsEnum::LOGIN_FORGOTTEN_COUNT, 'module' => self::NAME, - 'account' => $account->getId(), + 'account' => $account->id, 'content' => (string) (((int) $forgotten[SettingsEnum::LOGIN_FORGOTTEN_COUNT]->content) + 1), ], [ 'name' => SettingsEnum::LOGIN_FORGOTTEN_TOKEN, 'module' => self::NAME, - 'account' => $account->getId(), + 'account' => $account->id, 'content' => $token, ], ], true); @@ -415,13 +417,13 @@ final class ApiController extends Controller [ 'name' => SettingsEnum::LOGIN_FORGOTTEN_COUNT, 'module' => self::NAME, - 'account' => $account->getId(), + 'account' => $account->id, 'content' => '0', ], [ 'name' => SettingsEnum::LOGIN_FORGOTTEN_TOKEN, 'module' => self::NAME, - 'account' => $account->getId(), + 'account' => $account->id, 'content' => '', ], ], true); @@ -537,31 +539,59 @@ final class ApiController extends Controller $unit = $data['unit'] ?? null; $app = $data['app'] ?? null; $module = $data['module'] ?? null; + $pattern = $data['pattern'] ?? ''; + $encrypted = $data['encrypted'] ?? null; $group = isset($data['group']) ? (int) $data['group'] : null; $account = isset($data['account']) ? (int) $data['account'] : null; /** @var \Model\Setting $old */ $old = $this->app->appSettings->get($id, $name, $unit, $app, $module, $group, $account); + if ($old->id === 0) { + $internalResponse = new HttpResponse(); + $internalRequest = new HttpRequest($request->uri); + + $internalRequest->header->account = $request->header->account; + $internalRequest->setData('id', $id); + $internalRequest->setData('name', $name); + $internalRequest->setData('content', $content); + $internalRequest->setData('pattern', $pattern); + $internalRequest->setData('unit', $unit); + $internalRequest->setData('app', $app); + $internalRequest->setData('module', $module); + $internalRequest->setData('group', $group); + $internalRequest->setData('account', $account); + $internalRequest->setData('encrypted', $encrypted); + + $this->apiSettingsCreate($internalRequest, $internalResponse, $data); + + continue; + } + $new = clone $old; $new->name = $name ?? $new->name; - $new->content = $content ?? $new->content; + $new->isEncrypted = $encrypted ?? $new->isEncrypted; + $new->content = $new->isEncrypted && !empty($content) && !empty($_SERVER['OMS_PRIVATE_KEY_I'] ?? '') + ? EncryptionHelper::encryptShared($content, $_SERVER['OMS_PRIVATE_KEY_I']) + : $content ?? $new->content; $new->unit = $unit ?? $new->unit; $new->app = $app ?? $new->app; $new->module = $module ?? $new->module; $new->group = $group ?? $new->group; $new->account = $account ?? $new->account; + // @todo: this function call seems stupid, it should just pass the $new object. $this->app->appSettings->set([ [ - 'id' => $new->getId(), + 'id' => $new->id, 'name' => $new->name, 'content' => $new->content, 'unit' => $new->unit, 'app' => $new->app, 'module' => $new->module, 'group' => $new->group, - 'account' => $new->account + 'account' => $new->account, + 'isEncrypted' => $new->isEncrypted, ] ], false); @@ -652,7 +682,8 @@ final class ApiController extends Controller app: $request->getDataInt('app'), module: $request->getDataString('module'), group: $request->getDataInt('group'), - account: $request->getDataInt('account') + account: $request->getDataInt('account'), + isEncrypted: $request->getDataBool('encrypted') ?? false ); return $setting; @@ -1009,8 +1040,8 @@ final class ApiController extends Controller private function createDefaultAppSettings(App $app, RequestAbstract $request) : void { $settings = []; - $settings[] = new Setting(0, SettingsEnum::REGISTRATION_ALLOWED, '0', '\\d+', app: $app->getId(), module: 'Admin'); - $settings[] = new Setting(0, SettingsEnum::APP_DEFAULT_GROUPS, '[]', app: $app->getId(), module: 'Admin'); + $settings[] = new Setting(0, SettingsEnum::REGISTRATION_ALLOWED, '0', '\\d+', app: $app->id, module: 'Admin'); + $settings[] = new Setting(0, SettingsEnum::APP_DEFAULT_GROUPS, '[]', app: $app->id, module: 'Admin'); foreach ($settings as $setting) { $this->createModel($request->header->account, $setting, SettingMapper::class, 'setting', $request->getOrigin()); @@ -1511,7 +1542,7 @@ final class ApiController extends Controller $this->createProfileForAccount($account, $request); } - $collection = $this->createMediaDirForAccount($account->getId(), $account->login ?? '', $request->header->account); + $collection = $this->createMediaDirForAccount($account->id, $account->login ?? '', $request->header->account); $this->createModel($request->header->account, $collection, CollectionMapper::class, 'collection', $request->getOrigin()); // find default groups and create them @@ -1545,8 +1576,8 @@ final class ApiController extends Controller if (!empty($defaultGroupIds)) { $this->createModelRelation( - $account->getId(), - $account->getId(), + $account->id, + $account->id, $defaultGroupIds, AccountMapper::class, 'groups', @@ -1562,7 +1593,7 @@ final class ApiController extends Controller $this->app->l11nManager->getText($response->getLanguage(), 'Admin', 'Api', 'AccountCreateTitle'), \str_replace( '{url}', - UriFactory::build('{/base}/admin/account/settings?{?}&id=' . $account->getId()), + UriFactory::build('{/base}/admin/account/settings?{?}&id=' . $account->id), $this->app->l11nManager->getText($response->getLanguage(), 'Admin', 'Api', 'AccountCreateMsg' )), $account @@ -1668,7 +1699,7 @@ final class ApiController extends Controller $account = null; // email already in use - if (!($emailAccount instanceof NullAccount) + if ($emailAccount->id > 0 && $emailAccount->login !== null && AccountMapper::login($emailAccount->login, (string) $request->getData('password')) !== LoginReturnType::OK ) { @@ -1686,13 +1717,13 @@ final class ApiController extends Controller $response->header->status = RequestStatusCode::R_400; return; - } elseif (!($emailAccount instanceof NullAccount)) { + } elseif ($emailAccount->id > 0) { $account = $emailAccount; } // login already in use by different email if ($account === null - && !($loginAccount instanceof NullAccount) + && $loginAccount->id > 0 && $loginAccount->getEmail() !== $request->getData('email') ) { $response->header->status = RequestStatusCode::R_400; @@ -1710,7 +1741,7 @@ final class ApiController extends Controller return; } elseif ($account === null - && !($loginAccount instanceof NullAccount) + && $loginAccount->id > 0 && $loginAccount->login !== null && AccountMapper::login($loginAccount->login, (string) $request->getData('password')) !== LoginReturnType::OK ) { @@ -1722,7 +1753,7 @@ final class ApiController extends Controller /** @var Account $account */ $account = AccountMapper::get() ->with('groups') - ->where('id', $account->getId()) + ->where('id', $account->id) ->execute(); $defaultGroupIds = []; @@ -1788,8 +1819,8 @@ final class ApiController extends Controller if (!empty($defaultGroupIds)) { // Create missing account / group relationships $this->createModelRelation( - $account->getId(), - $account->getId(), + $account->id, + $account->id, $defaultGroupIds, AccountMapper::class, 'groups', @@ -1823,7 +1854,7 @@ final class ApiController extends Controller // Create confirmation pending entry $dataChange = new DataChange(); $dataChange->type = 'account'; - $dataChange->createdBy = $account->getId(); + $dataChange->createdBy = $account->id; $dataChange->data = \json_encode([ 'status' => AccountStatus::ACTIVE @@ -1832,24 +1863,24 @@ final class ApiController extends Controller $tries = 0; do { $dataChange->reHash(); - $this->createModel($account->getId(), $dataChange, DataChangeMapper::class, 'datachange', $request->getOrigin()); + $this->createModel($account->id, $dataChange, DataChangeMapper::class, 'datachange', $request->getOrigin()); ++$tries; - } while ($dataChange->getId() === 0 && $tries < 5); + } while ($dataChange->id === 0 && $tries < 5); } // Create client if ($request->hasData('client')) { $client = $this->app->moduleManager->get('ClientManagement') - ->findClientForAccount($account->getId(), $request->getDataInt('unit')); + ->findClientForAccount($account->id, $request->getDataInt('unit')); if ($client === null) { $internalRequest = new HttpRequest(); $internalResponse = new HttpResponse(); - $internalRequest->header->account = $account->getId(); - $internalRequest->setData('account', $account->getId()); - $internalRequest->setData('number', 100000 + $account->getId()); + $internalRequest->header->account = $account->id; + $internalRequest->setData('account', $account->id); + $internalRequest->setData('number', 100000 + $account->id); $internalRequest->setData('address', $request->getDataString('address') ?? ''); $internalRequest->setData('postal', $request->getDataString('postal') ?? ''); $internalRequest->setData('city', $request->getDataString('city') ?? ''); @@ -1871,12 +1902,19 @@ final class ApiController extends Controller /** @var \Modules\Messages\Models\Email $mail */ $mail = EmailMapper::get() + ->with('l11n') ->where('id', (int) $emailSettings[SettingsEnum::LOGIN_MAIL_REGISTRATION_TEMPLATE]) + ->where('l11n/language', $response->getLanguage()) ->execute(); $mail->setFrom($emailSettings[SettingsEnum::MAIL_SERVER_ADDR]->content); $mail->addTo((string) $request->getData('email')); + // @todo: load default l11n if no translation is available + $mailL11n = $mail->getL11nByLanguage($response->getLanguage()); + + $mail->subject = $mailL11n->subject; + // @todo: improve, the /tld link could be api.myurl.com which of course is not the url of the respective app. // Maybe store the uri in the $app model? or store all urls in the config file $mail->body = \str_replace( @@ -1890,7 +1928,7 @@ final class ApiController extends Controller : UriFactory::build('{/tld}/{/lang}/' . \strtolower($app->name) . '/signup/confirmation?hash=' . $dataChange->getHash()), $account->login ], - $mail->body + $mailL11n->body ); $mail->bodyAlt = \str_replace( @@ -1904,7 +1942,7 @@ final class ApiController extends Controller : UriFactory::build('{/tld}/{/lang}/' . \strtolower($app->name) . '/signup/confirmation?hash=' . $dataChange->getHash()), $account->login ], - $mail->bodyAlt + $mailL11n->bodyAlt ); $handler->send($mail); @@ -1968,7 +2006,7 @@ final class ApiController extends Controller /** @var DataChange $dataChange */ $dataChange = DataChangeMapper::get()->where('hash', (string) $request->getData('hash'))->execute(); - if ($dataChange instanceof NullDataChange) { + if ($dataChange->id === 0) { $response->header->status = RequestStatusCode::R_400; return; @@ -3062,53 +3100,6 @@ final class ApiController extends Controller { } - /** - * Api method to forward an event to the cli app - * - * @param mixed ...$data Generic data - * - * @return void - * - * @api - * - * @since 1.0.0 - */ - public function cliEventCall(mixed ...$data) : void - { - /** @var \Model\Setting $setting */ - $setting = $this->app->appSettings->get(null, SettingsEnum::CLI_ACTIVE); - $cliEventHandling = (bool) ($setting->content ?? false); - - if ($cliEventHandling) { - $count = \count($data); - - /** @var string $cliPath */ - $cliPath = \realpath(__DIR__ . '/../../../cli.php'); - if ($cliPath === false) { - return; - } - - $jsonData = \json_encode($data); - if ($jsonData === false) { - $jsonData = '{}'; - } - - SystemUtils::runProc( - OperatingSystem::getSystem() === SystemType::WIN ? 'php.exe' : 'php', - \escapeshellarg($cliPath) - . ' /admin/event ' - . '-g ' . \escapeshellarg($data[$count - 2] ?? '') . ' ' - . '-i ' . \escapeshellarg($data[$count - 1] ?? '') . ' ' - . '-d ' . \escapeshellarg($jsonData), - true - ); - } else { - if ($this->app->moduleManager->isActive('Workflow')) { - $this->app->moduleManager->get('Workflow')->runWorkflowFromHook($data); - } - } - } - /** * Routing end-point for application behaviour. * @@ -3138,7 +3129,7 @@ final class ApiController extends Controller $this->createModelRelation( $request->header->account, (int) $request->getData('account'), - $contact->getId(), + $contact->id, AccountMapper::class, 'contacts', '', $request->getOrigin() ); diff --git a/Controller/BackendController.php b/Controller/BackendController.php index c86dd8e..6661f6f 100755 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -14,7 +14,6 @@ declare(strict_types=1); namespace Modules\Admin\Controller; -use Model\NullSetting; use Model\SettingMapper; use Modules\Admin\Models\AccountMapper; use Modules\Admin\Models\AccountPermissionMapper; @@ -28,7 +27,6 @@ use phpOMS\Asset\AssetType; use phpOMS\Autoloader; use phpOMS\Contract\RenderableInterface; use phpOMS\DataStorage\Database\Query\OrderType; -use phpOMS\Localization\NullLocalization; use phpOMS\Message\RequestAbstract; use phpOMS\Message\ResponseAbstract; use phpOMS\Utils\Parser\Markdown\Markdown; @@ -207,7 +205,7 @@ final class BackendController extends Controller /** @var \Modules\Admin\Models\Account $account */ $account = AccountMapper::get()->with('groups')->with('l11n')->where('id', (int) $request->getData('id'))->execute(); - if ($account->l11n instanceof NullLocalization) { + if ($account->l11n->id === 0) { $account->l11n->loadFromLanguage($request->getLanguage()); } @@ -700,7 +698,7 @@ final class BackendController extends Controller /** @var null|\Model\NullSetting|\Model\Setting[] $settings */ $settings = SettingMapper::getAll()->where('module', $id)->execute(); - if (!($settings instanceof NullSetting)) { + if ($settings->id > 0) { $view->setData('settings', !\is_array($settings) ? [$settings] : $settings); } diff --git a/Models/Account.php b/Models/Account.php index 63f87b8..f503ce0 100755 --- a/Models/Account.php +++ b/Models/Account.php @@ -64,7 +64,7 @@ class Account extends \phpOMS\Account\Account * @var Location[] * @since 1.0.0 */ - protected array $locations = []; + public array $locations = []; /** * Contact data. @@ -72,57 +72,5 @@ class Account extends \phpOMS\Account\Account * @var Contact[] * @since 1.0.0 */ - protected array $contacts = []; - - /** - * Get account locations. - * - * @return Location[] - * - * @since 1.0.0 - */ - public function getLocations() : array - { - return $this->locations; - } - - /** - * Add location. - * - * @param Location $location Location - * - * @return void - * - * @since 1.0.0 - */ - public function addLocation(Location $location) : void - { - $this->locations[] = $location; - } - - /** - * Get account contact element. - * - * @return Contact[] - * - * @since 1.0.0 - */ - public function getContacts() : array - { - return $this->contacts; - } - - /** - * Add contact element. - * - * @param Contact $contact Contact Element - * - * @return void - * - * @since 1.0.0 - */ - public function addContact(Contact $contact) : void - { - $this->contacts[] = $contact; - } + public array $contacts = []; } diff --git a/Models/AccountExternal.php b/Models/AccountExternal.php index 8b31ae6..aaace80 100755 --- a/Models/AccountExternal.php +++ b/Models/AccountExternal.php @@ -30,7 +30,7 @@ class AccountExternal * @var int * @since 1.0.0 */ - protected int $id = 0; + public int $id = 0; /** * External type. @@ -38,7 +38,7 @@ class AccountExternal * @var int * @since 1.0.0 */ - private int $type = AccountExternalType::PAYMENT; + public int $type = AccountExternalType::PAYMENT; /** * External subtype. @@ -54,7 +54,7 @@ class AccountExternal * @var int * @since 1.0.0 */ - private int $status = AccountExternalStatus::ACTIVATE; + public int $status = AccountExternalStatus::ACTIVATE; /** * External key diff --git a/Models/AccountMapper.php b/Models/AccountMapper.php index 5707d4c..a10002d 100755 --- a/Models/AccountMapper.php +++ b/Models/AccountMapper.php @@ -73,6 +73,12 @@ class AccountMapper extends DataMapperFactory * @since 1.0.0 */ public const HAS_MANY = [ + 'permissions' => [ + 'mapper' => AccountPermissionMapper::class, + 'table' => 'account_permission', + 'external' => null, + 'self' => 'account_permission_account', + ], 'groups' => [ 'mapper' => GroupMapper::class, 'table' => 'account_group', @@ -142,38 +148,20 @@ class AccountMapper extends DataMapperFactory */ public static function getWithPermissions(int $id) : Account { + if ($id < 1) { + return new NullAccount(); + } + /** @var \Modules\Admin\Models\Account $account */ $account = self::get() ->with('groups') ->with('groups/permissions') + ->with('permissions') ->with('l11n') ->where('id', $id) + ->where('permission/element', null) ->execute(); - $groups = \array_keys($account->getGroups()); - - /** @var \Modules\Admin\Models\GroupPermission[] $groupPermissions */ - $groupPermissions = empty($groups) - ? [] - : GroupPermissionMapper::getAll() - ->where('group', \array_keys($account->getGroups()), 'in') - ->where('element', null) - ->execute(); - - foreach ($groupPermissions as $permission) { - $account->addPermission($permission); - } - - /** @var \Modules\Admin\Models\AccountPermission[] $accountPermissions */ - $accountPermissions = AccountPermissionMapper::getAll() - ->where('account', $id) - ->where('element', null) - ->execute(); - - foreach ($accountPermissions as $permission) { - $account->addPermission($permission); - } - return $account; } diff --git a/Models/AccountPermission.php b/Models/AccountPermission.php index 4312725..649f4b7 100755 --- a/Models/AccountPermission.php +++ b/Models/AccountPermission.php @@ -35,7 +35,7 @@ class AccountPermission extends PermissionAbstract * @var int * @since 1.0.0 */ - private int $account = 0; + public int $account = 0; /** * Constructor. diff --git a/Models/ApiKey.php b/Models/ApiKey.php index 50e99aa..6da5f3c 100755 --- a/Models/ApiKey.php +++ b/Models/ApiKey.php @@ -32,7 +32,7 @@ class ApiKey * @var int * @since 1.0.0 */ - protected int $id = 0; + public int $id = 0; /** * Names. @@ -48,7 +48,7 @@ class ApiKey * @var int * @since 1.0.0 */ - protected int $status = AccountStatus::INACTIVE; + public int $status = AccountStatus::INACTIVE; /** * Creator. diff --git a/Models/App.php b/Models/App.php index e36780a..334c8e2 100755 --- a/Models/App.php +++ b/Models/App.php @@ -33,7 +33,7 @@ class App implements \JsonSerializable * @var int * @since 1.0.0 */ - protected int $id = 0; + public int $id = 0; /** * Name diff --git a/Models/Contact.php b/Models/Contact.php index a8c1d23..d0b8522 100755 --- a/Models/Contact.php +++ b/Models/Contact.php @@ -32,7 +32,7 @@ class Contact * @var int * @since 1.0.0 */ - protected int $id = 0; + public int $id = 0; /** * Contact element type. @@ -40,7 +40,7 @@ class Contact * @var int * @since 1.0.0 */ - private int $type = ContactType::EMAIL; + public int $type = ContactType::EMAIL; /** * Contact element subtype. diff --git a/Models/DataChange.php b/Models/DataChange.php index f5785f1..d34f0c9 100755 --- a/Models/DataChange.php +++ b/Models/DataChange.php @@ -30,7 +30,7 @@ class DataChange * @var int * @since 1.0.0 */ - protected int $id = 0; + public int $id = 0; /** * Hash diff --git a/Models/Group.php b/Models/Group.php index a318d7c..b108842 100755 --- a/Models/Group.php +++ b/Models/Group.php @@ -54,7 +54,7 @@ class Group extends \phpOMS\Account\Group * @var Account[] * @since 1.0.0 */ - protected array $accounts = []; + public array $accounts = []; /** * Constructor diff --git a/Models/GroupPermission.php b/Models/GroupPermission.php index 2b5ebe2..c31c76b 100755 --- a/Models/GroupPermission.php +++ b/Models/GroupPermission.php @@ -35,7 +35,7 @@ class GroupPermission extends PermissionAbstract * @var int * @since 1.0.0 */ - private int $group = 0; + public int $group = 0; /** * Constructor. diff --git a/Models/Module.php b/Models/Module.php index 08a2390..27f8a07 100755 --- a/Models/Module.php +++ b/Models/Module.php @@ -73,7 +73,7 @@ class Module * @var int * @since 1.0.0 */ - protected int $status = ModuleStatus::INACTIVE; + public int $status = ModuleStatus::INACTIVE; /** * Created at. diff --git a/Models/PermissionQueryBuilder.php b/Models/PermissionQueryBuilder.php index ff4aec5..3651057 100755 --- a/Models/PermissionQueryBuilder.php +++ b/Models/PermissionQueryBuilder.php @@ -50,7 +50,7 @@ final class PermissionQueryBuilder * * @var int */ - private int $account = 0; + public int $account = 0; /** * Unit ids. diff --git a/Models/SettingsEnum.php b/Models/SettingsEnum.php index c84a7fe..b553d94 100755 --- a/Models/SettingsEnum.php +++ b/Models/SettingsEnum.php @@ -25,8 +25,7 @@ use phpOMS\Stdlib\Base\Enum; * @since 1.0.0 */ abstract class SettingsEnum extends Enum -{ - /* Logging settings */ +{ /* Logging settings */ public const PASSWORD_PATTERN = '1000000001'; public const LOGIN_TIMEOUT = '1000000002'; diff --git a/Theme/Backend/Components/GroupTagSelector/GroupTagSelectorView.php b/Theme/Backend/Components/GroupTagSelector/GroupTagSelectorView.php index 0c47292..3a3eb22 100755 --- a/Theme/Backend/Components/GroupTagSelector/GroupTagSelectorView.php +++ b/Theme/Backend/Components/GroupTagSelector/GroupTagSelectorView.php @@ -44,7 +44,7 @@ class GroupTagSelectorView extends View * @var bool * @since 1.0.0 */ - private bool $isRequired = false; + public bool $isRequired = false; /** * {@inheritdoc} diff --git a/Theme/Backend/Components/GroupTagSelector/group-selector.tpl.php b/Theme/Backend/Components/GroupTagSelector/group-selector.tpl.php index 0bbfe7b..0c29b94 100755 --- a/Theme/Backend/Components/GroupTagSelector/group-selector.tpl.php +++ b/Theme/Backend/Components/GroupTagSelector/group-selector.tpl.php @@ -2,10 +2,10 @@
- - getId(); ?>", "delay": 500, "resets": true}, - {"key": 3, "type": "dom.datalist.clear", "id": "getId(); ?>-datalist"}, - {"key": 4, "type": "message.request", "uri": "{/base}/{/lang}/api/admin/find/group?search={!#getId(); ?>}", "method": "GET", "request_type": "json"}, - {"key": 5, "type": "dom.datalist.append", "id": "getId(); ?>-datalist", "value": "id", "text": "name"} + {"key": 2, "type": "utils.timer", "id": "id; ?>", "delay": 500, "resets": true}, + {"key": 3, "type": "dom.datalist.clear", "id": "id; ?>-datalist"}, + {"key": 4, "type": "message.request", "uri": "{/base}/{/lang}/api/admin/find/group?search={!#id; ?>}", "method": "GET", "request_type": "json"}, + {"key": 5, "type": "dom.datalist.append", "id": "id; ?>-datalist", "value": "id", "text": "name"} ] }, { "key": 2, "listener": "keydown", "action" : [ {"key": 1, "type": "validate.keypress", "pressed": "13|9"}, - {"key": 2, "type": "message.request", "uri": "{/base}/{/lang}/api/admin/find/group?search={!#getId(); ?>}", "method": "GET", "request_type": "json"}, - {"key": 3, "type": "dom.setvalue", "overwrite": true, "selector": "#getId(); ?>-idlist", "value": "{0/id}", "data": ""}, - {"key": 4, "type": "dom.setvalue", "overwrite": true, "selector": "#getId(); ?>-taglist", "value": "getId(); ?>-taglist-{0/id}\" class=\"tag red\" data-id=\"{0/id}\"> {0/name}", "data": ""}, - {"key": 5, "type": "dom.setvalue", "overwrite": true, "selector": "#getId(); ?>", "value": "", "data": ""} + {"key": 2, "type": "message.request", "uri": "{/base}/{/lang}/api/admin/find/group?search={!#id; ?>}", "method": "GET", "request_type": "json"}, + {"key": 3, "type": "dom.setvalue", "overwrite": true, "selector": "#id; ?>-idlist", "value": "{0/id}", "data": ""}, + {"key": 4, "type": "dom.setvalue", "overwrite": true, "selector": "#id; ?>-taglist", "value": "id; ?>-taglist-{0/id}\" class=\"tag red\" data-id=\"{0/id}\"> {0/name}", "data": ""}, + {"key": 5, "type": "dom.setvalue", "overwrite": true, "selector": "#id; ?>", "value": "", "data": ""} ] } ]'> - - isRequired() ? ' required' : ''; ?>> + + isRequired() ? ' required' : ''; ?>>
-
getId(); ?>-taglist span fa", "action": [ + "key": 1, "listener": "click", "selector": "#id; ?>-taglist span fa", "action": [ {"key": 1, "type": "dom.getvalue", "base": "self"}, - {"key": 2, "type": "dom.removevalue", "selector": "#getId(); ?>-idlist", "data": ""}, + {"key": 2, "type": "dom.removevalue", "selector": "#id; ?>-idlist", "data": ""}, {"key": 3, "type": "dom.remove", "base": "self"} ] } diff --git a/Theme/Backend/accounts-list.tpl.php b/Theme/Backend/accounts-list.tpl.php index d1acd8a..41a0489 100755 --- a/Theme/Backend/accounts-list.tpl.php +++ b/Theme/Backend/accounts-list.tpl.php @@ -86,7 +86,7 @@ echo $this->getData('nav')->render(); ?> $value) : ++$c; - $url = UriFactory::build('{/base}/admin/account/settings?{?}&id=' . $value->getId()); + $url = UriFactory::build('{/base}/admin/account/settings?{?}&id=' . $value->id); $color = 'darkred'; if ($value->getStatus() === AccountStatus::ACTIVE) { $color = 'green'; } @@ -95,7 +95,7 @@ echo $this->getData('nav')->render(); ?> elseif ($value->getStatus() === AccountStatus::BANNED) { $color = 'red'; } ?> - getId(); ?> + id; ?> getHtml('Status'. $value->getStatus()); ?> printHtml($this->renderUserName('%3$s %2$s %1$s', [$value->name1, $value->name2, $value->name3, $value->login])); ?> printHtml($value->getLastActive()->format('Y-m-d H:i:s')); ?> diff --git a/Theme/Backend/accounts-single.tpl.php b/Theme/Backend/accounts-single.tpl.php index 7ec6f22..4e2826a 100755 --- a/Theme/Backend/accounts-single.tpl.php +++ b/Theme/Backend/accounts-single.tpl.php @@ -42,10 +42,10 @@ $l11n = $account->l11n; $previous = empty($audits) ? HttpHeader::getAllHeaders()['Referer'] ?? 'admin/account/settings?id={?id}#{\#}' - : 'admin/account/settings?{?}&audit=' . \reset($audits)->getId() . '&ptype=p#{\#}'; + : 'admin/account/settings?{?}&audit=' . \reset($audits)->id . '&ptype=p#{\#}'; $next = empty($audits) ? HttpHeader::getAllHeaders()['Referer'] ?? 'admin/account/settings?id={?id}#{\#}' - : 'admin/account/settings?{?}&audit=' . \end($audits)->getId() . '&ptype=n#{\#}'; + : 'admin/account/settings?{?}&audit=' . \end($audits)->id . '&ptype=n#{\#}'; echo $this->getData('nav')->render(); ?> @@ -70,7 +70,7 @@ echo $this->getData('nav')->render(); ?>
- +
@@ -169,7 +169,7 @@ echo $this->getData('nav')->render(); ?>
- +
@@ -190,11 +190,11 @@ echo $this->getData('nav')->render(); ?> $c = 0; $groups = $account->getGroups(); foreach ($groups as $key => $value) : ++$c; - $url = UriFactory::build('{/base}/admin/group/settings?{?}&id=' . $value->getId()); + $url = UriFactory::build('{/base}/admin/group/settings?{?}&id=' . $value->id); ?> - getId(); ?> + id; ?> printHtml($value->name); ?> @@ -282,7 +282,7 @@ echo $this->getData('nav')->render(); ?>
- +
@@ -317,7 +317,7 @@ echo $this->getData('nav')->render(); ?> - getId(); ?> + id; ?> getUnit(); ?> getApp(); ?> getModule(); ?> @@ -404,7 +404,7 @@ echo $this->getData('nav')->render(); ?>
- +
@@ -827,10 +827,10 @@ echo $this->getData('nav')->render(); ?> $audit) : ++$count; - $url = UriFactory::build('{/base}/admin/audit/single?{?}&id=' . $audit->getId()); + $url = UriFactory::build('{/base}/admin/audit/single?{?}&id=' . $audit->id); ?> - getId(); ?> + id; ?> printHtml($audit->module); ?> type; ?> printHtml($audit->trigger); ?> diff --git a/Theme/Backend/groups-list.tpl.php b/Theme/Backend/groups-list.tpl.php index 0f9b297..0452785 100755 --- a/Theme/Backend/groups-list.tpl.php +++ b/Theme/Backend/groups-list.tpl.php @@ -85,7 +85,7 @@ echo $this->getData('nav')->render(); ?> $value) : ++$c; - $url = UriFactory::build('{/base}/admin/group/settings?{?}&id=' . $value->getId()); + $url = UriFactory::build('{/base}/admin/group/settings?{?}&id=' . $value->id); $color = 'darkred'; if ($value->getStatus() === GroupStatus::ACTIVE) { $color = 'green'; } @@ -93,10 +93,10 @@ echo $this->getData('nav')->render(); ?> elseif ($value->getStatus() === GroupStatus::HIDDEN) { $color = 'purple'; } ?> - getId(); ?> + id; ?> getHtml('Status'. $value->getStatus()); ?> printHtml($value->name); ?> - getId()] ?? 0; ?> + id] ?? 0; ?> getHtml('Empty', '0', '0'); ?> diff --git a/Theme/Backend/groups-single.tpl.php b/Theme/Backend/groups-single.tpl.php index 0d12fa3..5e9b7ac 100755 --- a/Theme/Backend/groups-single.tpl.php +++ b/Theme/Backend/groups-single.tpl.php @@ -28,10 +28,10 @@ $audits = $this->getData('auditlogs') ?? []; $previous = empty($audits) ? HttpHeader::getAllHeaders()['Referer'] ?? 'admin/group/settings?id={?id}#{\#}' - : 'admin/group/settings?{?}&audit=' . \reset($audits)->getId() . '&ptype=p#{\#}'; + : 'admin/group/settings?{?}&audit=' . \reset($audits)->id . '&ptype=p#{\#}'; $next = empty($audits) ? HttpHeader::getAllHeaders()['Referer'] ?? 'admin/group/settings?id={?id}#{\#}' - : 'admin/group/settings?{?}&audit=' . \end($audits)->getId() . '&ptype=n#{\#}'; + : 'admin/group/settings?{?}&audit=' . \end($audits)->id . '&ptype=n#{\#}'; echo $this->getData('nav')->render(); ?> @@ -55,7 +55,7 @@ echo $this->getData('nav')->render(); ?>
- +
@@ -118,7 +118,7 @@ echo $this->getData('nav')->render(); ?> getHtml('ID', '0', '0'); ?> getHtml('Name'); ?> - $value) : ++$c; $url = UriFactory::build('{/base}/admin/account/settings?{?}&id=' . $value->getId()); ?> + $value) : ++$c; $url = UriFactory::build('{/base}/admin/account/settings?{?}&id=' . $value->id); ?> name1; ?> name2; ?> @@ -209,7 +209,7 @@ echo $this->getData('nav')->render(); ?>
- + @@ -268,7 +268,7 @@ echo $this->getData('nav')->render(); ?> - getId(); ?> + id; ?> getUnit(); ?> getApp(); ?> getModule(); ?> @@ -320,11 +320,11 @@ echo $this->getData('nav')->render(); ?> getHtml('Date', 'Auditor'); ?> $audit) : ++$count; - $url = UriFactory::build('{/base}/admin/audit/single?{?}&id=' . $audit->getId()); ?> + $url = UriFactory::build('{/base}/admin/audit/single?{?}&id=' . $audit->id); ?> - getId(); ?> + id; ?> printHtml($audit->module); ?> - getType(); ?> + type; ?> printHtml($audit->trigger); ?> printHtml($audit->createdBy->login); ?> printHtml($audit->ref); ?> diff --git a/Theme/Backend/modules-list.tpl.php b/Theme/Backend/modules-list.tpl.php index f55d8fe..ada4643 100755 --- a/Theme/Backend/modules-list.tpl.php +++ b/Theme/Backend/modules-list.tpl.php @@ -86,7 +86,7 @@ $tableView->setObjects($modules); } ?> - getId(); ?> + id; ?> printHtml($module->getExternalName()); ?> printHtml($module->getVersion()); ?> diff --git a/Theme/Backend/modules-log.tpl.php b/Theme/Backend/modules-log.tpl.php index fbdcd4f..4de40ab 100755 --- a/Theme/Backend/modules-log.tpl.php +++ b/Theme/Backend/modules-log.tpl.php @@ -20,8 +20,8 @@ use phpOMS\Uri\UriFactory; */ $audits = $this->getData('auditlogs') ?? []; -$previous = empty($audits) ? HttpHeader::getAllHeaders()['Referer'] ?? 'admin/module/settings?id={?id}#{\#}' : 'admin/module/settings?{?}&audit=' . \reset($audits)->getId() . '&ptype=p#{\#}'; -$next = empty($audits) ? HttpHeader::getAllHeaders()['Referer'] ?? 'admin/module/settings?id={?id}#{\#}' : 'admin/module/settings?{?}&audit=' . \end($audits)->getId() . '&ptype=n#{\#}'; +$previous = empty($audits) ? HttpHeader::getAllHeaders()['Referer'] ?? 'admin/module/settings?id={?id}#{\#}' : 'admin/module/settings?{?}&audit=' . \reset($audits)->id . '&ptype=p#{\#}'; +$next = empty($audits) ? HttpHeader::getAllHeaders()['Referer'] ?? 'admin/module/settings?id={?id}#{\#}' : 'admin/module/settings?{?}&audit=' . \end($audits)->id . '&ptype=n#{\#}'; echo $this->getData('nav')->render(); ?> @@ -54,9 +54,9 @@ echo $this->getData('nav')->render(); getHtml('Date', 'Auditor'); ?> $audit) : ++$count; - $url = UriFactory::build('{/base}/admin/audit/single?{?}&id=' . $audit->getId()); ?> + $url = UriFactory::build('{/base}/admin/audit/single?{?}&id=' . $audit->id); ?> - getId(); ?> + id; ?> printHtml($audit->module); ?> type; ?> printHtml($audit->trigger); ?> diff --git a/Theme/Backend/modules-settings.tpl.php b/Theme/Backend/modules-settings.tpl.php index 486446c..898219b 100755 --- a/Theme/Backend/modules-settings.tpl.php +++ b/Theme/Backend/modules-settings.tpl.php @@ -112,7 +112,7 @@ else : ?> ?> - getId(); ?> + id; ?> name; diff --git a/Theme/Backend/page-list.tpl.php b/Theme/Backend/page-list.tpl.php index ac831e9..fb19380 100755 --- a/Theme/Backend/page-list.tpl.php +++ b/Theme/Backend/page-list.tpl.php @@ -21,8 +21,8 @@ use phpOMS\Uri\UriFactory; */ $pages = $this->getData('pages') ?? []; -$previous = empty($pages) ? 'admin/page/list' : '{/base}/admin/page/list?{?}&id=' . \reset($pages)->getId() . '&ptype=p'; -$next = empty($pages) ? 'admin/page/list' : '{/base}/admin/page/list?{?}&id=' . \end($pages)->getId() . '&ptype=n'; +$previous = empty($pages) ? 'admin/page/list' : '{/base}/admin/page/list?{?}&id=' . \reset($pages)->id . '&ptype=p'; +$next = empty($pages) ? 'admin/page/list' : '{/base}/admin/page/list?{?}&id=' . \end($pages)->id . '&ptype=n'; echo $this->getData('nav')->render(); ?> @@ -90,14 +90,14 @@ echo $this->getData('nav')->render(); ?> $value) : ++$c; - $url = UriFactory::build('{/base}/admin/account/settings?{?}&id=' . $value->getId()); + $url = UriFactory::build('{/base}/admin/account/settings?{?}&id=' . $value->id); $color = 'darkred'; if ($value->getStatus() === AccountStatus::ACTIVE) { $color = 'green'; } elseif ($value->getStatus() === AccountStatus::INACTIVE) { $color = 'darkblue'; } elseif ($value->getStatus() === AccountStatus::TIMEOUT) { $color = 'purple'; } elseif ($value->getStatus() === AccountStatus::BANNED) { $color = 'red'; } ?> - getId(); ?> + id; ?> getHtml('Status'. $value->getStatus()); ?> printHtml($this->renderUserName('%3$s %2$s %1$s', [$value->name1, $value->name2, $value->name3, $value->login])); ?> printHtml($value->getLastActive()->format('Y-m-d H:i:s')); ?> diff --git a/Theme/Backend/settings-general.tpl.php b/Theme/Backend/settings-general.tpl.php index 8f7c7af..942f27c 100755 --- a/Theme/Backend/settings-general.tpl.php +++ b/Theme/Backend/settings-general.tpl.php @@ -62,7 +62,7 @@ $l11n = $this->getData('defaultlocalization') ?? new NullLocalization();
@@ -710,14 +710,14 @@ $l11n = $this->getData('defaultlocalization') ?? new NullLocalization(); getId() . '&ptype=p'; - $nextSettings = empty($settings) ? 'admin/settings/general' : 'admin/settings/general?{?}&sid=' . \end($settings)->getId() . '&ptype=n'; + $previousSettings = empty($settings) ? 'admin/settings/general' : 'admin/settings/general?{?}&sid=' . \reset($settings)->id . '&ptype=p'; + $nextSettings = empty($settings) ? 'admin/settings/general' : 'admin/settings/general?{?}&sid=' . \end($settings)->id . '&ptype=n'; foreach ($settings as $key => $setting) : ++$count; ?> - getId(); ?> + id; ?> printHtml($setting->name); ?> printHtml($setting->content); ?> printHtml($setting->module); ?> diff --git a/tests/Controller/Api/ApiControllerAccountTrait.php b/tests/Controller/Api/ApiControllerAccountTrait.php index ff26fbc..1587142 100755 --- a/tests/Controller/Api/ApiControllerAccountTrait.php +++ b/tests/Controller/Api/ApiControllerAccountTrait.php @@ -39,7 +39,7 @@ trait ApiControllerAccountTrait $this->module->apiAccountGet($request, $response); self::assertEquals('admin', $response->get('')['response']->login); - self::assertGreaterThan(0, $response->get('')['response']->getId()); + self::assertGreaterThan(0, $response->get('')['response']->id); } /** @@ -61,7 +61,7 @@ trait ApiControllerAccountTrait $this->module->apiAccountGet($request, $response); self::assertEquals('oms@karaka.de', $response->get('')['response']->getEmail()); - self::assertGreaterThan(0, $response->get('')['response']->getId()); + self::assertGreaterThan(0, $response->get('')['response']->id); } /** @@ -103,7 +103,7 @@ trait ApiControllerAccountTrait $this->module->apiAccountCreate($request, $response); self::assertEquals('guest', $response->get('')['response']->login); - self::assertGreaterThan(0, $response->get('')['response']->getId()); + self::assertGreaterThan(0, $response->get('')['response']->id); } /** @@ -127,7 +127,7 @@ trait ApiControllerAccountTrait $this->module->apiAccountCreate($request, $response); self::assertEquals('guest2', $response->get('')['response']->login); - self::assertGreaterThan(0, $response->get('')['response']->getId()); + self::assertGreaterThan(0, $response->get('')['response']->id); } /** @@ -148,10 +148,10 @@ trait ApiControllerAccountTrait $request->setData('status', AccountStatus::INACTIVE); $this->module->apiAccountCreate($request, $response); - $request->setData('id', $response->get('')['response']->getId()); + $request->setData('id', $response->get('')['response']->id); $this->module->apiAccountDelete($request, $response); - self::assertGreaterThan(0, $response->get('')['response']->getId()); + self::assertGreaterThan(0, $response->get('')['response']->id); } /** diff --git a/tests/Controller/Api/ApiControllerGroupTrait.php b/tests/Controller/Api/ApiControllerGroupTrait.php index 55a6599..a8bda63 100755 --- a/tests/Controller/Api/ApiControllerGroupTrait.php +++ b/tests/Controller/Api/ApiControllerGroupTrait.php @@ -38,7 +38,7 @@ trait ApiControllerGroupTrait $this->module->apiGroupGet($request, $response); self::assertEquals('admin', $response->get('')['response']->name); - self::assertGreaterThan(0, $response->get('')['response']->getId()); + self::assertGreaterThan(0, $response->get('')['response']->id); } /** @@ -100,13 +100,13 @@ trait ApiControllerGroupTrait $this->module->apiGroupCreate($request, $response); self::assertEquals('test', $response->get('')['response']->name); - self::assertGreaterThan(0, $response->get('')['response']->getId()); + self::assertGreaterThan(0, $response->get('')['response']->id); // test delete - $request->setData('id', $response->get('')['response']->getId()); + $request->setData('id', $response->get('')['response']->id); $this->module->apiGroupDelete($request, $response); - self::assertGreaterThan(0, $response->get('')['response']->getId()); + self::assertGreaterThan(0, $response->get('')['response']->id); } /** diff --git a/tests/Controller/Api/ApiControllerPermissionTrait.php b/tests/Controller/Api/ApiControllerPermissionTrait.php index 296bc7e..f439ecd 100755 --- a/tests/Controller/Api/ApiControllerPermissionTrait.php +++ b/tests/Controller/Api/ApiControllerPermissionTrait.php @@ -39,7 +39,7 @@ trait ApiControllerPermissionTrait $this->module->apiAddGroupPermission($request, $response); self::assertEquals('ok', $response->get('')['status']); - self::assertGreaterThan(0, $response->get('')['response']->getId()); + self::assertGreaterThan(0, $response->get('')['response']->id); } /** @@ -75,7 +75,7 @@ trait ApiControllerPermissionTrait $this->module->apiGroupPermissionGet($request, $response); self::assertGreaterThan(0, $response->get('')['response']->getGroup()); - self::assertGreaterThan(0, $response->get('')['response']->getId()); + self::assertGreaterThan(0, $response->get('')['response']->id); } /** @@ -94,13 +94,13 @@ trait ApiControllerPermissionTrait $this->module->apiAddGroupPermission($request, $response); self::assertEquals('ok', $response->get('')['status']); - self::assertGreaterThan(0, $response->get('')['response']->getId()); + self::assertGreaterThan(0, $response->get('')['response']->id); // test delete - $request->setData('id', $response->get('')['response']->getId()); + $request->setData('id', $response->get('')['response']->id); $this->module->apiGroupPermissionDelete($request, $response); - self::assertGreaterThan(0, $response->get('')['response']->getId()); + self::assertGreaterThan(0, $response->get('')['response']->id); } /** @@ -155,7 +155,7 @@ trait ApiControllerPermissionTrait $this->module->apiGroupPermissionUpdate($request, $response); self::assertEquals(PermissionType::READ, $response->get('')['response']->getPermission()); - self::assertGreaterThan(0, $response->get('')['response']->getId()); + self::assertGreaterThan(0, $response->get('')['response']->id); $request->setData('permissioncreate', PermissionType::CREATE); $request->setData('permissionupdate', PermissionType::MODIFY); @@ -181,7 +181,7 @@ trait ApiControllerPermissionTrait $this->module->apiAddAccountPermission($request, $response); self::assertEquals('ok', $response->get('')['status']); - self::assertGreaterThan(0, $response->get('')['response']->getId()); + self::assertGreaterThan(0, $response->get('')['response']->id); } /** @@ -200,7 +200,7 @@ trait ApiControllerPermissionTrait $this->module->apiAccountPermissionGet($request, $response); self::assertEquals(1, $response->get('')['response']->getAccount()); - self::assertGreaterThan(0, $response->get('')['response']->getId()); + self::assertGreaterThan(0, $response->get('')['response']->id); } /** @@ -219,13 +219,13 @@ trait ApiControllerPermissionTrait $this->module->apiAddAccountPermission($request, $response); self::assertEquals('ok', $response->get('')['status']); - self::assertGreaterThan(0, $response->get('')['response']->getId()); + self::assertGreaterThan(0, $response->get('')['response']->id); // test delete - $request->setData('id', $response->get('')['response']->getId()); + $request->setData('id', $response->get('')['response']->id); $this->module->apiAccountPermissionDelete($request, $response); - self::assertGreaterThan(0, $response->get('')['response']->getId()); + self::assertGreaterThan(0, $response->get('')['response']->id); } /** @@ -280,6 +280,6 @@ trait ApiControllerPermissionTrait $this->module->apiAccountPermissionUpdate($request, $response); self::assertEquals(PermissionType::READ, $response->get('')['response']->getPermission()); - self::assertGreaterThan(0, $response->get('')['response']->getId()); + self::assertGreaterThan(0, $response->get('')['response']->id); } } diff --git a/tests/Models/AccountMapperTest.php b/tests/Models/AccountMapperTest.php index 6f12e6d..cdf7dca 100755 --- a/tests/Models/AccountMapperTest.php +++ b/tests/Models/AccountMapperTest.php @@ -47,10 +47,10 @@ final class AccountMapperTest extends \PHPUnit\Framework\TestCase $account->setType(AccountType::USER); $id = AccountMapper::create()->execute($account); - self::assertGreaterThan(0, $account->getId()); - self::assertEquals($id, $account->getId()); + self::assertGreaterThan(0, $account->id); + self::assertEquals($id, $account->id); - $accountR = AccountMapper::get()->where('id', $account->getId())->execute(); + $accountR = AccountMapper::get()->where('id', $account->id)->execute(); self::assertEquals($account->createdAt->format('Y-m-d'), $accountR->createdAt->format('Y-m-d')); self::assertEquals($account->login, $accountR->login); self::assertEquals($account->name1, $accountR->name1); diff --git a/tests/Models/AddressMapperTest.php b/tests/Models/AddressMapperTest.php index 7d88cdd..3aa6cf1 100755 --- a/tests/Models/AddressMapperTest.php +++ b/tests/Models/AddressMapperTest.php @@ -44,10 +44,10 @@ final class AddressMapperTest extends \PHPUnit\Framework\TestCase $address->setGeo(['lat' => 12.1, 'long' => 11.2,]); $id = AddressMapper::create()->execute($address); - self::assertGreaterThan(0, $address->getId()); - self::assertEquals($id, $address->getId()); + self::assertGreaterThan(0, $address->id); + self::assertEquals($id, $address->id); - $addressR = AddressMapper::get()->where('id', $address->getId())->execute(); + $addressR = AddressMapper::get()->where('id', $address->id)->execute(); self::assertEquals($address->name, $addressR->name); self::assertEquals($address->addition, $addressR->addition); self::assertEquals($address->getType(), $addressR->getType()); diff --git a/tests/Models/AppMapperTest.php b/tests/Models/AppMapperTest.php index e3d9a28..2d04dd8 100755 --- a/tests/Models/AppMapperTest.php +++ b/tests/Models/AppMapperTest.php @@ -39,10 +39,10 @@ final class AppMapperTest extends \PHPUnit\Framework\TestCase $app->status = ApplicationStatus::NORMAL; $id = AppMapper::create()->execute($app); - self::assertGreaterThan(0, $app->getId()); - self::assertEquals($id, $app->getId()); + self::assertGreaterThan(0, $app->id); + self::assertEquals($id, $app->id); - $appR = AppMapper::get()->where('id', $app->getId())->execute(); + $appR = AppMapper::get()->where('id', $app->id)->execute(); self::assertEquals($app->name, $appR->name); self::assertEquals($app->theme, $appR->theme); self::assertEquals($app->status, $appR->status); diff --git a/tests/Models/AppTest.php b/tests/Models/AppTest.php index 94a8abe..9d024a2 100755 --- a/tests/Models/AppTest.php +++ b/tests/Models/AppTest.php @@ -31,6 +31,6 @@ final class AppTest extends \PHPUnit\Framework\TestCase public function testDefault() : void { $account = new App(); - self::assertEquals(0, $account->getId()); + self::assertEquals(0, $account->id); } } diff --git a/tests/Models/GroupMapperTest.php b/tests/Models/GroupMapperTest.php index 893be4d..af2af44 100755 --- a/tests/Models/GroupMapperTest.php +++ b/tests/Models/GroupMapperTest.php @@ -42,7 +42,7 @@ final class GroupMapperTest extends \PHPUnit\Framework\TestCase $permissions = GroupMapper::getPermissionForModule('Admin'); foreach ($permissions as $p) { - if ($p->getId() === $groupId) { + if ($p->id === $groupId) { self::assertTrue(true); return; } diff --git a/tests/Models/GroupTest.php b/tests/Models/GroupTest.php index 30c0f3f..e8047b7 100755 --- a/tests/Models/GroupTest.php +++ b/tests/Models/GroupTest.php @@ -42,7 +42,7 @@ final class GroupTest extends \PHPUnit\Framework\TestCase public function testDefault() : void { self::assertEquals((new \DateTime('now'))->format('Y-m-d'), $this->group->createdAt->format('Y-m-d')); - self::assertEquals(0, $this->group->createdBy->getId()); + self::assertEquals(0, $this->group->createdBy->id); self::assertEquals('', $this->group->descriptionRaw); self::assertEquals([], $this->group->getAccounts()); } @@ -66,6 +66,6 @@ final class GroupTest extends \PHPUnit\Framework\TestCase public function testCreatorInputOutput() : void { $this->group->createdBy = new NullAccount(3); - self::assertEquals(3, $this->group->createdBy->getId()); + self::assertEquals(3, $this->group->createdBy->id); } } diff --git a/tests/Models/ModuleTest.php b/tests/Models/ModuleTest.php index 341152a..5e8bf9d 100755 --- a/tests/Models/ModuleTest.php +++ b/tests/Models/ModuleTest.php @@ -41,7 +41,7 @@ final class ModuleTest extends \PHPUnit\Framework\TestCase */ public function testDefault() : void { - self::assertEquals('', $this->module->getId()); + self::assertEquals('', $this->module->id); self::assertInstanceOf('\DateTimeImmutable', $this->module->createdAt); self::assertEquals('', $this->module->name); self::assertEquals(ModuleStatus::INACTIVE, $this->module->getStatus()); diff --git a/tests/Models/NullAccountPermissionTest.php b/tests/Models/NullAccountPermissionTest.php index feca555..1e05ee2 100755 --- a/tests/Models/NullAccountPermissionTest.php +++ b/tests/Models/NullAccountPermissionTest.php @@ -37,6 +37,6 @@ final class NullAccountPermissionTest extends \PHPUnit\Framework\TestCase public function testId() : void { $null = new NullAccountPermission(2); - self::assertEquals(2, $null->getId()); + self::assertEquals(2, $null->id); } } diff --git a/tests/Models/NullAccountTest.php b/tests/Models/NullAccountTest.php index f513400..97cba71 100755 --- a/tests/Models/NullAccountTest.php +++ b/tests/Models/NullAccountTest.php @@ -37,6 +37,6 @@ final class NullAccountTest extends \PHPUnit\Framework\TestCase public function testId() : void { $null = new NullAccount(2); - self::assertEquals(2, $null->getId()); + self::assertEquals(2, $null->id); } } diff --git a/tests/Models/NullAddressTest.php b/tests/Models/NullAddressTest.php index c9cbd5a..d8d4a76 100755 --- a/tests/Models/NullAddressTest.php +++ b/tests/Models/NullAddressTest.php @@ -37,6 +37,6 @@ final class NullAddressTest extends \PHPUnit\Framework\TestCase public function testId() : void { $null = new NullAddress(2); - self::assertEquals(2, $null->getId()); + self::assertEquals(2, $null->id); } } diff --git a/tests/Models/NullGroupPermissionTest.php b/tests/Models/NullGroupPermissionTest.php index 1c63d79..e62667e 100755 --- a/tests/Models/NullGroupPermissionTest.php +++ b/tests/Models/NullGroupPermissionTest.php @@ -37,6 +37,6 @@ final class NullGroupPermissionTest extends \PHPUnit\Framework\TestCase public function testId() : void { $null = new NullGroupPermission(2); - self::assertEquals(2, $null->getId()); + self::assertEquals(2, $null->id); } } diff --git a/tests/Models/NullGroupTest.php b/tests/Models/NullGroupTest.php index 6babcf2..ba797f8 100755 --- a/tests/Models/NullGroupTest.php +++ b/tests/Models/NullGroupTest.php @@ -37,6 +37,6 @@ final class NullGroupTest extends \PHPUnit\Framework\TestCase public function testId() : void { $null = new NullGroup(2); - self::assertEquals(2, $null->getId()); + self::assertEquals(2, $null->id); } } diff --git a/tests/Models/NullModuleTest.php b/tests/Models/NullModuleTest.php index 62cb558..f285d3f 100755 --- a/tests/Models/NullModuleTest.php +++ b/tests/Models/NullModuleTest.php @@ -37,6 +37,6 @@ final class NullModuleTest extends \PHPUnit\Framework\TestCase public function testId() : void { $null = new NullModule('Test'); - self::assertEquals('Test', $null->getId()); + self::assertEquals('Test', $null->id); } }