auto fixes + some impl.

This commit is contained in:
Dennis Eichhorn 2024-01-26 22:53:58 +00:00
parent 2e3ce774bb
commit 35f5c851b7
59 changed files with 1369 additions and 705 deletions

View File

@ -18,7 +18,6 @@ use Modules\Admin\Models\SettingsEnum;
use phpOMS\Application\ApplicationAbstract;
use phpOMS\Message\Http\HttpRequest;
use phpOMS\Message\Http\HttpResponse;
use phpOMS\Uri\HttpUri;
/**
* Media class.
@ -75,7 +74,7 @@ class Messages
];
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('settings', \json_encode($settings));

View File

@ -188,6 +188,11 @@
"type": "TINYINT(1)",
"null": false
},
"address_attr_type_internal": {
"name": "address_attr_type_internal",
"type": "TINYINT(1)",
"null": false
},
"address_attr_type_required": {
"description": "Every address must have this attribute type if set to true.",
"name": "address_attr_type_required",
@ -871,6 +876,11 @@
"type": "TINYINT(1)",
"null": false
},
"unit_attr_type_internal": {
"name": "unit_attr_type_internal",
"type": "TINYINT(1)",
"null": false
},
"unit_attr_type_required": {
"description": "Every unit must have this attribute type if set to true.",
"name": "unit_attr_type_required",
@ -1399,6 +1409,11 @@
"type": "TINYINT(1)",
"null": false
},
"account_attr_type_internal": {
"name": "account_attr_type_internal",
"type": "TINYINT(1)",
"null": false
},
"account_attr_type_required": {
"description": "Every account must have this attribute type if set to true.",
"name": "account_attr_type_required",
@ -1656,50 +1671,35 @@
}
}
},
"account_contact": {
"name": "account_contact",
"contact": {
"name": "contact",
"fields": {
"account_contact_id": {
"name": "account_contact_id",
"contact_id": {
"name": "contact_id",
"type": "INT",
"null": false,
"primary": true,
"autoincrement": true
},
"account_contact_type": {
"name": "account_contact_type",
"type": "TINYINT",
"null": false
},
"account_contact_subtype": {
"name": "account_contact_subtype",
"type": "TINYINT",
"null": false
},
"account_contact_order": {
"name": "account_contact_order",
"type": "INT",
"null": false
},
"account_contact_content": {
"name": "account_contact_content",
"contact_title": {
"name": "contact_title",
"type": "VARCHAR(255)",
"null": false
},
"account_contact_module": {
"name": "account_contact_module",
"type": "VARCHAR(190)",
"null": true,
"default": null,
"foreignTable": "module",
"foreignKey": "module_id"
"contact_type": {
"name": "contact_type",
"type": "TINYINT",
"null": false
},
"account_contact_account": {
"name": "account_contact_account",
"type": "INT",
"null": false,
"foreignTable": "account",
"foreignKey": "account_id"
"contact_subtype": {
"name": "contact_subtype",
"type": "TINYINT",
"null": false
},
"contact_content": {
"name": "contact_content",
"type": "VARCHAR(255)",
"null": false
}
}
},
@ -1737,6 +1737,40 @@
}
}
},
"account_contact_rel": {
"name": "account_contact_rel",
"fields": {
"account_contact_rel_id": {
"name": "account_contact_rel_id",
"type": "INT",
"null": false,
"primary": true,
"autoincrement": true
},
"account_contact_rel_account": {
"name": "account_contact_rel_account",
"type": "INT",
"null": false,
"foreignTable": "account",
"foreignKey": "account_id"
},
"account_contact_rel_module": {
"name": "account_contact_rel_module",
"type": "VARCHAR(190)",
"null": true,
"default": null,
"foreignTable": "module",
"foreignKey": "module_id"
},
"account_contact_rel_contact": {
"name": "account_contact_rel_contact",
"type": "INT",
"null": false,
"foreignTable": "contact",
"foreignKey": "contact_id"
}
}
},
"account_account_rel": {
"description": "Accounts can belong to other accounts. E.g. a user can belong to a company account",
"name": "account_account_rel",

View File

@ -31,7 +31,6 @@ use phpOMS\Module\ModuleInfo;
use phpOMS\System\File\PathException;
use phpOMS\System\OperatingSystem;
use phpOMS\System\SystemType;
use phpOMS\Uri\HttpUri;
/**
* Installer class.
@ -287,13 +286,13 @@ final class Installer extends InstallerAbstract
*
* @since 1.0.0
*/
private static function createSettings(ApplicationAbstract $app, array $data) : array
public static function createSettings(ApplicationAbstract $app, array $data) : array
{
/** @var \Modules\Admin\Controller\ApiController $module */
$module = $app->moduleManager->get('Admin');
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('id', $data['id'] ?? 0);

View File

@ -10,13 +10,13 @@ return [
'verb' => RouteVerb::ANY,
],
],
'^/admin/event.*$' => [
'^/admin/event(\?.*$|$)' => [
[
'dest' => '\Modules\Admin\Controller\CliController:cliRunEvent',
'verb' => RouteVerb::ANY,
],
],
'^/admin/encryption/change.*$' => [
'^/admin/encryption/change(\?.*$|$)' => [
[
'dest' => '\Modules\Admin\Controller\CliController:cliEncryptionChange',
'verb' => RouteVerb::ANY,

View File

@ -153,7 +153,7 @@ return [
],
],
],
'^.*/admin/find/group.*$' => [
'^.*/admin/find/group(\?.*$|$)' => [
[
'dest' => '\Modules\Admin\Controller\ApiController:apiGroupFind',
'verb' => RouteVerb::GET,
@ -164,7 +164,7 @@ return [
],
],
],
'^.*/admin/find/accgrp.*$' => [
'^.*/admin/find/accgrp(\?.*$|$)' => [
[
'dest' => '\Modules\Admin\Controller\ApiController:apiAccountGroupFind',
'verb' => RouteVerb::GET,
@ -226,7 +226,7 @@ return [
],
],
'^.*/admin/module/status.*$' => [
'^.*/admin/module/status(\?.*$|$)' => [
[
'dest' => '\Modules\Admin\Controller\ApiController:apiModuleStatusUpdate',
'verb' => RouteVerb::SET,
@ -238,7 +238,7 @@ return [
],
],
'^.*/admin/group/account.*$' => [
'^.*/admin/group/account(\?.*$|$)' => [
[
'dest' => '\Modules\Admin\Controller\ApiController:apiAddAccountToGroup',
'verb' => RouteVerb::PUT,
@ -249,7 +249,7 @@ return [
],
],
],
'^.*/admin/account/group.*$' => [
'^.*/admin/account/group(\?.*$|$)' => [
[
'dest' => '\Modules\Admin\Controller\ApiController:apiAddGroupToAccount',
'verb' => RouteVerb::PUT,
@ -261,7 +261,7 @@ return [
],
],
'^.*/admin/group/permission.*$' => [
'^.*/admin/group/permission(\?.*$|$)' => [
[
'dest' => '\Modules\Admin\Controller\ApiController:apiGroupPermissionGet',
'verb' => RouteVerb::PUT,
@ -299,7 +299,7 @@ return [
],
],
],
'^.*/admin/account/permission.*$' => [
'^.*/admin/account/permission(\?.*$|$)' => [
[
'dest' => '\Modules\Admin\Controller\ApiController:apiAccountPermissionGet',
'verb' => RouteVerb::GET,
@ -337,7 +337,7 @@ return [
],
],
],
'^.*/admin/module/reinit.*$' => [
'^.*/admin/module/reinit(\?.*$|$)' => [
[
'dest' => '\Modules\Admin\Controller\ApiController:apiReInit',
'verb' => RouteVerb::GET,
@ -349,7 +349,7 @@ return [
],
],
'^.*/admin/update/url.*$' => [
'^.*/admin/update/url(\?.*$|$)' => [
[
'dest' => '\Modules\Admin\Controller\ApiController:apiUpdateFile',
'verb' => RouteVerb::GET,
@ -360,7 +360,7 @@ return [
],
],
],
'^.*/admin/update/check.*$' => [
'^.*/admin/update/check(\?.*$|$)' => [
[
'dest' => '\Modules\Admin\Controller\ApiController:apiCheckForUpdates',
'verb' => RouteVerb::PUT,
@ -371,7 +371,7 @@ return [
],
],
],
'^.*/admin/update/component.*$' => [
'^.*/admin/update/component(\?.*$|$)' => [
[
'dest' => '\Modules\Admin\Controller\ApiController:apiCheckForUpdates',
'verb' => RouteVerb::PUT,
@ -382,4 +382,62 @@ return [
],
],
],
'^.*/account/address$' => [
[
'dest' => '\Modules\Admin\Controller\ApiAttributeController:apiAddressCreate',
'verb' => RouteVerb::PUT,
'permission' => [
'module' => ApiController::NAME,
'type' => PermissionType::CREATE,
'state' => PermissionCategory::ADDRESS,
],
],
[
'dest' => '\Modules\Admin\Controller\ApiAttributeController:apiAddressUpdate',
'verb' => RouteVerb::SET,
'permission' => [
'module' => ApiController::NAME,
'type' => PermissionType::MODIFY,
'state' => PermissionCategory::ADDRESS,
],
],
[
'dest' => '\Modules\Admin\Controller\ApiAttributeController:apiAddressDelete',
'verb' => RouteVerb::DELETE,
'permission' => [
'module' => ApiController::NAME,
'type' => PermissionType::DELETE,
'state' => PermissionCategory::ADDRESS,
],
],
],
'^.*/account/contact$' => [
[
'dest' => '\Modules\Admin\Controller\ApiAttributeController:apiContactCreate',
'verb' => RouteVerb::PUT,
'permission' => [
'module' => ApiController::NAME,
'type' => PermissionType::CREATE,
'state' => PermissionCategory::ADDRESS,
],
],
[
'dest' => '\Modules\Admin\Controller\ApiAttributeController:apiContactUpdate',
'verb' => RouteVerb::SET,
'permission' => [
'module' => ApiController::NAME,
'type' => PermissionType::MODIFY,
'state' => PermissionCategory::ADDRESS,
],
],
[
'dest' => '\Modules\Admin\Controller\ApiAttributeController:apiContactDelete',
'verb' => RouteVerb::DELETE,
'permission' => [
'module' => ApiController::NAME,
'type' => PermissionType::DELETE,
'state' => PermissionCategory::ADDRESS,
],
],
],
];

View File

@ -18,7 +18,7 @@ use phpOMS\Account\PermissionType;
use phpOMS\Router\RouteVerb;
return [
'^.*/forgot.*$' => [
'^.*/forgot(\?.*$|$)' => [
[
'dest' => '\Modules\Admin\Controller\BackendController:viewForgot',
'verb' => RouteVerb::GET,
@ -27,7 +27,7 @@ return [
],
],
'^.*/admin/module/settings.*$' => [
'^.*/admin/module/settings(\?.*$|$)' => [
[
'dest' => '\Modules\Admin\Controller\BackendController:viewModuleSettings',
'verb' => RouteVerb::GET,
@ -39,7 +39,7 @@ return [
],
],
'^.*/admin/account/list.*$' => [
'^.*/admin/account/list(\?.*$|$)' => [
[
'dest' => '\Modules\Admin\Controller\BackendController:viewAccountList',
'verb' => RouteVerb::GET,
@ -50,7 +50,7 @@ return [
],
],
],
'^.*/admin/account/settings.*$' => [
'^.*/admin/account/settings(\?.*$|$)' => [
[
'dest' => '\Modules\Admin\Controller\BackendController:viewAccountSettings',
'verb' => RouteVerb::GET,
@ -61,7 +61,7 @@ return [
],
],
],
'^.*/admin/account/create.*$' => [
'^.*/admin/account/create(\?.*$|$)' => [
[
'dest' => '\Modules\Admin\Controller\BackendController:viewAccountCreate',
'verb' => RouteVerb::GET,
@ -72,7 +72,7 @@ return [
],
],
],
'^.*/admin/group/list.*$' => [
'^.*/admin/group/list(\?.*$|$)' => [
[
'dest' => '\Modules\Admin\Controller\BackendController:viewGroupList',
'verb' => RouteVerb::GET,
@ -83,7 +83,7 @@ return [
],
],
],
'^.*/admin/group/settings.*$' => [
'^.*/admin/group/settings(\?.*$|$)' => [
[
'dest' => '\Modules\Admin\Controller\BackendController:viewGroupSettings',
'verb' => RouteVerb::GET,
@ -94,7 +94,7 @@ return [
],
],
],
'^.*/admin/group/create.*$' => [
'^.*/admin/group/create(\?.*$|$)' => [
[
'dest' => '\Modules\Admin\Controller\BackendController:viewGroupCreate',
'verb' => RouteVerb::GET,
@ -105,7 +105,7 @@ return [
],
],
],
'^.*/admin/module/list.*$' => [
'^.*/admin/module/list(\?.*$|$)' => [
[
'dest' => '\Modules\Admin\Controller\BackendController:viewModuleList',
'verb' => RouteVerb::GET,
@ -116,7 +116,7 @@ return [
],
],
],
'^.*/admin/module/info\?.*$' => [
'^.*/admin/module/info(\?.*$|$)' => [
[
'dest' => '\Modules\Admin\Controller\BackendController:viewModuleInfo',
'verb' => RouteVerb::GET,
@ -127,7 +127,7 @@ return [
],
],
],
'^.*/admin/module/log\?.*$' => [
'^.*/admin/module/log(\?.*$|$)' => [
[
'dest' => '\Modules\Admin\Controller\BackendController:viewModuleLog',
'verb' => RouteVerb::GET,
@ -138,7 +138,7 @@ return [
],
],
],
'^.*/admin/module/route/list\?.*$' => [
'^.*/admin/module/route/list(\?.*$|$)' => [
[
'dest' => '\Modules\Admin\Controller\BackendController:viewModuleRouteList',
'verb' => RouteVerb::GET,
@ -149,7 +149,7 @@ return [
],
],
],
'^.*/admin/module/hook/list\?.*$' => [
'^.*/admin/module/hook/list(\?.*$|$)' => [
[
'dest' => '\Modules\Admin\Controller\BackendController:viewModuleHookList',
'verb' => RouteVerb::GET,

View File

@ -37,7 +37,7 @@ $temperatures = \phpOMS\Utils\Converter\TemperatureType::getConstants();
$serverModes = ApplicationStatus::getConstants();
$l11n = $this->getData('default_localization') ?? new NullLocalization();
$l11n = $this->data['default_localization'] ?? new NullLocalization();
echo $this->data['nav']->render();
?>
@ -288,7 +288,7 @@ echo $this->data['nav']->render();
<label for="iCurrencies"><?= $this->getHtml('Currency'); ?></label>
<select form="fLocalization" id="iCurrencies" name="settings_currency">
<?php foreach ($currencies as $code => $currency) : $code = \substr($code, 1); ?>
<option value="<?= $this->printHtml($code); ?>"<?= $this->printHtml($code === $l11n->getCurrency() ? ' selected' : ''); ?>><?= $this->printHtml($currency); ?>
<option value="<?= $this->printHtml($code); ?>"<?= $this->printHtml($code === $l11n->currency ? ' selected' : ''); ?>><?= $this->printHtml($currency); ?>
<?php endforeach; ?>
</select>
</div>
@ -296,8 +296,8 @@ echo $this->data['nav']->render();
<div class="form-group">
<label><?= $this->getHtml('Currencyformat'); ?></label>
<select form="fLocalization" name="settings_currencyformat">
<option value="0"<?= $this->printHtml($l11n->getCurrencyFormat() === '0' ? ' selected' : ''); ?>><?= $this->getHtml('Amount') , ' ' , $this->printHtml($l11n->getCurrency()); ?>
<option value="1"<?= $this->printHtml($l11n->getCurrencyFormat() === '1' ? ' selected' : ''); ?>><?= $this->printHtml($l11n->getCurrency()) , ' ' , $this->getHtml('Amount'); ?>
<option value="0"<?= $this->printHtml($l11n->getCurrencyFormat() === '0' ? ' selected' : ''); ?>><?= $this->getHtml('Amount') , ' ' , $this->printHtml($l11n->currency); ?>
<option value="1"<?= $this->printHtml($l11n->getCurrencyFormat() === '1' ? ' selected' : ''); ?>><?= $this->printHtml($l11n->currency) , ' ' , $this->getHtml('Amount'); ?>
</select>
</div>
@ -806,7 +806,7 @@ echo $this->data['nav']->render();
$name = $this->getData('settings_class')::getName($setting->name);
if (!\is_string($name)) {
$name= $setting->name;
$name = $setting->name;
}
}
?>

View File

@ -1,12 +1,16 @@
# Development
## Development environment
The setup and configuration of the development environment is in the hands of every developer themselves. However, it is recommended to follow the setup instructions in the [Developer-Guide](https://github.com/Karaka-Management/Developer-Guide/blob/develop/general/setup.md).
The setup and configuration of the development environment is in the hands of every developer themselves. However, it is recommended to follow the setup instructions in the [Developer-Guide](https://github.com/Karaka-Management/Developer-Guide/blob/develop/general/setup.md).
## Code of conduct
Every organization member and contributor to the organization must follow the [code of conduct](../Policies & Guidelines/Code of conduct.md).
Every organization member and contributor to the organization must follow the [Code of Conduct](../Policies%20&%20Guidelines/Code%20of%20Conduct.md).
## Becoming a contributor
For public repositories you can immediately start by creating forks and pull requests. For private repositories which are necessary to setup the complete developer environment, feel free to request access. Please not that we may not immediately give you access to private repositories and instead will give you smaller tasks regarding public repositories. Please contact info@jingga.app for more details. (**R1**)
For all contributions our [Contributor License Agreement "CLA"](https://github.com/Karaka-Management/Organization-Guide/blob/master/Processes/HR/Hiring/Individual%20Contributor%20License%20Agreement.md) comes into effect. (**R2**)
## Code changes
@ -14,58 +18,106 @@ Every organization member and contributor to the organization must follow the [c
Generally, the development philosophy is result orientated. This means that anyone can propose tasks, pick up existing tasks or right away implement their code changes. However, implementing code changes without consulting with a senior developer in advance has a much higher risk of code changes not getting admitted. The easiest way to discuss a code change idea in advance are the github [issues](https://github.com/Karaka-Management/Karaka/issues) or [discussions](https://github.com/Karaka-Management/Karaka/discussions).
Developers are encouraged to pick open tasks with high priorities according to their own skill level. Senior developers may directly assign tasks to developers based on their importance. New developers may find it easier to start with a task that has a low priority as they often also have a lower difficulty.
Developers are encouraged to pick open tasks with high priorities according to their own skill level. Senior developers may directly assign tasks to developers based on their importance. New developers may find it easier to start with a task that has a low priority as they often also have a lower difficulty.
Open tasks can be found in the project overview: [PROJECT.md](https://github.com/orgs/Karaka-Management/projects/10)
Open tasks can be found in the project overview: [Todos](https://github.com/orgs/Karaka-Management/projects/10)
Tasks currently in development are prefixed in the priority column with an asterisk `*` and a name tag in the task description of the developer who is working on the task.
Tasks currently in development are prefixed in the priority column with an asterisk `*` and a name tag in the task description of the developer who is working on the task.
The open tasks are reviewed once a month by a senior developer. The senior developer updates the project overview if necessary and requests feedback regarding development status of important tasks under development. During this process important tasks may also get directly assigned to developers. This review is performed on a judgmental bases of the senior basis.
The open tasks are reviewed once a month by a senior developer. The senior developer updates the project overview if necessary and requests feedback regarding development status of important tasks under development. During this process important tasks may also get directly assigned to developers. This review is performed on a judgmental bases of the senior basis.
### Code style
### Quality
Code changes must follow the [style guidelines](https://github.com/Karaka-Management/Developer-Guide/tree/develop/standards). Additionally, the automatic code style inspection tools must return no errors, failures or warnings. Developers should test their changes with inspection tools and configurations mentioned in the [inspection documentation](https://github.com/Karaka-Management/Developer-Guide/blob/develop/quality/inspections.md) in advance before submitting them for review.
#### Code style
In rare cases errors, failures or warnings during the automatic inspection are acceptable. Reasons can be changes in the programming language, special cases which cannot, are difficult or must be individually configured in the inspection settings. If this is the case for a code change and if inspection configuration changes are necessary are decided by the senior developer performing the code review.
Code changes must follow the [style guidelines](https://github.com/Karaka-Management/Developer-Guide/tree/develop/standards) (**R3**). Additionally, the automatic code style inspection tools must return no errors, failures or warnings. Developers should test their changes with inspection tools and configurations mentioned in the [inspection documentation](https://github.com/Karaka-Management/Developer-Guide/blob/develop/quality/inspections.md) in advance before submitting them for review. (**R4**)
Automated checks which are run during the review process:
In rare cases errors, failures or warnings during the automatic inspection are acceptable. Reasons can be for example special cases which are difficult automatize or must be individually configured in the inspection settings. If this is the case for a code change and if inspection configuration changes are necessary are decided by the senior developer performing the code review. (**R5**)
Automated checks which are run during the review process (**R4**):
```sh
php ./vendor/bin/phpcs --severity=1 ./ --standard="Build/Config/phpcs.xml"
php ./vendor/bin/phpcs ./ --standard="Build/Config/phpcs.xml"
php ./vendor/bin/php-cs-fixer fix ./ --config=Build/Config/.php-cs-fixer.php --allow-risky=yes
php ./vendor/bin/phpcbf --standard=Build/Config/phpcs.xml ./
php ./vendor/bin/rector process --dry-run --config Build/Config/rector.php ./
npx eslint ./ -c ./Build/Config/.eslintrc.json
```
### Tests
#### Tests
Code changes must follow the inspection guidelines (i.e. code coverage) mentioned in the [inspection documentation](https://github.com/Karaka-Management/Developer-Guide/blob/develop/quality/inspections.md). Developers should check if the code changes comply with the inspection guidelines before submitting them.
Code changes must follow the inspection guidelines (i.e. code coverage) mentioned in the [inspection documentation](https://github.com/Karaka-Management/Developer-Guide/blob/develop/quality/inspections.md) (**R6**). Developers should test their changes with inspection tools and configurations mentioned in the [inspection documentation](https://github.com/Karaka-Management/Developer-Guide/blob/develop/quality/inspections.md) in advance before submitting them for review. (**R7**)
In rare cases it might be not possible to follow the inspection guidelines. In such cases the senior developer performing the code review may decide if the code change still gets accepted.
In rare cases it might be not possible to follow the inspection guidelines. In such cases the senior developer performing the code review may decide if the code change still gets accepted. (**R8**)
Automated tests which are run during the review process:
Automated tests which are run during the review process (**R7**):
```sh
php ./vendor/bin/phpunit -c tests/PHPUnit/phpunit_default.xml
php ./vendor/bin/phpstan analyse --autoload-file=phpOMS/Autoloader.php -l 9 -c Build/Config/phpstan.neon ./
php ./vendor/bin/phpstan analyse --no-progress -l 9 -c Build/Config/phpstan.neon ./
npx jasmine-node ./
./cOMS/tests/test.sh
```
Additional inspections which are run but might be ignored during the review depending on the use case are mentioned in the [inspection documentation](https://github.com/Karaka-Management/Developer-Guide/blob/develop/quality/inspections.md) as other checks.
Additional inspections which are run but might be ignored during the review depending on the use case are mentioned in the [inspection documentation](https://github.com/Karaka-Management/Developer-Guide/blob/develop/quality/inspections.md) as other checks. (**R7**)
### Demo
#### Performance
Some code changes may also require changes or extensions in the demo setup scripts. The demo setup script try to simulate a real world use case by generating and modifying mostly random data. This is also a good way to setup and “manually” test the code changes in a larger picture. The demo setup script can be found in the [demoSetup](https://github.com/Karaka-Management/demoSetup) repository. The demo setup script takes a long time due to the large amount of user input simulated data which is generated. Therefore it is recommended to run this only sporadically.
Developers should occasionaly check performance statistics. At this point no target metrics are defined.
### Code review
Since the primary application is a web based application a similar tool as the Google lighthouse tool can be used to inspect the application for best practicies which can significantly improve the application performance. The sitespeed.io tool shows potential performance improvements and slow pages. With the php trace and profiler enabled in the `php.ini` file the VM automatically generates profiling and trace reports for every web request. These can be found in the webgrind logs directory and inspected in webgrind and dropped into the trace visualizer for a flame chart visualization. With mysqldumpslow you can inspect slow sql queries which may need optimization.
1. Automatic trace and benchmark generation with every web request in `/var/www/html/webgrind/Logs`
2. Webgrind view `http://vm_ip:82`
3. Trace visualization `http://vm_ip:81`
1. Download the latest trace from `http://vm_ip:82/Logs`
2. Drag and drop that downloaded `*.xt` file in the trace visualizer
4. `sitespeed.io ./Build/Helper/Scripts/sitespeedDemoUrls.txt -b chrome --outputFolder /var/www/html/sitespeed`
5. Slow query inspection.
```sh
mysqldumpslow -t 10 /var/log/mysql/mysql-slow.log
mysqldumpslow -t 10 -s l /var/log/mysql/mysql-slow.log
```
#### Code review
In addition to the automatic code review performed by the various inspection tools such as (phpcs, phpstan, phpunit, eslint and custom scripts) a senior developer must check the proposed code change before it is merged with the respective `develop` branch. Only upon the approval by the reviewer a code change requests gets merged as no other developers have permission in the software to make such code merges.
In case a code change request is not approved the reviewer states the reason for the decision, this may include some tips and requests which will allow the contributor to make improvements so that the code change may get approved.
If the code reviewer only finds minor issues with the proposed code change the reviewer may make small changes to the proposed code change and inform the contributor to speed up the implementation process. Code reviewers are encouraged to do this with new contributors to avoid long iteration processes and to not discourage new developers. However, communication is key and severe issues with code change requests or if the contributor already made multiple code change requests in the past the reviewer should not implement the improvements by himself and rather decline the code change requests with his reasoning.
If the code reviewer only finds minor issues with the proposed code change the reviewer may make small changes to the proposed code change and inform the contributor to speed up the implementation process. Code reviewers are encouraged to do this with new contributors to avoid long iteration processes and to not discourage new developers. However, communication is key and severe issues with code change requests or if the contributor already made multiple code change requests in the past the reviewer should not implement the improvements by himself and rather decline the code change requests with his reasoning. (**R5**+**R8**)
#### Demo
Some code changes may also require changes or extensions in the demo setup scripts. The demo setup script try to simulate a real world use case by generating and modifying mostly random data. This is also a good way to setup and “manually” test the code changes in a larger picture. The demo setup script can be found in the [demoSetup](https://github.com/Karaka-Management/demoSetup) repository. The demo setup script takes a long time due to the large amount of user input simulated data which is generated. Therefore it is recommended to run this only sporadically. (**R9**)
```sh
sudo -u www-data php -dxdebug.remote_enable=1 -dxdebug.start_with_request=yes -dxdebug.mode=coverage,develop,debug demoSetup/setup.php
```
#### Documentation
Occasionally new code or code changes also require new documentation or documentation changes. Developers should make sure that the new code is also reflected in the existing documentation ([Developer-Guide](), [User-Guide]() and/or module documentation) or if additional documentation is necessary.
#### Improvements, features, bugs
If a developer (or employee in general) has an idea for an improvement, feature or finds a potential bug it should be reported at https://github.com/Karaka-Management/Karaka/issues. A senior developer has to check these issues and decide how to proceed with them. The decision how to proceed with the issue must be explained by the senior developer as a response in the issue. Possible steps are:
* Accept the issue and put the task into the [Todos](https://github.com/orgs/Karaka-Management/projects/10)
* Dismiss the issue with an explanation
### Release flow
In case SCSS/CSS or JS files got changed they must get re-built locally before comitting the code change:
```sh
npx esbuild Web/Backend/js/backend.js --bundle --outfile=Install/Application/Backend/js/backend.min.js --minify
scss cssOMS/styles.scss > cssOMS/styles.css
```
For JS you may also use the shorthand command `npm run build`.
Code changes must be performed in a new branch. A new branch can be created with:
```sh
@ -75,8 +127,70 @@ git checkout -b new-branch-name
The name of the branch can be chosen freely however it is recommended to follow the following branch naming conventions:
* `feature-*` for feature implementations
* `hotfix-*` for security related fixes/improvements
* `bug-*` for bug fixes
* `security-*` for security related fixes/improvements
* `general-*` for general improvements (i.e. code documentation improvements, code style improvements)
* `general-*` for general improvements (i.e. documentation, code style & performance improvements)
The senior developer who performs the code review merges the change request into the `develop` branch upon approval.
```mermaid
%%{init: { 'gitGraph': {'mainBranchName': 'master'}} }%%
gitGraph
commit
branch hotfix-xxx
commit
checkout master
branch develop
checkout master
merge hotfix-xxx
checkout develop
branch bug-xxx
commit
commit
checkout hotfix-xxx
commit
checkout master
merge hotfix-xxx
checkout develop
merge bug-xxx
commit
checkout develop
branch feature-xxx
commit
commit
commit
checkout develop
merge feature-xxx
checkout master
merge develop
checkout develop
branch general-xxx
commit
checkout develop
merge general-xxx
branch security-xxx
commit
commit
checkout develop
merge security-xxx
checkout master
merge develop
```
The senior developer who performs the code review merges the change request into the `develop` branch after their successful code review. Unsuccessful reviews lead to change requests by the original developer, other developers who can make the requested changes, changes by the senior developer who performed the review, or dismissal of the changed code. (**R10**)
## Approved dependencies
### Customer dependencies
Developers may only rely on the dependencies defined in [Approved Customer Software]() when developing a solution. If new software should be added to this list or a different version is required developers should make a request with their team leader/head of department who forwards this requests if appropriate to the CTO and explain the reasoning for the different dependency needs. The CTO can decide if the dependency will be accepted. (**R11**)
### Developer dependencies
Developers may only rely on the dependencies defined in [IT Equipment & Software](). If new software should be added to this list or a different version is required developers should make a request with their team leader/head of department who forwards this requests if appropriate to the CTO and explain the reasoning for the different dependency needs. The CTO can decide if the dependency will be accepted. Changing the package managers such as `composer.json` or `package.json` is not allowed by anyone else than the CTO. (**R12**)
## Other related documents
* [Confidentiality Policy](../Policies%20&%20Guidelines/Confidentiality%20Policy.md)
* [Organization Activity Policy](../Policies%20&%20Guidelines/Organization%20Activity%20Policy.md)
* [Tutorials](./Development/Tutorials)

View File

@ -21,10 +21,12 @@ use Modules\Admin\Models\AccountCredentialMapper;
use Modules\Admin\Models\AccountMapper;
use Modules\Admin\Models\AccountPermission;
use Modules\Admin\Models\AccountPermissionMapper;
use Modules\Admin\Models\AddressMapper;
use Modules\Admin\Models\App;
use Modules\Admin\Models\AppMapper;
use Modules\Admin\Models\Contact;
use Modules\Admin\Models\ContactMapper;
use Modules\Admin\Models\ContactType;
use Modules\Admin\Models\DataChange;
use Modules\Admin\Models\DataChangeMapper;
use Modules\Admin\Models\Group;
@ -48,11 +50,13 @@ use phpOMS\Account\GroupStatus;
use phpOMS\Account\PermissionAbstract;
use phpOMS\Account\PermissionOwner;
use phpOMS\Account\PermissionType;
use phpOMS\Api\Geocoding\Nominatim;
use phpOMS\Application\ApplicationInfo;
use phpOMS\Application\ApplicationManager;
use phpOMS\Application\ApplicationType;
use phpOMS\Auth\LoginReturnType;
use phpOMS\DataStorage\Database\Query\Builder;
use phpOMS\Localization\ISO3166TwoEnum;
use phpOMS\Localization\Localization;
use phpOMS\Message\Http\HttpRequest;
use phpOMS\Message\Http\HttpResponse;
@ -70,6 +74,8 @@ use phpOMS\Model\Message\Reload;
use phpOMS\Module\ModuleInfo;
use phpOMS\Module\ModuleStatus;
use phpOMS\Security\EncryptionHelper;
use phpOMS\Stdlib\Base\Address;
use phpOMS\Stdlib\Base\AddressType;
use phpOMS\System\File\Local\File;
use phpOMS\System\MimeType;
use phpOMS\Uri\HttpUri;
@ -627,11 +633,11 @@ final class ApiController extends Controller
$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;
$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;
$this->app->appSettings->set([$new], false);
@ -864,7 +870,7 @@ final class ApiController extends Controller
$dataSettings = $request->getLike('settings_(.*)');
$account->l11n->setCountry($dataSettings['settings_country']);
$account->l11n->setLanguage($dataSettings['settings_language']);
$account->l11n->language = $dataSettings['settings_language'];
$account->l11n->setTemperature($dataSettings['settings_temperature']);
$account->l11n->setTimezone($dataSettings['settings_timezone']);
@ -878,7 +884,7 @@ final class ApiController extends Controller
]
);
$account->l11n->setCurrency($dataSettings['settings_currency']);
$account->l11n->currency = $dataSettings['settings_currency'];
$account->l11n->setCurrencyFormat($dataSettings['settings_currencyformat']);
$account->l11n->setDecimal($dataSettings['settings_decimal']);
@ -1074,7 +1080,7 @@ final class ApiController extends Controller
{
$app = new App();
$app->name = $request->getDataString('name') ?? '';
$app->type = $request->getDataInt('type') ?? ApplicationType::WEB;
$app->type = ApplicationType::tryFromValue($request->getDataInt('type')) ?? ApplicationType::WEB;
$app->defaultUnit = $request->getDataInt('default_unit');
return $app;
@ -1200,8 +1206,8 @@ final class ApiController extends Controller
*/
private function updateGroupFromRequest(RequestAbstract $request, Group $group) : Group
{
$group->name = $request->getDataString('name') ?? $group->name;
$group->setStatus($request->getDataInt('status') ?? $group->getStatus());
$group->name = $request->getDataString('name') ?? $group->name;
$group->status = GroupStatus::tryFromValue($request->getDataInt('status')) ?? $group->status;
$group->description = Markdown::parse($request->getDataString('description') ?? $group->descriptionRaw);
$group->descriptionRaw = $request->getDataString('description') ?? $group->descriptionRaw;
@ -1267,10 +1273,10 @@ final class ApiController extends Controller
*/
private function createGroupFromRequest(RequestAbstract $request) : Group
{
$group = new Group();
$group->createdBy = new NullAccount($request->header->account);
$group->name = $request->getDataString('name') ?? '';
$group->setStatus($request->getDataInt('status') ?? GroupStatus::INACTIVE);
$group = new Group();
$group->createdBy = new NullAccount($request->header->account);
$group->name = $request->getDataString('name') ?? '';
$group->status = GroupStatus::tryFromValue($request->getDataInt('status')) ?? GroupStatus::INACTIVE;
$group->description = Markdown::parse($request->getDataString('description') ?? '');
$group->descriptionRaw = $request->getDataString('description') ?? '';
@ -1394,7 +1400,7 @@ final class ApiController extends Controller
public function apiAccountFind(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
{
/** @var \Modules\Admin\Models\Account[] $accounts */
$accounts = AccountMapper::getAll()
$accounts = AccountMapper::getAll()
->where('login', '%' . ($request->getDataString('search') ?? '') . '%', 'LIKE')
->where('email', '%' . ($request->getDataString('search') ?? '') . '%', 'LIKE', 'OR')
->where('name1', '%' . ($request->getDataString('search') ?? '') . '%', 'LIKE', 'OR')
@ -1791,7 +1797,7 @@ final class ApiController extends Controller
}
if (empty($defaultGroupIds)
&& $account->getStatus() === AccountStatus::INACTIVE
&& $account->status === AccountStatus::INACTIVE
) {
$response->header->status = RequestStatusCode::R_400;
@ -2016,7 +2022,7 @@ final class ApiController extends Controller
break;
}
$new->setStatus((int) ($data['status'] ?? -1));
$new->status = AccountStatus::tryFromValue((int) ($data['status'] ?? AccountStatus::INACTIVE)) ?? AccountStatus::INACTIVE;
$this->updateModel($dataChange->createdBy, $old, $new, AccountMapper::class, 'datachange', $request->getOrigin());
$this->deleteModel($dataChange->createdBy, $dataChange, DataChangeMapper::class, 'datachange', $request->getOrigin());
@ -2098,13 +2104,13 @@ final class ApiController extends Controller
*/
private function createAccountFromRequest(RequestAbstract $request) : Account
{
$account = new Account();
$account->login = $request->getDataString('user') ?? '';
$account->name1 = $request->getDataString('name1') ?? '';
$account->name2 = $request->getDataString('name2') ?? '';
$account->name3 = $request->getDataString('name3') ?? '';
$account->setStatus($request->getDataInt('status') ?? AccountStatus::INACTIVE);
$account->setType($request->getDataInt('type') ?? AccountType::USER);
$account = new Account();
$account->login = $request->getDataString('user') ?? '';
$account->name1 = $request->getDataString('name1') ?? '';
$account->name2 = $request->getDataString('name2') ?? '';
$account->name3 = $request->getDataString('name3') ?? '';
$account->status = AccountStatus::tryFromValue($request->getDataInt('status')) ?? AccountStatus::INACTIVE;
$account->type = AccountType::tryFromValue($request->getDataInt('type')) ?? AccountType::USER;
$account->setEmail($request->getDataString('email') ?? '');
$account->generatePassword($request->getDataString('password') ?? '');
@ -2191,8 +2197,8 @@ final class ApiController extends Controller
$account->name2 = $request->getDataString('name2') ?? $account->name2;
$account->name3 = $request->getDataString('name3') ?? $account->name3;
$account->setEmail($request->getDataString('email') ?? $account->getEmail());
$account->setStatus($request->getDataInt('status') ?? $account->getStatus());
$account->setType($request->getDataInt('type') ?? $account->getType());
$account->status = AccountStatus::tryFromValue($request->getDataInt('status')) ?? $account->status;
$account->type = AccountType::tryFromValue($request->getDataInt('type')) ?? $account->type;
if ($allowPassword && $request->hasData('password')) {
$account->generatePassword((string) $request->getData('password'));
@ -2250,8 +2256,8 @@ final class ApiController extends Controller
? $this->app->l11nManager->getText($response->header->l11n->language, 'Admin', 'Api', 'ModuleActivatedSuccessful')
: $this->app->l11nManager->getText($response->header->l11n->language, 'Admin', 'Api', 'ModuleActivatedFailure');
$new = clone $old;
$new->setStatus(ModuleStatusUpdateType::ACTIVATE);
$new = clone $old;
$new->status = ModuleStatusUpdateType::ACTIVATE;
ModuleMapper::update()->execute($new);
break;
@ -2261,8 +2267,8 @@ final class ApiController extends Controller
? $this->app->l11nManager->getText($response->header->l11n->language, 'Admin', 'Api', 'ModuleDeactivatedSuccessful')
: $this->app->l11nManager->getText($response->header->l11n->language, 'Admin', 'Api', 'ModuleDeactivatedFailure');
$new = clone $old;
$new->setStatus(ModuleStatusUpdateType::DEACTIVATE);
$new = clone $old;
$new->status = ModuleStatusUpdateType::DEACTIVATE;
ModuleMapper::update()->execute($new);
break;
@ -2289,7 +2295,7 @@ final class ApiController extends Controller
$dependencies = $moduleInfo->getDependencies();
foreach ($dependencies as $key => $_) {
$iResponse = new HttpResponse();
$iRequest = new HttpRequest(new HttpUri(''));
$iRequest = new HttpRequest();
$iRequest->header->account = 1;
$iRequest->setData('status', ModuleStatusUpdateType::INSTALL);
$iRequest->setData('module', $key);
@ -2305,7 +2311,7 @@ final class ApiController extends Controller
$moduleObj->version = $moduleInfo->getVersion();
$moduleObj->name = $moduleInfo->getExternalName();
$moduleObj->setStatus(ModuleStatus::AVAILABLE);
$moduleObj->status = ModuleStatus::AVAILABLE;
$this->createModel($request->header->account, $moduleObj, ModuleMapper::class, 'module', $request->getOrigin());
@ -2314,8 +2320,8 @@ final class ApiController extends Controller
? $this->app->l11nManager->getText($response->header->l11n->language, 'Admin', 'Api', 'ModuleInstalledSuccessful')
: $this->app->l11nManager->getText($response->header->l11n->language, 'Admin', 'Api', 'ModuleInstalledFailure');
$old = clone $moduleObj;
$moduleObj->setStatus(ModuleStatus::ACTIVE);
$old = clone $moduleObj;
$moduleObj->status = ModuleStatus::ACTIVE;
$this->updateModel($request->header->account, $old, $moduleObj, ModuleMapper::class, 'module', $request->getOrigin());
@ -2356,8 +2362,8 @@ final class ApiController extends Controller
? $this->app->l11nManager->getText($response->header->l11n->language, 'Admin', 'Api', 'ModuleUninstalledSuccessful')
: $this->app->l11nManager->getText($response->header->l11n->language, 'Admin', 'Api', 'ModuleUninstalledFailure');
$new = clone $old;
$new->setStatus(ModuleStatusUpdateType::DELETE);
$new = clone $old;
$new->status = ModuleStatusUpdateType::DELETE;
ModuleMapper::delete()->execute($new);
break;
@ -3098,7 +3104,6 @@ final class ApiController extends Controller
}
$contact = $this->createContactFromRequest($request);
$this->createModel($request->header->account, $contact, ContactMapper::class, 'account_contact', $request->getOrigin());
$this->createModelRelation(
@ -3145,11 +3150,10 @@ final class ApiController extends Controller
public function createContactFromRequest(RequestAbstract $request) : Contact
{
/** @var Contact $element */
$element = new Contact();
$element->setType($request->getDataInt('type') ?? 0);
$element->setSubtype($request->getDataInt('subtype') ?? 0);
$element = new Contact();
$element->type = ContactType::tryFromValue($request->getDataInt('type')) ?? ContactType::EMAIL;
$element->subtype = $request->getDataInt('subtype') ?? 0;
$element->content = $request->getDataString('content') ?? '';
$element->account = $request->getDataInt('account') ?? 0;
return $element;
}
@ -3456,10 +3460,9 @@ final class ApiController extends Controller
*/
public function updateContactFromRequest(RequestAbstract $request, Contact $new) : Contact
{
$new->type = $request->getDataInt('type') ?? $new->type;
$new->type = ContactType::tryFromValue($request->getDataInt('type')) ?? $new->type;
$new->subtype = $request->getDataInt('subtype') ?? $new->subtype;
$new->content = $request->getDataString('content') ?? $new->content;
$new->account = $request->getDataInt('account') ?? $new->account;
return $new;
}
@ -3509,7 +3512,9 @@ final class ApiController extends Controller
/** @var \Modules\Admin\Models\Contact $contact */
$contact = ContactMapper::get()->where('id', (int) $request->getData('id'))->execute();
$this->deleteModelRelation($request->header->account, (int) $request->getData('account'), [$contact->id], AccountMapper::class, 'contacts', 'account-contact', $request->getOrigin());
$this->deleteModel($request->header->account, $contact, ContactMapper::class, 'contact', $request->getOrigin());
$this->createStandardDeleteResponse($request, $response, $contact);
}
@ -3527,7 +3532,9 @@ final class ApiController extends Controller
private function validateContactDelete(RequestAbstract $request) : array
{
$val = [];
if (($val['id'] = !$request->hasData('id'))) {
if (($val['id'] = !$request->hasData('id'))
|| ($val['account'] = !$request->hasData('account'))
) {
return $val;
}
@ -3642,4 +3649,235 @@ final class ApiController extends Controller
return [];
}
/**
* Api method to delete Contact
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiAddressDelete(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
{
if (!empty($val = $this->validateAddressDelete($request))) {
$response->header->status = RequestStatusCode::R_400;
$this->createInvalidDeleteResponse($request, $response, $val);
return;
}
/** @var \Modules\Admin\Models\Address $address */
$address = AddressMapper::get()->where('id', (int) $request->getData('id'))->execute();
$this->deleteModelRelation($request->header->account, (int) $request->getData('account'), [$address->id], AccountMapper::class, 'addresses', 'account-address', $request->getOrigin());
$this->deleteModel($request->header->account, $address, AddressMapper::class, 'address', $request->getOrigin());
$this->createStandardDeleteResponse($request, $response, $address);
}
/**
* Validate Address delete request
*
* @param RequestAbstract $request Request
*
* @return array<string, bool>
*
* @todo Implement API validation function
*
* @since 1.0.0
*/
private function validateAddressDelete(RequestAbstract $request) : array
{
$val = [];
if (($val['id'] = !$request->hasData('id'))
|| ($val['account'] = !$request->hasData('account'))
) {
return $val;
}
return [];
}
/**
* Api method to update Contact
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiAddressUpdate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
{
if (!empty($val = $this->validateAddressUpdate($request))) {
$response->header->status = RequestStatusCode::R_400;
$this->createInvalidUpdateResponse($request, $response, $val);
return;
}
/** @var Address $old */
$old = AddressMapper::get()->where('id', (int) $request->getData('id'))->execute();
$new = $this->updateAddressFromRequest($request, clone $old);
$this->updateModel($request->header->account, $old, $new, AddressMapper::class, 'address', $request->getOrigin());
$this->createStandardUpdateResponse($request, $response, $new);
}
/**
* Validate Contact update request
*
* @param RequestAbstract $request Request
*
* @return array<string, bool>
*
* @todo Implement API validation function
*
* @since 1.0.0
*/
private function validateAddressUpdate(RequestAbstract $request) : array
{
$val = [];
if (($val['id'] = !$request->hasData('id'))) {
return $val;
}
return [];
}
/**
* Method to update an account from a request
*
* @param RequestAbstract $request Request
* @param Address $address Address
*
* @return Address
*
* @since 1.0.0
*/
public function updateAddressFromRequest(RequestAbstract $request, Address $address) : Address
{
$hasLocationChange = ($request->getDataString('address') ?? $address->address) !== $address->address
|| ($request->getDataString('postal') ?? $address->postal) !== $address->postal
|| ($request->getDataString('city') ?? $address->city) !== $address->city
|| ($request->getDataString('state') ?? $address->state) !== $address->state
|| ($request->getDataString('country') ?? $address->country) !== $address->country;
$address->name = $request->getDataString('name') ?? $address->name;
$address->fao = $request->getDataString('fao') ?? $address->fao;
$address->address = $request->getDataString('address') ?? $address->address;
$address->addressAddition = $request->getDataString('addition') ?? $address->addressAddition;
$address->postal = $request->getDataString('postal') ?? $address->postal;
$address->city = $request->getDataString('city') ?? $address->city;
$address->state = $request->getDataString('state') ?? $address->state;
$address->setCountry($request->getDataString('country') ?? $address->country);
if ($hasLocationChange) {
$geocoding = Nominatim::geocoding($address->country, $address->city, $address->address);
if ($geocoding === ['lat' => 0.0, 'lon' => 0.0]) {
$geocoding = Nominatim::geocoding($address->country, $address->city);
}
$address->lat = $geocoding['lat'];
$address->lon = $geocoding['lon'];
}
return $address;
}
/**
* Routing end-point for application behavior.
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiAddressCreate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
{
if (!empty($val = $this->validateAddressCreate($request))) {
$response->header->status = RequestStatusCode::R_400;
$this->createInvalidCreateResponse($request, $response, $val);
return;
}
$address = $this->createAddressFromRequest($request);
$this->createModel($request->header->account, $address, AddressMapper::class, 'account_address', $request->getOrigin());
$this->createModelRelation(
$request->header->account,
(int) $request->getData('account'),
$address->id,
AccountMapper::class, 'addresses', '', $request->getOrigin()
);
$this->createStandardCreateResponse($request, $response, $address);
}
/**
* Validate contact element create request
*
* @param RequestAbstract $request Request
*
* @return array<string, bool>
*
* @since 1.0.0
*/
public function validateAddressCreate(RequestAbstract $request) : array
{
$val = [];
if (($val['account'] = !$request->hasData('account'))
) {
return $val;
}
return [];
}
/**
* Method to create unit from request.
*
* @param RequestAbstract $request Request
*
* @return Address
*
* @since 1.0.0
*/
public function createAddressFromRequest(RequestAbstract $request) : Address
{
$address = new Address();
$address->name = $request->getDataString('name') ?? '';
$address->type = AddressType::tryFromValue($request->getDataInt('type')) ?? AddressType::BUSINESS;
$address->fao = $request->getDataString('fao') ?? '';
$address->address = $request->getDataString('address') ?? '';
$address->postal = $request->getDataString('postal') ?? '';
$address->city = $request->getDataString('city') ?? '';
$address->state = $request->getDataString('state') ?? '';
$address->setCountry($request->getDataString('country') ?? ISO3166TwoEnum::_XXX);
$geocoding = Nominatim::geocoding($address->country, $address->city, $address->address);
if ($geocoding === ['lat' => 0.0, 'lon' => 0.0]) {
$geocoding = Nominatim::geocoding($address->country, $address->city);
}
$address->lat = $geocoding['lat'];
$address->lon = $geocoding['lon'];
return $address;
}
}

View File

@ -20,13 +20,11 @@ use Modules\Admin\Models\AccountPermissionMapper;
use Modules\Admin\Models\AppMapper;
use Modules\Admin\Models\GroupMapper;
use Modules\Admin\Models\GroupPermissionMapper;
use Modules\Admin\Models\LocalizationMapper;
use Modules\Admin\Models\ModuleMapper;
use Modules\Admin\Models\SettingsEnum;
use Modules\Auditor\Models\AuditMapper;
use Modules\Media\Models\MediaMapper;
use Modules\Organization\Models\UnitMapper;
use phpOMS\Asset\AssetType;
use phpOMS\Autoloader;
use phpOMS\Contract\RenderableInterface;
use phpOMS\DataStorage\Database\Query\OrderType;
@ -110,7 +108,7 @@ final class BackendController extends Controller
foreach ($searchFieldData as $key => $data) {
if ($data === '1') {
$split = \explode('-', $key);
$member = \end($split);
$member = \end($split);
$searchField[] = $member;
}
@ -203,7 +201,7 @@ final class BackendController extends Controller
public function viewAccountSettings(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface
{
$view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/Admin/Theme/Backend/accounts-single');
$view->setTemplate('/Modules/Admin/Theme/Backend/accounts-view');
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1000104001, $request, $response);
/** @var \Modules\Admin\Models\Account $account */
@ -234,7 +232,7 @@ final class BackendController extends Controller
foreach ($searchFieldData as $key => $data) {
if ($data === '1') {
$split = \explode('-', $key);
$member = \end($split);
$member = \end($split);
$searchField[] = $member;
}
@ -355,7 +353,7 @@ final class BackendController extends Controller
foreach ($searchFieldData as $key => $data) {
if ($data === '1') {
$split = \explode('-', $key);
$member = \end($split);
$member = \end($split);
$searchField[] = $member;
}
@ -451,7 +449,7 @@ final class BackendController extends Controller
public function viewGroupSettings(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface
{
$view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/Admin/Theme/Backend/groups-single');
$view->setTemplate('/Modules/Admin/Theme/Backend/groups-view');
$view->data['nav'] = $this->app->moduleManager->get('Navigation')
->createNavigationMid(1000103001, $request, $response);
@ -642,7 +640,7 @@ final class BackendController extends Controller
$id = $request->getDataString('id') ?? '';
$queryMapper = AuditMapper::getAll()
$queryMapper = AuditMapper::getAll()
->with('createdBy')
->where('module', $id);
@ -800,13 +798,13 @@ final class BackendController extends Controller
$generalSettings = $this->app->appSettings->get(
names: [
SettingsEnum::PASSWORD_PATTERN, SettingsEnum::LOGIN_TIMEOUT, SettingsEnum::PASSWORD_INTERVAL, SettingsEnum::PASSWORD_HISTORY, SettingsEnum::LOGIN_TRIES, SettingsEnum::LOGGING_STATUS, SettingsEnum::LOGGING_PATH, SettingsEnum::DEFAULT_UNIT,
SettingsEnum::LOGIN_STATUS, SettingsEnum::DEFAULT_LOCALIZATION, SettingsEnum::MAIL_SERVER_ADDR,
SettingsEnum::LOGIN_STATUS, SettingsEnum::MAIL_SERVER_ADDR,
],
module: 'Admin'
);
$view->data['generalSettings'] = $generalSettings;
$view->data['default_localization'] = LocalizationMapper::get()->where('id', (int) $generalSettings[SettingsEnum::DEFAULT_LOCALIZATION]->content)->execute();
$view->data['generalSettings'] = $generalSettings;
$view->data['default_localization'] = $this->app->l11nServer;
return $view;
}

View File

@ -42,7 +42,7 @@ The type is a `module` specific subpart which only should be set if the module i
### Element
The element is a `module` and `type` specific subpart which only should be set if the `type` is defined in the permission. For further information what kind of elements are available for a module and type please refer to the module specific documentation. Usually it referes to a section on a module page.
The element is a `module` and `type` specific subpart which only should be set if the `type` is defined in the permission. For further information what kind of elements are available for a module and type please refer to the module specific documentation. Usually it refers to a section on a module page.
### Component

View File

@ -42,7 +42,7 @@ The type is a `module` specific subpart which only should be set if the module i
### Element
The element is a `module` and `type` specific subpart which only should be set if the `type` is defined in the permission. For further information what kind of elements are available for a module and type please refer to the module specific documentation. Usually it referes to a section on a module page.
The element is a `module` and `type` specific subpart which only should be set if the `type` is defined in the permission. For further information what kind of elements are available for a module and type please refer to the module specific documentation. Usually it refers to a section on a module page.
### Component

View File

@ -27,7 +27,7 @@ Version 2.0
Subject to the terms and conditions of this License, each Contributor grants to You after purchase a perpetual, worldwide, non-exclusive, irrevocable copyright license to prepare Derivative Works of, publicly display, publicly perform the Work and such Derivative Works in Source or Object form. You are not allowed to sublicense, reproduce, or distribute the Work and such Derivative Works in Source or Object form.
3. Redistribution.
3. Redistribution
You may not reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form.

View File

@ -62,7 +62,7 @@ class Account extends \phpOMS\Account\Account
* @var Address[]
* @since 1.0.0
*/
public array $locations = [];
public array $addresses = [];
/**
* Contact data.
@ -71,4 +71,24 @@ class Account extends \phpOMS\Account\Account
* @since 1.0.0
*/
public array $contacts = [];
/**
* Get the main contact element by type
*
* @param int $type Contact element type
*
* @return Contact
*
* @since 1.0.0
*/
public function getContactByType(int $type) : Contact
{
foreach ($this->contacts as $element) {
if ($element->type === $type) {
return $element;
}
}
return new NullContact();
}
}

View File

@ -36,16 +36,16 @@ class AccountExternalMapper extends DataMapperFactory
* @since 1.0.0
*/
public const COLUMNS = [
'account_external_id' => ['name' => 'account_external_id', 'type' => 'int', 'internal' => 'id'],
'account_external_status' => ['name' => 'account_external_status', 'type' => 'int', 'internal' => 'status'],
'account_external_type' => ['name' => 'account_external_type', 'type' => 'int', 'internal' => 'type'],
'account_external_subtype' => ['name' => 'account_external_subtype', 'type' => 'int', 'internal' => 'subtype'],
'account_external_name' => ['name' => 'account_external_name', 'type' => 'string', 'internal' => 'name'],
'account_external_uid' => ['name' => 'account_external_uid', 'type' => 'string', 'internal' => 'uid', ],
'account_external_login' => ['name' => 'account_external_login', 'type' => 'string', 'internal' => 'login', ],
'account_external_password' => ['name' => 'account_external_password', 'type' => 'string', 'internal' => 'password', ],
'account_external_key' => ['name' => 'account_external_key', 'type' => 'string', 'internal' => 'key'],
'account_external_account' => ['name' => 'account_external_account', 'type' => 'int', 'internal' => 'account'],
'account_external_id' => ['name' => 'account_external_id', 'type' => 'int', 'internal' => 'id'],
'account_external_status' => ['name' => 'account_external_status', 'type' => 'int', 'internal' => 'status'],
'account_external_type' => ['name' => 'account_external_type', 'type' => 'int', 'internal' => 'type'],
'account_external_subtype' => ['name' => 'account_external_subtype', 'type' => 'int', 'internal' => 'subtype'],
'account_external_name' => ['name' => 'account_external_name', 'type' => 'string', 'internal' => 'name'],
'account_external_uid' => ['name' => 'account_external_uid', 'type' => 'string', 'internal' => 'uid', ],
'account_external_login' => ['name' => 'account_external_login', 'type' => 'string', 'internal' => 'login', ],
'account_external_password' => ['name' => 'account_external_password', 'type' => 'string', 'internal' => 'password', ],
'account_external_key' => ['name' => 'account_external_key', 'type' => 'string', 'internal' => 'key'],
'account_external_account' => ['name' => 'account_external_account', 'type' => 'int', 'internal' => 'account'],
];
/**

View File

@ -39,18 +39,18 @@ class AccountMapper extends DataMapperFactory
* @since 1.0.0
*/
public const COLUMNS = [
'account_id' => ['name' => 'account_id', 'type' => 'int', 'internal' => 'id'],
'account_status' => ['name' => 'account_status', 'type' => 'int', 'internal' => 'status'],
'account_type' => ['name' => 'account_type', 'type' => 'int', 'internal' => 'type'],
'account_login' => ['name' => 'account_login', 'type' => 'string', 'internal' => 'login', 'autocomplete' => true],
'account_name1' => ['name' => 'account_name1', 'type' => 'string', 'internal' => 'name1', 'autocomplete' => true, 'annotations' => ['gdpr' => true]],
'account_name2' => ['name' => 'account_name2', 'type' => 'string', 'internal' => 'name2', 'autocomplete' => true, 'annotations' => ['gdpr' => true]],
'account_name3' => ['name' => 'account_name3', 'type' => 'string', 'internal' => 'name3', 'autocomplete' => true, 'annotations' => ['gdpr' => true]],
'account_email' => ['name' => 'account_email', 'type' => 'string', 'internal' => 'email', 'autocomplete' => true, 'annotations' => ['gdpr' => true]],
'account_tries' => ['name' => 'account_tries', 'type' => 'int', 'internal' => 'tries'],
'account_lactive' => ['name' => 'account_lactive', 'type' => 'DateTime', 'internal' => 'lastActive'],
'account_localization' => ['name' => 'account_localization', 'type' => 'int', 'internal' => 'l11n'],
'account_created_at' => ['name' => 'account_created_at', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt', 'readonly' => true],
'account_id' => ['name' => 'account_id', 'type' => 'int', 'internal' => 'id'],
'account_status' => ['name' => 'account_status', 'type' => 'int', 'internal' => 'status'],
'account_type' => ['name' => 'account_type', 'type' => 'int', 'internal' => 'type'],
'account_login' => ['name' => 'account_login', 'type' => 'string', 'internal' => 'login', 'autocomplete' => true],
'account_name1' => ['name' => 'account_name1', 'type' => 'string', 'internal' => 'name1', 'autocomplete' => true, 'annotations' => ['gdpr' => true]],
'account_name2' => ['name' => 'account_name2', 'type' => 'string', 'internal' => 'name2', 'autocomplete' => true, 'annotations' => ['gdpr' => true]],
'account_name3' => ['name' => 'account_name3', 'type' => 'string', 'internal' => 'name3', 'autocomplete' => true, 'annotations' => ['gdpr' => true]],
'account_email' => ['name' => 'account_email', 'type' => 'string', 'internal' => 'email', 'autocomplete' => true, 'annotations' => ['gdpr' => true]],
'account_tries' => ['name' => 'account_tries', 'type' => 'int', 'internal' => 'tries'],
'account_lactive' => ['name' => 'account_lactive', 'type' => 'DateTime', 'internal' => 'lastActive'],
'account_localization' => ['name' => 'account_localization', 'type' => 'int', 'internal' => 'l11n'],
'account_created_at' => ['name' => 'account_created_at', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt', 'readonly' => true],
];
/**
@ -60,9 +60,9 @@ class AccountMapper extends DataMapperFactory
* @since 1.0.0
*/
public const OWNS_ONE = [
'l11n' => [
'mapper' => LocalizationMapper::class,
'external' => 'account_localization',
'l11n' => [
'mapper' => LocalizationMapper::class,
'external' => 'account_localization',
],
];
@ -91,7 +91,7 @@ class AccountMapper extends DataMapperFactory
'external' => 'account_account_rel_root',
'self' => 'account_account_rel_child',
],
'locations' => [
'addresses' => [
'mapper' => AddressMapper::class,
'table' => 'account_address_rel',
'external' => 'account_address_rel_address',
@ -99,9 +99,9 @@ class AccountMapper extends DataMapperFactory
],
'contacts' => [
'mapper' => ContactMapper::class,
'table' => 'account_contact',
'self' => 'account_contact_account',
'external' => null,
'table' => 'account_contact_rel',
'external' => 'account_contact_rel_contact',
'self' => 'account_contact_rel_account',
],
];

View File

@ -54,13 +54,13 @@ class AccountPermission extends PermissionAbstract
*/
public function __construct(
int $account = 0,
int $unit = null,
int $app = null,
string $module = null,
string $from = null,
int $category = null,
int $element = null,
int $component = null,
?int $unit = null,
?int $app = null,
?string $module = null,
?string $from = null,
?int $category = null,
?int $element = null,
?int $component = null,
int $permission = PermissionType::NONE
) {
$this->account = $account;

View File

@ -36,22 +36,22 @@ final class AccountPermissionMapper extends DataMapperFactory
* @since 1.0.0
*/
public const COLUMNS = [
'account_permission_id' => ['name' => 'account_permission_id', 'type' => 'int', 'internal' => 'id'],
'account_permission_account' => ['name' => 'account_permission_account', 'type' => 'int', 'internal' => 'account'],
'account_permission_unit' => ['name' => 'account_permission_unit', 'type' => 'int', 'internal' => 'unit'],
'account_permission_app' => ['name' => 'account_permission_app', 'type' => 'int', 'internal' => 'app'],
'account_permission_module' => ['name' => 'account_permission_module', 'type' => 'string', 'internal' => 'module'],
'account_permission_from' => ['name' => 'account_permission_from', 'type' => 'string', 'internal' => 'from'],
'account_permission_category' => ['name' => 'account_permission_category', 'type' => 'int', 'internal' => 'category'],
'account_permission_element' => ['name' => 'account_permission_element', 'type' => 'int', 'internal' => 'element'],
'account_permission_component' => ['name' => 'account_permission_component', 'type' => 'int', 'internal' => 'component'],
'account_permission_hasread' => ['name' => 'account_permission_hasread', 'type' => 'bool', 'internal' => 'hasRead'],
'account_permission_hascreate' => ['name' => 'account_permission_hascreate', 'type' => 'bool', 'internal' => 'hasCreate'],
'account_permission_defaultcperm' => ['name' => 'account_permission_defaultcperm', 'type' => 'string', 'internal' => 'defaultCPermissions'],
'account_permission_hasmodify' => ['name' => 'account_permission_hasmodify', 'type' => 'bool', 'internal' => 'hasModify'],
'account_permission_hasdelete' => ['name' => 'account_permission_hasdelete', 'type' => 'bool', 'internal' => 'hasDelete'],
'account_permission_haspermission' => ['name' => 'account_permission_haspermission', 'type' => 'bool', 'internal' => 'hasPermission'],
'account_permission_defaultpperm' => ['name' => 'account_permission_defaultpperm', 'type' => 'string', 'internal' => 'defaultPPermissions'],
'account_permission_id' => ['name' => 'account_permission_id', 'type' => 'int', 'internal' => 'id'],
'account_permission_account' => ['name' => 'account_permission_account', 'type' => 'int', 'internal' => 'account'],
'account_permission_unit' => ['name' => 'account_permission_unit', 'type' => 'int', 'internal' => 'unit'],
'account_permission_app' => ['name' => 'account_permission_app', 'type' => 'int', 'internal' => 'app'],
'account_permission_module' => ['name' => 'account_permission_module', 'type' => 'string', 'internal' => 'module'],
'account_permission_from' => ['name' => 'account_permission_from', 'type' => 'string', 'internal' => 'from'],
'account_permission_category' => ['name' => 'account_permission_category', 'type' => 'int', 'internal' => 'category'],
'account_permission_element' => ['name' => 'account_permission_element', 'type' => 'int', 'internal' => 'element'],
'account_permission_component' => ['name' => 'account_permission_component', 'type' => 'int', 'internal' => 'component'],
'account_permission_hasread' => ['name' => 'account_permission_hasread', 'type' => 'bool', 'internal' => 'hasRead'],
'account_permission_hascreate' => ['name' => 'account_permission_hascreate', 'type' => 'bool', 'internal' => 'hasCreate'],
'account_permission_defaultcperm' => ['name' => 'account_permission_defaultcperm', 'type' => 'string', 'internal' => 'defaultCPermissions'],
'account_permission_hasmodify' => ['name' => 'account_permission_hasmodify', 'type' => 'bool', 'internal' => 'hasModify'],
'account_permission_hasdelete' => ['name' => 'account_permission_hasdelete', 'type' => 'bool', 'internal' => 'hasDelete'],
'account_permission_haspermission' => ['name' => 'account_permission_haspermission', 'type' => 'bool', 'internal' => 'hasPermission'],
'account_permission_defaultpperm' => ['name' => 'account_permission_defaultpperm', 'type' => 'string', 'internal' => 'defaultPPermissions'],
];
/**

View File

@ -81,10 +81,10 @@ class App implements \JsonSerializable
public function toArray() : array
{
return [
'id' => $this->id,
'name' => $this->name,
'type' => $this->type,
'status' => $this->status,
'id' => $this->id,
'name' => $this->name,
'type' => $this->type,
'status' => $this->status,
];
}

View File

@ -36,12 +36,12 @@ final class AppMapper extends DataMapperFactory
* @since 1.0.0
*/
public const COLUMNS = [
'app_id' => ['name' => 'app_id', 'type' => 'int', 'internal' => 'id'],
'app_name' => ['name' => 'app_name', 'type' => 'string', 'internal' => 'name'],
'app_theme' => ['name' => 'app_theme', 'type' => 'string', 'internal' => 'theme'],
'app_status' => ['name' => 'app_status', 'type' => 'int', 'internal' => 'status'],
'app_type' => ['name' => 'app_type', 'type' => 'int', 'internal' => 'type'],
'app_unit_default' => ['name' => 'app_unit_default', 'type' => 'int', 'internal' => 'defaultUnit'],
'app_id' => ['name' => 'app_id', 'type' => 'int', 'internal' => 'id'],
'app_name' => ['name' => 'app_name', 'type' => 'string', 'internal' => 'name'],
'app_theme' => ['name' => 'app_theme', 'type' => 'string', 'internal' => 'theme'],
'app_status' => ['name' => 'app_status', 'type' => 'int', 'internal' => 'status'],
'app_type' => ['name' => 'app_type', 'type' => 'int', 'internal' => 'type'],
'app_unit_default' => ['name' => 'app_unit_default', 'type' => 'int', 'internal' => 'defaultUnit'],
];
/**

View File

@ -50,6 +50,8 @@ class Contact
*/
public int $subtype = 0;
public string $title = '';
/**
* Content.
*
@ -57,80 +59,4 @@ class Contact
* @since 1.0.0
*/
public string $content = '';
/**
* Order.
*
* @var int
* @since 1.0.0
*/
public int $order = 0;
public int $account = 0;
public string $module = '';
/**
* Get id.
*
* @return int Model id
*
* @since 1.0.0
*/
public function getId() : int
{
return $this->id;
}
/**
* Set type
*
* @param int $type Type
*
* @return void
*
* @since 1.0.0
*/
public function setType(int $type) : void
{
$this->type = $type;
}
/**
* Get type
*
* @return int
*
* @since 1.0.0
*/
public function getType() : int
{
return $this->type;
}
/**
* Set subtype
*
* @param int $subtype Subtype
*
* @return void
*
* @since 1.0.0
*/
public function setSubtype(int $subtype) : void
{
$this->subtype = $subtype;
}
/**
* Get subtype
*
* @return int
*
* @since 1.0.0
*/
public function getSubtype() : int
{
return $this->subtype;
}
}

View File

@ -36,13 +36,11 @@ final class ContactMapper extends DataMapperFactory
* @since 1.0.0
*/
public const COLUMNS = [
'account_contact_id' => ['name' => 'account_contact_id', 'type' => 'int', 'internal' => 'id'],
'account_contact_type' => ['name' => 'account_contact_type', 'type' => 'int', 'internal' => 'type'],
'account_contact_subtype' => ['name' => 'account_contact_subtype', 'type' => 'int', 'internal' => 'subtype'],
'account_contact_order' => ['name' => 'account_contact_order', 'type' => 'int', 'internal' => 'order'],
'account_contact_content' => ['name' => 'account_contact_content', 'type' => 'string', 'internal' => 'content'],
'account_contact_module' => ['name' => 'account_contact_module', 'type' => 'string', 'internal' => 'module'],
'account_contact_account' => ['name' => 'account_contact_account', 'type' => 'int', 'internal' => 'account'],
'contact_id' => ['name' => 'contact_id', 'type' => 'int', 'internal' => 'id'],
'contact_title' => ['name' => 'contact_title', 'type' => 'string', 'internal' => 'title'],
'contact_type' => ['name' => 'contact_type', 'type' => 'int', 'internal' => 'type'],
'contact_subtype' => ['name' => 'contact_subtype', 'type' => 'int', 'internal' => 'subtype'],
'contact_content' => ['name' => 'contact_content', 'type' => 'string', 'internal' => 'content'],
];
/**
@ -51,7 +49,7 @@ final class ContactMapper extends DataMapperFactory
* @var string
* @since 1.0.0
*/
public const TABLE = 'account_contact';
public const TABLE = 'contact';
/**
* Primary field name.
@ -59,5 +57,5 @@ final class ContactMapper extends DataMapperFactory
* @var string
* @since 1.0.0
*/
public const PRIMARYFIELD = 'account_contact_id';
public const PRIMARYFIELD = 'contact_id';
}

View File

@ -113,8 +113,8 @@ class DataChange
public function toArray() : array
{
return [
'id' => $this->id,
'data' => $this->data,
'id' => $this->id,
'data' => $this->data,
];
}

View File

@ -54,13 +54,13 @@ class GroupPermission extends PermissionAbstract
*/
public function __construct(
int $group = 0,
int $unit = null,
int $app = null,
string $module = null,
string $from = null,
int $category = null,
int $element = null,
int $component = null,
?int $unit = null,
?int $app = null,
?string $module = null,
?string $from = null,
?int $category = null,
?int $element = null,
?int $component = null,
int $permission = PermissionType::NONE
) {
$this->group = $group;

View File

@ -36,22 +36,22 @@ final class GroupPermissionMapper extends DataMapperFactory
* @since 1.0.0
*/
public const COLUMNS = [
'group_permission_id' => ['name' => 'group_permission_id', 'type' => 'int', 'internal' => 'id'],
'group_permission_group' => ['name' => 'group_permission_group', 'type' => 'int', 'internal' => 'group'],
'group_permission_unit' => ['name' => 'group_permission_unit', 'type' => 'int', 'internal' => 'unit'],
'group_permission_app' => ['name' => 'group_permission_app', 'type' => 'int', 'internal' => 'app'],
'group_permission_module' => ['name' => 'group_permission_module', 'type' => 'string', 'internal' => 'module'],
'group_permission_from' => ['name' => 'group_permission_from', 'type' => 'string', 'internal' => 'from'],
'group_permission_category' => ['name' => 'group_permission_category', 'type' => 'int', 'internal' => 'category'],
'group_permission_element' => ['name' => 'group_permission_element', 'type' => 'int', 'internal' => 'element'],
'group_permission_component' => ['name' => 'group_permission_component', 'type' => 'int', 'internal' => 'component'],
'group_permission_hasread' => ['name' => 'group_permission_hasread', 'type' => 'bool', 'internal' => 'hasRead'],
'group_permission_hascreate' => ['name' => 'group_permission_hascreate', 'type' => 'bool', 'internal' => 'hasCreate'],
'group_permission_defaultcperm' => ['name' => 'group_permission_defaultcperm', 'type' => 'string', 'internal' => 'defaultCPermissions'],
'group_permission_hasmodify' => ['name' => 'group_permission_hasmodify', 'type' => 'bool', 'internal' => 'hasModify'],
'group_permission_hasdelete' => ['name' => 'group_permission_hasdelete', 'type' => 'bool', 'internal' => 'hasDelete'],
'group_permission_haspermission' => ['name' => 'group_permission_haspermission', 'type' => 'bool', 'internal' => 'hasPermission'],
'group_permission_defaultpperm' => ['name' => 'group_permission_defaultpperm', 'type' => 'string', 'internal' => 'defaultPPermissions'],
'group_permission_id' => ['name' => 'group_permission_id', 'type' => 'int', 'internal' => 'id'],
'group_permission_group' => ['name' => 'group_permission_group', 'type' => 'int', 'internal' => 'group'],
'group_permission_unit' => ['name' => 'group_permission_unit', 'type' => 'int', 'internal' => 'unit'],
'group_permission_app' => ['name' => 'group_permission_app', 'type' => 'int', 'internal' => 'app'],
'group_permission_module' => ['name' => 'group_permission_module', 'type' => 'string', 'internal' => 'module'],
'group_permission_from' => ['name' => 'group_permission_from', 'type' => 'string', 'internal' => 'from'],
'group_permission_category' => ['name' => 'group_permission_category', 'type' => 'int', 'internal' => 'category'],
'group_permission_element' => ['name' => 'group_permission_element', 'type' => 'int', 'internal' => 'element'],
'group_permission_component' => ['name' => 'group_permission_component', 'type' => 'int', 'internal' => 'component'],
'group_permission_hasread' => ['name' => 'group_permission_hasread', 'type' => 'bool', 'internal' => 'hasRead'],
'group_permission_hascreate' => ['name' => 'group_permission_hascreate', 'type' => 'bool', 'internal' => 'hasCreate'],
'group_permission_defaultcperm' => ['name' => 'group_permission_defaultcperm', 'type' => 'string', 'internal' => 'defaultCPermissions'],
'group_permission_hasmodify' => ['name' => 'group_permission_hasmodify', 'type' => 'bool', 'internal' => 'hasModify'],
'group_permission_hasdelete' => ['name' => 'group_permission_hasdelete', 'type' => 'bool', 'internal' => 'hasDelete'],
'group_permission_haspermission' => ['name' => 'group_permission_haspermission', 'type' => 'bool', 'internal' => 'hasPermission'],
'group_permission_defaultpperm' => ['name' => 'group_permission_defaultpperm', 'type' => 'string', 'internal' => 'defaultPPermissions'],
];
/**

View File

@ -99,23 +99,23 @@ final class LocalizationMapper extends DataMapperFactory
* @since 1.0.0
*/
public const OWNS_ONE = [
'country' => [
'mapper' => CountryMapper::class,
'external' => 'l11n_country',
'by' => 'code2',
'column' => 'code2',
'country' => [
'mapper' => CountryMapper::class,
'external' => 'l11n_country',
'by' => 'code2',
'column' => 'code2',
],
'language' => [
'mapper' => LanguageMapper::class,
'external' => 'l11n_language',
'by' => 'code2',
'column' => 'code2',
'language' => [
'mapper' => LanguageMapper::class,
'external' => 'l11n_language',
'by' => 'code2',
'column' => 'code2',
],
'currency' => [
'mapper' => CurrencyMapper::class,
'external' => 'l11n_currency',
'by' => 'code',
'column' => 'code',
'currency' => [
'mapper' => CurrencyMapper::class,
'external' => 'l11n_currency',
'by' => 'code',
'column' => 'code',
],
];

View File

@ -15,7 +15,6 @@ declare(strict_types=1);
namespace Modules\Admin\Models;
use phpOMS\Module\ModuleStatus;
use phpOMS\Stdlib\Base\Exception\InvalidEnumValue;
/**
* Module class.
@ -93,50 +92,6 @@ class Module
$this->createdAt = new \DateTimeImmutable('now');
}
/**
* Get module id.
*
* @return string
*
* @since 1.0.0
*/
public function getId() : string
{
return $this->id;
}
/**
* Get module status.
*
* @return int Module status
*
* @since 1.0.0
*/
public function getStatus() : int
{
return $this->status;
}
/**
* Set module status.
*
* @param int $status Module status
*
* @return void
*
* @throws InvalidEnumValue
*
* @since 1.0.0
*/
public function setStatus(int $status) : void
{
if (!ModuleStatusUpdateType::isValidValue($status)) {
throw new InvalidEnumValue($status);
}
$this->status = $status;
}
/**
* Get string representation.
*
@ -163,12 +118,12 @@ class Module
public function toArray() : array
{
return [
'id' => $this->id,
'name' => $this->name,
'path' => $this->path,
'version' => $this->version,
'status' => $this->status,
'createdAt' => $this->createdAt,
'id' => $this->id,
'name' => $this->name,
'path' => $this->path,
'version' => $this->version,
'status' => $this->status,
'createdAt' => $this->createdAt,
];
}
}

46
Models/NullContact.php Normal file
View File

@ -0,0 +1,46 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\Admin\Models
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\Admin\Models;
/**
* Null model
*
* @package Modules\Admin\Models
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*/
final class NullContact extends Contact
{
/**
* Constructor
*
* @param int $id Model id
*
* @since 1.0.0
*/
public function __construct(int $id = 0)
{
$this->id = $id;
}
/**
* {@inheritdoc}
*/
public function jsonSerialize() : mixed
{
return ['id' => $this->id];
}
}

View File

@ -44,5 +44,9 @@ abstract class PermissionCategory extends Enum
public const SEARCH = 9;
public const API = 9;
public const API = 10;
public const ADDRESS = 11;
public const CONTACT = 12;
}

View File

@ -59,7 +59,7 @@ class BaseView extends View
/**
* {@inheritdoc}
*/
public function __construct(L11nManager $l11n = null, RequestAbstract $request, ResponseAbstract $response)
public function __construct(?L11nManager $l11n = null, RequestAbstract $request, ResponseAbstract $response)
{
parent::__construct($l11n, $request, $response);
$this->setTemplate('/Modules/Admin/Theme/Backend/Components/AccountPermissionSelector/account-permission-selector');

View File

@ -39,15 +39,31 @@ class AddressView extends View
public array $addresses = [];
/**
* Units
* Form id
*
* @var \Modules\Organization\Models\Unit[]
* @var string
* @since 1.0.0
*/
public array $units = [];
public string $form = '';
/**
* API Uri for address actions
* Virtual path of the media file
*
* @var string
* @since 1.0.0
*/
public string $virtualPath = '';
/**
* Name of the image preview
*
* @var string
* @since 1.0.0
*/
public string $name = '';
/**
* API Uri for attribute actions
*
* @var string
* @since 1.0.0
@ -65,7 +81,7 @@ class AddressView extends View
/**
* {@inheritdoc}
*/
public function __construct(L11nManager $l11n = null, RequestAbstract $request, ResponseAbstract $response)
public function __construct(?L11nManager $l11n = null, RequestAbstract $request, ResponseAbstract $response)
{
parent::__construct($l11n, $request, $response);
$this->setTemplate('/Modules/Admin/Theme/Backend/Components/AddressEditor/addresses');
@ -76,11 +92,10 @@ class AddressView extends View
*/
public function render(mixed ...$data) : string
{
/** @var array{0:\phpOMS\Stdlib\Base\Address[]} $data */
$this->addresses = $data[0];
$this->units = $data[1];
$this->apiUri = $data[2];
$this->refId = $data[3];
/** @var array{0:string, 1?:string, 2?:array} $data */
$this->form = $data[0];
$this->virtualPath = $data[1] ?? $this->virtualPath;
$this->addresses = $data[2] ?? $this->addresses;
return parent::render();
}

View File

@ -4,7 +4,7 @@
*
* PHP Version 8.1
*
* @package Modules\Admin
* @package Modules\Address
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
@ -16,120 +16,162 @@ use phpOMS\Localization\ISO639Enum;
use phpOMS\Stdlib\Base\AddressType;
use phpOMS\Uri\UriFactory;
$address = $this->addresses;
$address = $this->addresses;
$languages = ISO639Enum::getConstants();
$types = AddressType::getConstants();
$units = $this->units;
?>
<div class="col-xs-12 col-md-6">
<section class="portlet">
<form id="addressForm" action="<?= UriFactory::build($this->apiUri); ?>" method="post"
data-ui-container="#addressTable tbody"
data-add-form="addressForm"
data-add-tpl="#addressTable tbody .oms-add-tpl-address">
<div class="portlet-head"><?= $this->getHtml('Address', 'Admin', 'Backend'); ?></div>
<div class="portlet-body">
<input type="hidden" id="iAddressRef" name="ref" value="<?= $this->refId; ?>" disabled>
<div class="row">
<div class="col-xs-12 col-md-6">
<section class="portlet">
<form id="addressForm" action="<?= UriFactory::build('{api}account/address'); ?>" method="post"
data-ui-container="#addressTable tbody"
data-add-form="addressForm"
data-add-tpl="#addressTable tbody .oms-add-tpl-address">
<div class="portlet-head"><?= $this->getHtml('Address', 'Admin', 'Backend'); ?></div>
<div class="portlet-body">
<input type="hidden" id="iAddressRef" name="account" value="<?= $this->refId; ?>" disabled>
<div class="form-group">
<label for="iAddressId"><?= $this->getHtml('ID', '0', '0'); ?></label>
<input type="text" id="iAddressId" name="id" data-tpl-text="/id" data-tpl-value="/id" disabled>
</div>
<div class="form-group">
<label for="iAddressId"><?= $this->getHtml('ID', '0', '0'); ?></label>
<input type="text" id="iAddressId" name="id" data-tpl-text="/id" data-tpl-value="/id" disabled>
</div>
<div class="form-group">
<label for="iAddressType"><?= $this->getHtml('Type', 'Admin', 'Backend'); ?></label>
<select id="iAddressType" name="type" data-tpl-text="/type" data-tpl-value="/type">
<div class="form-group">
<label for="iAddressName"><?= $this->getHtml('Name', 'Admin', 'Backend'); ?></label>
<input type="text" id="iAddressName" name="name" data-tpl-text="/name" data-tpl-value="/name">
</div>
<div class="form-group">
<label for="iAddressFao"><?= $this->getHtml('FAO', 'Admin', 'Backend'); ?></label>
<input type="text" id="iAddressFao" name="fao" data-tpl-text="/fao" data-tpl-value="/fao">
</div>
<div class="form-group">
<label for="iAddressAddress"><?= $this->getHtml('Address', 'Admin', 'Backend'); ?></label>
<input type="text" id="iAddressAddress" name="address" data-tpl-text="/address" data-tpl-value="/address">
</div>
<div class="form-group">
<label for="iAddressAddition"><?= $this->getHtml('Addition', 'Admin', 'Backend'); ?></label>
<input type="text" id="iAddressAddition" name="addition" data-tpl-text="/addition" data-tpl-value="/addition">
</div>
<div class="form-group">
<label for="iAddressPostal"><?= $this->getHtml('Postal', 'Admin', 'Backend'); ?></label>
<input type="text" id="iAddressPostal" name="postal" data-tpl-text="/postal" data-tpl-value="/postal">
</div>
<div class="form-group">
<label for="iAddressCity"><?= $this->getHtml('City', 'Admin', 'Backend'); ?></label>
<input type="text" id="iAddressCity" name="city" data-tpl-text="/city" data-tpl-value="/city">
</div>
<div class="form-group">
<label for="iAddressState"><?= $this->getHtml('State', 'Admin', 'Backend'); ?></label>
<input type="text" id="iAddressState" name="state" data-tpl-text="/state" data-tpl-value="/state">
</div>
<div class="form-group">
<label for="iAddressCountry"><?= $this->getHtml('Country', 'Admin', 'Backend'); ?></label>
<input type="text" id="iAddressCountry" name="country" data-tpl-text="/country" data-tpl-value="/country">
</div>
<div class="form-group">
<label for="iAddressesType"><?= $this->getHtml('Type', 'Admin', 'Backend'); ?></label>
<select id="iAddressesType" name="type" data-tpl-text="/type" data-tpl-value="/type">
<?php
foreach ($types as $type) : ?>
<option value="<?= $type->id; ?>"><?= $this->printHtml($type->getL11n()); ?>
<?php endforeach; ?>
</select>
foreach ($types as $type) : ?>
<option value="<?= $type; ?>"><?= $this->getHtml(':address' . $type); ?>
<?php endforeach; ?>
</select>
</div>
</div>
<!-- @todo implement
<div class="form-group">
<label for="iAddressUnit"><?= $this->getHtml('Unit', 'Admin', 'Backend'); ?></label>
<select id="iAddressUnit" name="unit" data-tpl-text="/unit" data-tpl-value="/unit">
<option value="">
<?php
foreach ($units as $unit) : ?>
<option value="<?= $unit->id; ?>"><?= $this->printHtml($unit->name); ?>
<?php endforeach; ?>
</select>
<div class="portlet-foot">
<input id="bAddressAdd" formmethod="put" type="submit" class="add-form" value="<?= $this->getHtml('Add', '0', '0'); ?>">
<input id="bAddressSave" formmethod="post" type="submit" class="save-form hidden button save" value="<?= $this->getHtml('Update', '0', '0'); ?>">
<input id="bAddressCancel" type="submit" class="cancel-form hidden button close" value="<?= $this->getHtml('Cancel', '0', '0'); ?>">
</div>
-->
</form>
</section>
</div>
<div class="form-group">
<label for="iAddressValue"><?= $this->getHtml('Value', 'Admin', 'Backend'); ?></label>
<pre class="textarea contenteditable" id="iAddressValue" data-name="value" data-tpl-value="/value" contenteditable></pre>
</div>
</div>
<div class="portlet-foot">
<input id="bAddressAdd" formmethod="put" type="submit" class="add-form" value="<?= $this->getHtml('Add', '0', '0'); ?>">
<input id="bAddressSave" formmethod="post" type="submit" class="save-form hidden button save" value="<?= $this->getHtml('Update', '0', '0'); ?>">
<input id="bAddressCancel" type="submit" class="cancel-form hidden button close" value="<?= $this->getHtml('Cancel', '0', '0'); ?>">
</div>
</form>
</section>
</div>
<div class="col-xs-12 col-md-6">
<section class="portlet">
<div class="portlet-head"><?= $this->getHtml('Address', 'Admin', 'Backend'); ?><i class="g-icon download btn end-xs">download</i></div>
<div class="slider">
<table id="addressTable" class="default sticky"
data-tag="form"
data-ui-element="tr"
data-add-tpl=".oms-add-tpl-address"
data-update-form="addressForm">
<thead>
<tr>
<td>
<td><?= $this->getHtml('ID', '0', '0'); ?>
<td><?= $this->getHtml('Name', 'Admin', 'Backend'); ?><i class="sort-asc g-icon">expand_less</i><i class="sort-desc g-icon">expand_more</i>
<td class="wf-100"><?= $this->getHtml('Value', 'Admin', 'Backend'); ?><i class="sort-asc g-icon">expand_less</i><i class="sort-desc g-icon">expand_more</i>
<td><?= $this->getHtml('Unit', 'Admin', 'Backend'); ?><i class="sort-asc g-icon">expand_less</i><i class="sort-desc g-icon">expand_more</i>
<tbody>
<template class="oms-add-tpl-address">
<tr class="animated medium-duration greenCircleFade" data-id="" draggable="false">
<div class="col-xs-12 col-md-6">
<section class="portlet">
<div class="portlet-head"><?= $this->getHtml('Addresses', 'Admin', 'Backend'); ?><i class="g-icon download btn end-xs">download</i></div>
<div class="slider">
<table id="addressTable" class="default sticky"
data-tag="form"
data-ui-element="tr"
data-add-tpl=".oms-add-tpl-address"
data-update-form="addressForm">
<thead>
<tr>
<td>
<i class="g-icon btn update-form">settings</i>
<input id="addressTable-remove-0" type="checkbox" class="hidden">
<label for="addressTable-remove-0" class="checked-visibility-alt"><i class="g-icon btn form-action">close</i></label>
<span class="checked-visibility">
<label for="addressTable-remove-0" class="link default"><?= $this->getHtml('Cancel', '0', '0'); ?></label>
<label for="addressTable-remove-0" class="remove-form link cancel"><?= $this->getHtml('Delete', '0', '0'); ?></label>
</span>
<td data-tpl-text="/id" data-tpl-value="/id"></td>
<td data-tpl-text="/type" data-tpl-value="/type" data-value=""></td>
<td data-tpl-text="/value" data-tpl-value="/value"></td>
<td data-tpl-text="/unit" data-tpl-value="/unit"></td>
</tr>
</template>
<?php $c = 0;
foreach ($address as $key => $value) : ++$c; ?>
<td><?= $this->getHtml('ID', '0', '0'); ?>
<td><?= $this->getHtml('Type', 'Admin', 'Backend'); ?><i class="sort-asc g-icon">expand_less</i><i class="sort-desc g-icon">expand_more</i>
<td><?= $this->getHtml('Name', 'Admin', 'Backend'); ?><i class="sort-asc g-icon">expand_less</i><i class="sort-desc g-icon">expand_more</i>
<td><?= $this->getHtml('FAO', 'Admin', 'Backend'); ?><i class="sort-asc g-icon">expand_less</i><i class="sort-desc g-icon">expand_more</i>
<td><?= $this->getHtml('Address', 'Admin', 'Backend'); ?><i class="sort-asc g-icon">expand_less</i><i class="sort-desc g-icon">expand_more</i>
<td><?= $this->getHtml('Addition', 'Admin', 'Backend'); ?><i class="sort-asc g-icon">expand_less</i><i class="sort-desc g-icon">expand_more</i>
<td><?= $this->getHtml('Postal', 'Admin', 'Backend'); ?><i class="sort-asc g-icon">expand_less</i><i class="sort-desc g-icon">expand_more</i>
<td><?= $this->getHtml('City', 'Admin', 'Backend'); ?><i class="sort-asc g-icon">expand_less</i><i class="sort-desc g-icon">expand_more</i>
<td><?= $this->getHtml('State', 'Admin', 'Backend'); ?><i class="sort-asc g-icon">expand_less</i><i class="sort-desc g-icon">expand_more</i>
<td><?= $this->getHtml('Country', 'Admin', 'Backend'); ?><i class="sort-asc g-icon">expand_less</i><i class="sort-desc g-icon">expand_more</i>
<tbody>
<template class="oms-add-tpl-address">
<tr class="animated medium-duration greenCircleFade" data-id="" draggable="false">
<td>
<i class="g-icon btn update-form">settings</i>
<input id="addressTable-remove-0" type="checkbox" class="hidden">
<label for="addressTable-remove-0" class="checked-visibility-alt"><i class="g-icon btn form-action">close</i></label>
<span class="checked-visibility">
<label for="addressTable-remove-0" class="link default"><?= $this->getHtml('Cancel', '0', '0'); ?></label>
<label for="addressTable-remove-0" class="remove-form link cancel"><?= $this->getHtml('Delete', '0', '0'); ?></label>
</span>
<td data-tpl-text="/id" data-tpl-value="/id"></td>
<td data-tpl-text="/type" data-tpl-value="/type" data-value=""></td>
<td data-tpl-text="/name" data-tpl-value="/name"></td>
<td data-tpl-text="/fao" data-tpl-value="/fao"></td>
<td data-tpl-text="/address" data-tpl-value="/address"></td>
<td data-tpl-text="/addition" data-tpl-value="/addition"></td>
<td data-tpl-text="/postal" data-tpl-value="/postal"></td>
<td data-tpl-text="/city" data-tpl-value="/city"></td>
<td data-tpl-text="/state" data-tpl-value="/state"></td>
<td data-tpl-text="/country" data-tpl-value="/country"></td>
</tr>
</template>
<?php
$c = 0;
foreach ($address as $key => $value) :
++$c;
?>
<tr data-id="<?= $value->id; ?>">
<td>
<i class="g-icon btn update-form">settings</i>
<?php if (!$value->type->isRequired) : ?>
<input id="addressTable-remove-<?= $value->id; ?>" type="checkbox" class="hidden">
<label for="addressTable-remove-<?= $value->id; ?>" class="checked-visibility-alt"><i class="g-icon btn form-action">close</i></label>
<span class="checked-visibility">
<label for="addressTable-remove-<?= $value->id; ?>" class="link default"><?= $this->getHtml('Cancel', '0', '0'); ?></label>
<label for="addressTable-remove-<?= $value->id; ?>" class="remove-form link cancel"><?= $this->getHtml('Delete', '0', '0'); ?></label>
</span>
<?php endif; ?>
<td data-tpl-text="/id" data-tpl-value="/id"><?= $value->id; ?>
<td data-tpl-text="/type" data-tpl-value="/type" data-value="<?= $value->type->id; ?>"><?= $this->printHtml($value->type->getL11n()); ?>
<td data-tpl-text="/value" data-tpl-value="/value"><?= $value->value->getValue() instanceof \DateTime ? $value->value->getValue()->format('Y-m-d') : $this->printHtml((string) $value->value->getValue()); ?>
<td data-tpl-text="/unit" data-tpl-value="/unit" data-value="<?= $value->value->unit; ?>"><?= $this->printHtml($value->value->unit); ?>
<?php endforeach; ?>
<?php if ($c === 0) : ?>
<tr>
<td colspan="5" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>
<?php endif; ?>
</table>
</div>
</section>
<td data-tpl-text="/type" data-tpl-value="/type" data-value="<?= $value->type; ?>"><?= $this->getHtml(':address' . $value->type, 'Admin', 'Backend'); ?>
<td data-tpl-text="/name" data-tpl-value="/name"><?= $this->printHtml($value->name); ?>
<td data-tpl-text="/fao" data-tpl-value="/fao"><?= $this->printHtml($value->fao); ?>
<td data-tpl-text="/address" data-tpl-value="/address"><?= $this->printHtml($value->address); ?>
<td data-tpl-text="/addition" data-tpl-value="/addition"><?= $this->printHtml($value->addressAddition); ?>
<td data-tpl-text="/postal" data-tpl-value="/postal"><?= $this->printHtml($value->postal); ?>
<td data-tpl-text="/city" data-tpl-value="/city"><?= $this->printHtml($value->city); ?>
<td data-tpl-text="/state" data-tpl-value="/state"><?= $this->printHtml($value->state); ?>
<td data-tpl-text="/country" data-tpl-value="/country"><?= $this->printHtml($value->country); ?>
<?php endforeach; ?>
<?php if ($c === 0) : ?>
<tr>
<td colspan="11" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>
<?php endif; ?>
</table>
</div>
</section>
</div>
</div>

View File

@ -0,0 +1,102 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\Admin
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\Admin\Theme\Backend\Components\ContactEditor;
use phpOMS\Localization\L11nManager;
use phpOMS\Message\RequestAbstract;
use phpOMS\Message\ResponseAbstract;
use phpOMS\Views\View;
/**
* Component view.
*
* @package Modules\Admin
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
* @codeCoverageIgnore
*/
class ContactView extends View
{
/**
* Contact
*
* @var Modules\Admin\Models\Contact[]
* @since 1.0.0
*/
public array $contacts = [];
/**
* Form id
*
* @var string
* @since 1.0.0
*/
public string $form = '';
/**
* Virtual path of the media file
*
* @var string
* @since 1.0.0
*/
public string $virtualPath = '';
/**
* Name of the image preview
*
* @var string
* @since 1.0.0
*/
public string $name = '';
/**
* API Uri for attribute actions
*
* @var string
* @since 1.0.0
*/
public string $apiUri = '';
/**
* Reference id
*
* @var string
* @since 1.0.0
*/
public int $refId = 0;
/**
* {@inheritdoc}
*/
public function __construct(?L11nManager $l11n = null, RequestAbstract $request, ResponseAbstract $response)
{
parent::__construct($l11n, $request, $response);
$this->setTemplate('/Modules/Admin/Theme/Backend/Components/ContactEditor/contacts');
}
/**
* {@inheritdoc}
*/
public function render(mixed ...$data) : string
{
/** @var array{0:string, 1?:string, 2?:array} $data */
$this->form = $data[0];
$this->virtualPath = $data[1] ?? $this->virtualPath;
$this->contacts = $data[2] ?? $this->contacts;
return parent::render();
}
}

View File

@ -0,0 +1,140 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\Contact
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
use Modules\Admin\Models\ContactType;
use phpOMS\Localization\ISO639Enum;
use phpOMS\Stdlib\Base\AddressType;
use phpOMS\Uri\UriFactory;
$contact = $this->contacts;
$languages = ISO639Enum::getConstants();
$types = ContactType::getConstants();
$subtypes = AddressType::getConstants();
?>
<div class="row">
<div class="col-xs-12 col-md-6">
<section class="portlet">
<form id="contactForm" action="<?= UriFactory::build('{api}account/contact'); ?>" method="post"
data-ui-container="#contactTable tbody"
data-add-form="contactForm"
data-add-tpl="#contactTable tbody .oms-add-tpl-contact">
<div class="portlet-head"><?= $this->getHtml('Contact', 'Admin', 'Backend'); ?></div>
<div class="portlet-body">
<input type="hidden" id="iContactRef" name="account" value="<?= $this->refId; ?>" disabled>
<div class="form-group">
<label for="iContactId"><?= $this->getHtml('ID', '0', '0'); ?></label>
<input type="text" id="iContactId" name="id" data-tpl-text="/id" data-tpl-value="/id" disabled>
</div>
<div class="form-group">
<label for="iContactName"><?= $this->getHtml('Name', 'Admin', 'Backend'); ?></label>
<input type="text" id="iContactName" name="name" data-tpl-text="/name" data-tpl-value="/name">
</div>
<div class="form-group">
<label for="iContactsType"><?= $this->getHtml('Type', 'Admin', 'Backend'); ?></label>
<select id="iContactsType" name="type" data-tpl-text="/type" data-tpl-value="/type">
<?php
foreach ($types as $type) : ?>
<option value="<?= $type; ?>"><?= $this->getHtml(':contact' . $type); ?>
<?php endforeach; ?>
</select>
</div>
<div class="form-group">
<label for="iContactsSubtype"><?= $this->getHtml('Subtype', 'Admin', 'Backend'); ?></label>
<select id="iContactsSubtype" name="subtype" data-tpl-text="/subtype" data-tpl-value="/subtype">
<?php
foreach ($subtypes as $type) : ?>
<option value="<?= $type; ?>"><?= $this->getHtml(':address' . $type); ?>
<?php endforeach; ?>
</select>
</div>
<div class="form-group">
<label for="iContactContent"><?= $this->getHtml('Contact', 'Admin', 'Backend'); ?></label>
<input type="text" id="iContactContent" name="content" data-tpl-text="/content" data-tpl-value="/content">
</div>
</div>
<div class="portlet-foot">
<input id="bContactAdd" formmethod="put" type="submit" class="add-form" value="<?= $this->getHtml('Add', '0', '0'); ?>">
<input id="bContactSave" formmethod="post" type="submit" class="save-form hidden button save" value="<?= $this->getHtml('Update', '0', '0'); ?>">
<input id="bContactCancel" type="submit" class="cancel-form hidden button close" value="<?= $this->getHtml('Cancel', '0', '0'); ?>">
</div>
</form>
</section>
</div>
<div class="col-xs-12 col-md-6">
<section class="portlet">
<div class="portlet-head"><?= $this->getHtml('Contacts', 'Admin', 'Backend'); ?><i class="g-icon download btn end-xs">download</i></div>
<div class="slider">
<table id="contactTable" class="default sticky"
data-tag="form"
data-ui-element="tr"
data-add-tpl=".oms-add-tpl-contact"
data-update-form="contactForm">
<thead>
<tr>
<td>
<td><?= $this->getHtml('ID', '0', '0'); ?>
<td><?= $this->getHtml('Type', 'Admin', 'Backend'); ?><i class="sort-asc g-icon">expand_less</i><i class="sort-desc g-icon">expand_more</i>
<td><?= $this->getHtml('Subtype', 'Admin', 'Backend'); ?><i class="sort-asc g-icon">expand_less</i><i class="sort-desc g-icon">expand_more</i>
<td><?= $this->getHtml('Name', 'Admin', 'Backend'); ?><i class="sort-asc g-icon">expand_less</i><i class="sort-desc g-icon">expand_more</i>
<td><?= $this->getHtml('Content', 'Admin', 'Backend'); ?><i class="sort-asc g-icon">expand_less</i><i class="sort-desc g-icon">expand_more</i>
<tbody>
<template class="oms-add-tpl-contact">
<tr class="animated medium-duration greenCircleFade" data-id="" draggable="false">
<td>
<i class="g-icon btn update-form">settings</i>
<input id="contactTable-remove-0" type="checkbox" class="hidden">
<label for="contactTable-remove-0" class="checked-visibility-alt"><i class="g-icon btn form-action">close</i></label>
<span class="checked-visibility">
<label for="contactTable-remove-0" class="link default"><?= $this->getHtml('Cancel', '0', '0'); ?></label>
<label for="contactTable-remove-0" class="remove-form link cancel"><?= $this->getHtml('Delete', '0', '0'); ?></label>
</span>
<td data-tpl-text="/id" data-tpl-value="/id"></td>
<td data-tpl-text="/type" data-tpl-value="/type" data-value=""></td>
<td data-tpl-text="/subtype" data-tpl-value="/subtype" data-value=""></td>
<td data-tpl-text="/name" data-tpl-value="/name"></td>
<td data-tpl-text="/content" data-tpl-value="/content"></td>
</tr>
</template>
<?php $c = 0;
foreach ($contact as $key => $value) : ++$c; ?>
<tr data-id="<?= $value->id; ?>">
<td>
<i class="g-icon btn update-form">settings</i>
<input id="contactTable-remove-<?= $value->id; ?>" type="checkbox" class="hidden">
<label for="contactTable-remove-<?= $value->id; ?>" class="checked-visibility-alt"><i class="g-icon btn form-action">close</i></label>
<span class="checked-visibility">
<label for="contactTable-remove-<?= $value->id; ?>" class="link default"><?= $this->getHtml('Cancel', '0', '0'); ?></label>
<label for="contactTable-remove-<?= $value->id; ?>" class="remove-form link cancel"><?= $this->getHtml('Delete', '0', '0'); ?></label>
</span>
<td data-tpl-text="/id" data-tpl-value="/id"><?= $value->id; ?>
<td data-tpl-text="/type" data-tpl-value="/type" data-value="<?= $value->type; ?>"><?= $this->getHtml(':contact' . $value->type, 'Admin', 'Backend'); ?>
<td data-tpl-text="/subtype" data-tpl-value="/subtype" data-value="<?= $value->subtype; ?>"><?= $this->getHtml(':address' . $value->subtype, 'Admin', 'Backend'); ?>
<td data-tpl-text="/name" data-tpl-value="/name"><?= $this->printHtml($value->title); ?>
<td data-tpl-text="/content" data-tpl-value="/content"><?= $this->printHtml($value->content); ?>
<?php endforeach; ?>
<?php if ($c === 0) : ?>
<tr><td colspan="11" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>
<?php endif; ?>
</table>
</div>
</section>
</div>
</div>

View File

@ -41,38 +41,12 @@ class GroupTagSelectorPopupView extends View
/**
* {@inheritdoc}
*/
public function __construct(L11nManager $l11n = null, RequestAbstract $request, ResponseAbstract $response)
public function __construct(?L11nManager $l11n = null, RequestAbstract $request, ResponseAbstract $response)
{
parent::__construct($l11n, $request, $response);
$this->setTemplate('/Modules/Admin/Theme/Backend/Components/GroupTagSelector/group-selector-popup');
}
/**
* Set selector id
*
* @param string $id Id
*
* @return void
*
* @since 1.0.0
*/
public function setId(string $id) : void
{
$this->id = $id;
}
/**
* Get selector id
*
* @return string
*
* @since 1.0.0
*/
public function getId() : string
{
return $this->id;
}
/**
* {@inheritdoc}
*/

View File

@ -58,18 +58,6 @@ class GroupTagSelectorView extends View
$this->addData('group-selector-popup', $view);
}
/**
* Get selector id
*
* @return string
*
* @since 1.0.0
*/
public function getId() : string
{
return $this->id;
}
/**
* Is required?
*
@ -91,7 +79,7 @@ class GroupTagSelectorView extends View
$this->id = $data[0];
$this->isRequired = $data[1] ?? false;
$this->getData('group-selector-popup')->setId($this->id);
$this->getData('group-selector-popup')->id = $this->id;
return parent::render();
}

View File

@ -17,6 +17,18 @@ return ['Admin' => [
':s2' => 'Inactive',
':s3' => 'Timeout',
':s4' => 'Banned',
':contact1' => 'Phone',
':contact2' => 'Fax',
':contact3' => 'Website',
':contact4' => 'Email',
':address1' => 'Home',
':address2' => 'Business',
':address3' => 'Delivery',
':address4' => 'Billing',
':address5' => 'Work',
':address6' => 'Contract',
':address8' => 'Education',
':address99' => 'Other',
'Account' => 'Account',
'Account/Group' => 'Account/Group',
'Accounts' => 'Accounts',
@ -149,7 +161,7 @@ return ['Admin' => [
'Status0' => 'None',
'Status1' => 'Active',
'Status2' => 'Inactive',
'Status3' => 'Timehout',
'Status3' => 'Timeout',
'Status4' => 'Banned',
'Tablespoon' => 'Tablespoon',
'Teaspoon' => 'Teaspoon',
@ -189,7 +201,7 @@ return ['Admin' => [
'active' => 'active',
'available' => 'available',
'i:LoginRetries' => 'Amount of allowed retries (-1 = unlimited)',
'i:PasswordChangeInterval' => 'Interval in which passwards need to be changed (-1 = never)',
'i:PasswordChangeInterval' => 'Interval in which passwords need to be changed (-1 = never)',
'i:PasswordHistory' => 'New password has to be different from the last N passwords',
'i:PasswordRegex' => 'Password requirement for users',
'i:TimeoutPeriod' => 'Timeout period after too many logins',
@ -200,4 +212,13 @@ return ['Admin' => [
'i:rem' => 'IP address or URL for remote access.',
'i:timef' => 'Time format.',
'inactive' => 'inactive',
'FAO' => 'FAO',
'Addition' => 'Addition',
'Postal' => 'Postal',
'State' => 'State',
'Addresses' => 'Addresses',
'Contact' => 'Contact',
'Contacts' => 'Contacts',
'Subtype' => 'Subtype',
'Content' => 'Content',
]];

View File

@ -89,14 +89,14 @@ echo $this->data['nav']->render(); ?>
$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'; }
if ($value->status === AccountStatus::ACTIVE) { $color = 'green'; }
elseif ($value->status === AccountStatus::INACTIVE) { $color = 'darkblue'; }
elseif ($value->status === AccountStatus::TIMEOUT) { $color = 'purple'; }
elseif ($value->status === AccountStatus::BANNED) { $color = 'red'; }
?>
<tr tabindex="0" data-href="<?= $url; ?>">
<td data-label="<?= $this->getHtml('ID', '0', '0'); ?>"><a href="<?= $url; ?>"><?= $value->id; ?></a>
<td data-label="<?= $this->getHtml('Status'); ?>"><a href="<?= $url; ?>"><span class="tag <?= $color; ?>"><?= $this->getHtml('Status'. $value->getStatus()); ?></span></a>
<td data-label="<?= $this->getHtml('Status'); ?>"><a href="<?= $url; ?>"><span class="tag <?= $color; ?>"><?= $this->getHtml('Status'. $value->status); ?></span></a>
<td data-label="<?= $this->getHtml('Name'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($this->renderUserName('%3$s %2$s %1$s', [$value->name1, $value->name2, $value->name3, $value->login])); ?></a>
<td data-label="<?= $this->getHtml('Activity'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->getLastActive()->format('Y-m-d H:i:s')); ?></a>
<td data-label="<?= $this->getHtml('Created'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->createdAt->format('Y-m-d H:i:s')); ?></a>

View File

@ -85,17 +85,17 @@ echo $this->data['nav']->render(); ?>
<div class="form-group">
<label for="iType"><?= $this->getHtml('Type'); ?></label>
<select id="iType" name="type">
<option value="<?= AccountType::USER; ?>"<?= $this->printHtml($account->getType() === AccountType::USER ? ' selected' : ''); ?>><?= $this->getHtml('Person'); ?>
<option value="<?= AccountType::GROUP; ?>"<?= $this->printHtml($account->getType() === AccountType::GROUP ? ' selected' : ''); ?>><?= $this->getHtml('Organization'); ?>
<option value="<?= AccountType::USER; ?>"<?= $account->type === AccountType::USER ? ' selected' : ''; ?>><?= $this->getHtml('Person'); ?>
<option value="<?= AccountType::GROUP; ?>"<?= $account->type === AccountType::GROUP ? ' selected' : ''; ?>><?= $this->getHtml('Organization'); ?>
</select>
</div>
<div class="form-group">
<label for="iStatus"><?= $this->getHtml('Status'); ?></label>
<select id="iStatus" name="status">
<option value="<?= AccountStatus::ACTIVE; ?>"<?= $this->printHtml($account->getStatus() === AccountStatus::ACTIVE ? ' selected' : ''); ?>><?= $this->getHtml('Active'); ?>
<option value="<?= AccountStatus::INACTIVE; ?>"<?= $this->printHtml($account->getStatus() === AccountStatus::INACTIVE ? ' selected' : ''); ?>><?= $this->getHtml('Inactive'); ?>
<option value="<?= AccountStatus::TIMEOUT; ?>"<?= $this->printHtml($account->getStatus() === AccountStatus::TIMEOUT ? ' selected' : ''); ?>><?= $this->getHtml('Timeout'); ?>
<option value="<?= AccountStatus::BANNED; ?>"<?= $this->printHtml($account->getStatus() === AccountStatus::BANNED ? ' selected' : ''); ?>><?= $this->getHtml('Banned'); ?>
<option value="<?= AccountStatus::ACTIVE; ?>"<?= $account->status === AccountStatus::ACTIVE ? ' selected' : ''; ?>><?= $this->getHtml('Active'); ?>
<option value="<?= AccountStatus::INACTIVE; ?>"<?= $account->status === AccountStatus::INACTIVE ? ' selected' : ''; ?>><?= $this->getHtml('Inactive'); ?>
<option value="<?= AccountStatus::TIMEOUT; ?>"<?= $account->status === AccountStatus::TIMEOUT ? ' selected' : ''; ?>><?= $this->getHtml('Timeout'); ?>
<option value="<?= AccountStatus::BANNED; ?>"<?= $account->status === AccountStatus::BANNED ? ' selected' : ''; ?>><?= $this->getHtml('Banned'); ?>
</select>
</div>
<div class="form-group">
@ -153,7 +153,7 @@ echo $this->data['nav']->render(); ?>
"key": 1, "listener": "click", "action": [
{"key": 1, "type": "event.prevent"},
{"key": 2, "type": "dom.getvalue", "base": "", "selector": "#iId"},
{"key": 3, "type": "message.request", "uri": "{/base}/{/lang}/api/profile", "method": "PUT", "request_type": "json"},
{"key": 3, "type": "message.request", "uri": "{/base}/{/lang}/api/view", "method": "PUT", "request_type": "json"},
{"key": 4, "type": "message.log"}
]
}
@ -538,15 +538,15 @@ echo $this->data['nav']->render(); ?>
<label for="iCurrencies"><?= $this->getHtml('Currency'); ?></label>
<select form="fLocalization" id="iCurrencies" name="settings_currency">
<?php foreach ($currencies as $code => $currency) : $code = \substr($code, 1); ?>
<option value="<?= $this->printHtml($code); ?>"<?= $this->printHtml($code === $l11n->getCurrency() ? ' selected' : ''); ?>><?= $this->printHtml($currency); ?>
<option value="<?= $this->printHtml($code); ?>"<?= $this->printHtml($code === $l11n->currency ? ' selected' : ''); ?>><?= $this->printHtml($currency); ?>
<?php endforeach; ?>
</select>
</div>
<div class="form-group">
<label><?= $this->getHtml('Currencyformat'); ?></label>
<select form="fLocalization" name="settings_currencyformat">
<option value="0"<?= $this->printHtml($l11n->getCurrencyFormat() === '0' ? ' selected' : ''); ?>><?= $this->getHtml('Amount') , ' ' , $this->printHtml($l11n->getCurrency()); ?>
<option value="1"<?= $this->printHtml($l11n->getCurrencyFormat() === '1' ? ' selected' : ''); ?>><?= $this->printHtml($l11n->getCurrency()) , ' ' , $this->getHtml('Amount'); ?>
<option value="0"<?= $this->printHtml($l11n->getCurrencyFormat() === '0' ? ' selected' : ''); ?>><?= $this->getHtml('Amount') , ' ' , $this->printHtml($l11n->currency); ?>
<option value="1"<?= $this->printHtml($l11n->getCurrencyFormat() === '1' ? ' selected' : ''); ?>><?= $this->printHtml($l11n->currency) , ' ' , $this->getHtml('Amount'); ?>
</select>
</div>
<div class="form-group">
@ -916,7 +916,7 @@ echo $this->data['nav']->render(); ?>
<?php
$count = 0;
foreach ($audits as $key => $audit) : ++$count;
$url = UriFactory::build('{/base}/admin/audit/single?id=' . $audit->id); ?>
$url = UriFactory::build('{/base}/admin/audit/view?id=' . $audit->id); ?>
<tr tabindex="0" data-href="<?= $url; ?>">
<td><?= $audit->id; ?>
<td><?= $this->printHtml($audit->module); ?>

View File

@ -87,14 +87,14 @@ echo $this->data['nav']->render(); ?>
foreach ($groups as $key => $value) : ++$c;
$url = UriFactory::build('{/base}/admin/group/settings?{?}&id=' . $value->id);
$color = 'darkred';
if ($value->getStatus() === GroupStatus::ACTIVE) { $color = 'green'; }
elseif ($value->getStatus() === GroupStatus::INACTIVE) { $color = 'darkblue'; }
elseif ($value->getStatus() === GroupStatus::HIDDEN) { $color = 'purple'; }
$color = 'darkred';
if ($value->status === GroupStatus::ACTIVE) { $color = 'green'; }
elseif ($value->status === GroupStatus::INACTIVE) { $color = 'darkblue'; }
elseif ($value->status === GroupStatus::HIDDEN) { $color = 'purple'; }
?>
<tr tabindex="0" data-href="<?= $url; ?>">
<td data-label="<?= $this->getHtml('ID', '0', '0'); ?>"><a href="<?= $url; ?>"><?= $value->id; ?></a>
<td data-label="<?= $this->getHtml('Status'); ?>"><a href="<?= $url; ?>"><span class="tag <?= $color; ?>"><?= $this->getHtml('Status'. $value->getStatus()); ?></span></a>
<td data-label="<?= $this->getHtml('Status'); ?>"><a href="<?= $url; ?>"><span class="tag <?= $color; ?>"><?= $this->getHtml('Status' . $value->status); ?></span></a>
<td data-label="<?= $this->getHtml('Name'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->name); ?></a>
<td data-label="<?= $this->getHtml('Members'); ?>"><?= $memberCount[$value->id] ?? 0; ?>
<?php endforeach; ?>

View File

@ -29,7 +29,7 @@ $audits = $this->data['auditlogs'] ?? [];
$previous = empty($audits)
? HttpHeader::getAllHeaders()['Referer'] ?? 'admin/group/settings?id={?id}#{\#}'
: 'admin/group/settings?{?}&audit=' . \reset($audits)->id . '&ptype=p#{\#}';
$next = empty($audits)
$next = empty($audits)
? HttpHeader::getAllHeaders()['Referer'] ?? 'admin/group/settings?id={?id}#{\#}'
: 'admin/group/settings?{?}&audit=' . \end($audits)->id . '&ptype=n#{\#}';
@ -65,7 +65,7 @@ echo $this->data['nav']->render(); ?>
<label for="iGstatus"><?= $this->getHtml('Status'); ?></label>
<select id="iGstatus" name="status">
<?php $status = GroupStatus::getConstants(); foreach ($status as $stat) : ?>
<option value="<?= $stat; ?>"<?= $stat === $group->getStatus() ? ' selected' : ''; ?>><?= $this->getHtml('GroupStatus' . $stat); ?>
<option value="<?= $stat; ?>"<?= $stat === $group->status ? ' selected' : ''; ?>><?= $this->getHtml('GroupStatus' . $stat); ?>
<?php endforeach; ?>
</select>
</div>
@ -387,7 +387,7 @@ echo $this->data['nav']->render(); ?>
<td><?= $this->getHtml('Date', 'Auditor'); ?>
<tbody>
<?php $count = 0; foreach ($audits as $key => $audit) : ++$count;
$url = UriFactory::build('{/base}/admin/audit/single?{?}&id=' . $audit->id); ?>
$url = UriFactory::build('{/base}/admin/audit/view?{?}&id=' . $audit->id); ?>
<tr tabindex="0" data-href="<?= $url; ?>">
<td><?= $audit->id; ?>
<td><?= $this->printHtml($audit->module); ?>

View File

@ -85,7 +85,7 @@ $tableView->setObjects($modules);
}
?>
<tr tabindex="0" data-href="<?= $url; ?>">
<td data-label="<?= $this->getHtml('ID', '0', '0'); ?>"><a href="<?= $url; ?>"><?= $module->getId(); ?></a>
<td data-label="<?= $this->getHtml('ID', '0', '0'); ?>"><a href="<?= $url; ?>"><?= $module->id; ?></a>
<td data-label="<?= $this->getHtml('Name'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($module->getExternalName()); ?></a>
<td data-label="<?= $this->getHtml('Version'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($module->getVersion()); ?></a>
<td data-label="<?= $this->getHtml('Status'); ?>">

View File

@ -54,7 +54,7 @@ echo $this->data['nav']->render();
<?php
$count = 0;
foreach ($audits as $key => $audit) : ++$count;
$url = UriFactory::build('{/base}/admin/audit/single?{?}&id=' . $audit->id); ?>
$url = UriFactory::build('{/base}/admin/audit/view?{?}&id=' . $audit->id); ?>
<tr tabindex="0" data-href="<?= $url; ?>">
<td><?= $audit->id; ?>
<td><?= $this->printHtml($audit->module); ?>

View File

@ -121,7 +121,7 @@ else : ?>
$name = $this->getData('settings_class')::getName($setting->name);
if (!\is_string($name)) {
$name= $setting->name;
$name = $setting->name;
}
}
?>

View File

@ -89,16 +89,16 @@ echo $this->data['nav']->render(); ?>
<i class="filter g-icon">filter_alt</i>
</label>
<tbody>
<?php $c = 0; foreach ($accounts as $key => $value) : ++$c;
$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'; } ?>
<?php $c = 0; foreach ($accounts as $key => $value) : ++$c;
$url = UriFactory::build('{/base}/admin/account/settings?{?}&id=' . $value->id);
$color = 'darkred';
if ($value->status === AccountStatus::ACTIVE) { $color = 'green'; }
elseif ($value->status === AccountStatus::INACTIVE) { $color = 'darkblue'; }
elseif ($value->status === AccountStatus::TIMEOUT) { $color = 'purple'; }
elseif ($value->status === AccountStatus::BANNED) { $color = 'red'; } ?>
<tr tabindex="0" data-href="<?= $url; ?>">
<td data-label="<?= $this->getHtml('ID', '0', '0'); ?>"><a href="<?= $url; ?>"><?= $value->id; ?></a>
<td data-label="<?= $this->getHtml('Status'); ?>"><a href="<?= $url; ?>"><span class="tag <?= $color; ?>"><?= $this->getHtml('Status'. $value->getStatus()); ?></span></a>
<td data-label="<?= $this->getHtml('Status'); ?>"><a href="<?= $url; ?>"><span class="tag <?= $color; ?>"><?= $this->getHtml('Status' . $value->status); ?></span></a>
<td data-label="<?= $this->getHtml('Name'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($this->renderUserName('%3$s %2$s %1$s', [$value->name1, $value->name2, $value->name3, $value->login])); ?></a>
<td data-label="<?= $this->getHtml('Activity'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->getLastActive()->format('Y-m-d H:i:s')); ?></a>
<td data-label="<?= $this->getHtml('Created'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->createdAt->format('Y-m-d H:i:s')); ?></a>

View File

@ -37,7 +37,7 @@ $lengths = \phpOMS\Utils\Converter\LengthType::getConstants();
$volumes = \phpOMS\Utils\Converter\VolumeType::getConstants();
$temperatures = \phpOMS\Utils\Converter\TemperatureType::getConstants();
$l11n = $this->getData('default_localization') ?? new NullLocalization();
$l11n = $this->data['default_localization'] ?? new NullLocalization();
?>
<div class="tabview tab-2 url-rewrite">
@ -186,7 +186,7 @@ $l11n = $this->getData('default_localization') ?? new NullLocalization();
<label for="iCountries"><?= $this->getHtml('Country'); ?></label>
<select id="iCountries" name="settings_country">
<?php foreach ($countryCodes as $code3 => $code2) : ?>
<option value="<?= $this->printHtml($code2); ?>"<?= $this->printHtml($code2 === $l11n->getCountry() ? ' selected' : ''); ?>><?= $this->printHtml($countries[$code3]); ?>
<option value="<?= $this->printHtml($code2); ?>"<?= $this->printHtml($code2 === $l11n->country ? ' selected' : ''); ?>><?= $this->printHtml($countries[$code3]); ?>
<?php endforeach; ?>
</select>
</div>
@ -267,7 +267,7 @@ $l11n = $this->getData('default_localization') ?? new NullLocalization();
<label for="iCurrencies"><?= $this->getHtml('Currency'); ?></label>
<select form="fLocalization" id="iCurrencies" name="settings_currency">
<?php foreach ($currencies as $code => $currency) : $code = \substr($code, 1); ?>
<option value="<?= $this->printHtml($code); ?>"<?= $this->printHtml($code === $l11n->getCurrency() ? ' selected' : ''); ?>><?= $this->printHtml($currency); ?>
<option value="<?= $this->printHtml($code); ?>"<?= $this->printHtml($code === $l11n->currency ? ' selected' : ''); ?>><?= $this->printHtml($currency); ?>
<?php endforeach; ?>
</select>
</div>
@ -275,8 +275,8 @@ $l11n = $this->getData('default_localization') ?? new NullLocalization();
<div class="form-group">
<label><?= $this->getHtml('Currencyformat'); ?></label>
<select form="fLocalization" name="settings_currencyformat">
<option value="0"<?= $this->printHtml($l11n->getCurrencyFormat() === '0' ? ' selected' : ''); ?>><?= $this->getHtml('Amount') , ' ' , $this->printHtml($l11n->getCurrency()); ?>
<option value="1"<?= $this->printHtml($l11n->getCurrencyFormat() === '1' ? ' selected' : ''); ?>><?= $this->printHtml($l11n->getCurrency()) , ' ' , $this->getHtml('Amount'); ?>
<option value="0"<?= $this->printHtml($l11n->getCurrencyFormat() === '0' ? ' selected' : ''); ?>><?= $this->getHtml('Amount') , ' ' , $this->printHtml($l11n->currency); ?>
<option value="1"<?= $this->printHtml($l11n->getCurrencyFormat() === '1' ? ' selected' : ''); ?>><?= $this->printHtml($l11n->currency) , ' ' , $this->getHtml('Amount'); ?>
</select>
</div>

View File

@ -75,8 +75,8 @@ final class Autoloader
*/
public static function defaultAutoloader(string $class) : void
{
$class = \ltrim($class, '\\');
$class = \strtr($class, '_\\', '//');
$class = \ltrim($class, '\\');
$class = \strtr($class, '_\\', '//');
if (\stripos($class, 'Web/Backend') !== false || \stripos($class, 'Web/Api') !== false) {
$class = \is_dir(__DIR__ . '/Web') ? $class : \str_replace('Web/', 'MainRepository/Web/', $class);

View File

@ -1,4 +1,15 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\Admin\tests
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
\ini_set('memory_limit', '2048M');
@ -67,10 +78,10 @@ $GLOBALS['is_github'] = $IS_GITHUB;
$tmp = FileLogger::getInstance(__DIR__ . '/../Logs');
$CONFIG = [
'db' => [
'db' => [
'core' => [
'masters' => [
'admin' => [
'admin' => [
'db' => 'mysql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '3306', /* db host port */
@ -80,7 +91,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'insert' => [
'insert' => [
'db' => 'mysql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '3306', /* db host port */
@ -90,7 +101,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'select' => [
'select' => [
'db' => 'mysql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '3306', /* db host port */
@ -100,7 +111,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'update' => [
'update' => [
'db' => 'mysql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '3306', /* db host port */
@ -110,7 +121,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'delete' => [
'delete' => [
'db' => 'mysql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '3306', /* db host port */
@ -120,7 +131,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'schema' => [
'schema' => [
'db' => 'mysql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '3306', /* db host port */
@ -132,7 +143,7 @@ $CONFIG = [
],
],
'postgresql' => [
'admin' => [
'admin' => [
'db' => 'pgsql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '5432', /* db host port */
@ -142,7 +153,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'insert' => [
'insert' => [
'db' => 'pgsql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '5432', /* db host port */
@ -152,7 +163,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'select' => [
'select' => [
'db' => 'pgsql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '5432', /* db host port */
@ -162,7 +173,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'update' => [
'update' => [
'db' => 'pgsql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '5432', /* db host port */
@ -172,7 +183,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'delete' => [
'delete' => [
'db' => 'pgsql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '5432', /* db host port */
@ -182,7 +193,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'schema' => [
'schema' => [
'db' => 'pgsql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '5432', /* db host port */
@ -194,37 +205,37 @@ $CONFIG = [
],
],
'sqlite' => [
'admin' => [
'admin' => [
'db' => 'sqlite', /* db type */
'database' => __DIR__ . '/../Karaka/phpOMS/Localization/Defaults/localization.sqlite', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'insert' => [
'insert' => [
'db' => 'sqlite', /* db type */
'database' => __DIR__ . '/../Karaka/phpOMS/Localization/Defaults/localization.sqlite', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'select' => [
'select' => [
'db' => 'sqlite', /* db type */
'database' => __DIR__ . '/../Karaka/phpOMS/Localization/Defaults/localization.sqlite', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'update' => [
'update' => [
'db' => 'sqlite', /* db type */
'database' => __DIR__ . '/../Karaka/phpOMS/Localization/Defaults/localization.sqlite', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'delete' => [
'delete' => [
'db' => 'sqlite', /* db type */
'database' => __DIR__ . '/../Karaka/phpOMS/Localization/Defaults/localization.sqlite', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'schema' => [
'schema' => [
'db' => 'sqlite', /* db type */
'database' => __DIR__ . '/../Karaka/phpOMS/Localization/Defaults/localization.sqlite', /* db name */
'weight' => 1000, /* db table prefix */
@ -232,7 +243,7 @@ $CONFIG = [
],
],
'mssql' => [
'admin' => [
'admin' => [
'db' => 'mssql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '1433', /* db host port */
@ -242,7 +253,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'insert' => [
'insert' => [
'db' => 'mssql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '1433', /* db host port */
@ -252,7 +263,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'select' => [
'select' => [
'db' => 'mssql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '1433', /* db host port */
@ -262,7 +273,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'update' => [
'update' => [
'db' => 'mssql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '1433', /* db host port */
@ -272,7 +283,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'delete' => [
'delete' => [
'db' => 'mssql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '1433', /* db host port */
@ -282,7 +293,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'schema' => [
'schema' => [
'db' => 'mssql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '1433', /* db host port */
@ -322,16 +333,16 @@ $CONFIG = [
'password' => '123456',
],
],
'log' => [
'log' => [
'file' => [
'path' => __DIR__ . '/Logs',
],
],
'page' => [
'page' => [
'root' => '/',
'https' => false,
],
'app' => [
'app' => [
'path' => __DIR__,
'default' => [
'app' => 'Backend',
@ -350,7 +361,7 @@ $CONFIG = [
],
],
],
'socket' => [
'socket' => [
'master' => [
'host' => '127.0.0.1',
'limit' => 300,
@ -360,7 +371,7 @@ $CONFIG = [
'language' => [
'en',
],
'apis' => [
'apis' => [
],
];

View File

@ -19,7 +19,6 @@ use phpOMS\Account\AccountType;
use phpOMS\Message\Http\HttpRequest;
use phpOMS\Message\Http\HttpResponse;
use phpOMS\Message\Http\RequestStatusCode;
use phpOMS\Uri\HttpUri;
trait ApiControllerAccountTrait
{
@ -31,7 +30,7 @@ trait ApiControllerAccountTrait
public function testApiAccountGet() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('id', '1');
@ -50,7 +49,7 @@ trait ApiControllerAccountTrait
public function testApiAccountUpdate() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('id', 1);
@ -72,7 +71,7 @@ trait ApiControllerAccountTrait
public function testApiAccountFind() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('search', 'admin');
@ -90,7 +89,7 @@ trait ApiControllerAccountTrait
public function testApiAccountAndProfileCreate() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('user', 'guest');
@ -113,7 +112,7 @@ trait ApiControllerAccountTrait
public function testApiAccountCreateWithCustomLocale() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('user', 'guest2');
@ -138,7 +137,7 @@ trait ApiControllerAccountTrait
public function testApiAccountDelete() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
// mustn't create a profile otherwise it will not be possible to delete the account because of FK constraints
@ -162,7 +161,7 @@ trait ApiControllerAccountTrait
public function testApiAccountCreateInvalid() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('status', 999);
@ -180,7 +179,7 @@ trait ApiControllerAccountTrait
public function testApiAddRemoveGroupToAccount() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('account', 1);
@ -203,7 +202,7 @@ trait ApiControllerAccountTrait
public function testApiRemoveAdminGroupFromOneselfAccount() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('account', 1);
@ -220,7 +219,7 @@ trait ApiControllerAccountTrait
public function testApiAccountLogin() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('user', 'admin');
@ -237,7 +236,7 @@ trait ApiControllerAccountTrait
public function testApiAccountLoginInvalid() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('user', 'admin');
@ -254,7 +253,7 @@ trait ApiControllerAccountTrait
public function testApiAccountLogout() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('user', 'admin');

View File

@ -17,7 +17,6 @@ namespace Modules\Admin\tests\Controller\Api;
use phpOMS\Message\Http\HttpRequest;
use phpOMS\Message\Http\HttpResponse;
use phpOMS\Message\Http\RequestStatusCode;
use phpOMS\Uri\HttpUri;
trait ApiControllerApplicationTrait
{
@ -28,7 +27,7 @@ trait ApiControllerApplicationTrait
public function testApiInvalidAppplicationPathInstall() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('appSrc', 'invalid');

View File

@ -18,7 +18,6 @@ use phpOMS\Account\GroupStatus;
use phpOMS\Message\Http\HttpRequest;
use phpOMS\Message\Http\HttpResponse;
use phpOMS\Message\Http\RequestStatusCode;
use phpOMS\Uri\HttpUri;
trait ApiControllerGroupTrait
{
@ -30,7 +29,7 @@ trait ApiControllerGroupTrait
public function testApiGroupGet() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('id', '3');
@ -49,7 +48,7 @@ trait ApiControllerGroupTrait
public function testApiGroupSet() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('id', '3');
@ -72,7 +71,7 @@ trait ApiControllerGroupTrait
public function testApiGroupFind() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('search', 'admin');
@ -90,7 +89,7 @@ trait ApiControllerGroupTrait
public function testApiGroupCreateDelete() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('name', 'test');
@ -117,7 +116,7 @@ trait ApiControllerGroupTrait
public function testApiGroupDeleteAdminInvalid() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
@ -134,7 +133,7 @@ trait ApiControllerGroupTrait
public function testApiGroupCreateInvalid() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('status', 999);
@ -152,7 +151,7 @@ trait ApiControllerGroupTrait
public function testApiAddRemoveAccountToGroup() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('group', 1);
@ -175,7 +174,7 @@ trait ApiControllerGroupTrait
public function testApiRemoveAdminAccountFromAdminGroup() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('group', 3);
@ -193,7 +192,7 @@ trait ApiControllerGroupTrait
public function testApiAccountGroupFind() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('search', 'admin');

View File

@ -18,7 +18,6 @@ use Modules\Admin\Models\ModuleStatusUpdateType;
use phpOMS\Message\Http\HttpRequest;
use phpOMS\Message\Http\HttpResponse;
use phpOMS\Message\Http\RequestStatusCode;
use phpOMS\Uri\HttpUri;
trait ApiControllerModuleTrait
{
@ -30,7 +29,7 @@ trait ApiControllerModuleTrait
public function testApiModuleStatusUpdate() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('module', 'TestModule');
@ -60,7 +59,7 @@ trait ApiControllerModuleTrait
public function testApiModuleStatusUpdateEmptyModule() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
@ -79,7 +78,7 @@ trait ApiControllerModuleTrait
public function testApiModuleStatusUpdateInvalidStatus() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('module', 'TestModule');
@ -97,7 +96,7 @@ trait ApiControllerModuleTrait
public function testApiModuleStatusUpdateInvalidModule() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('module', 'invalid');
@ -115,7 +114,7 @@ trait ApiControllerModuleTrait
public function testApiReInit() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;

View File

@ -19,7 +19,6 @@ use phpOMS\Account\PermissionType;
use phpOMS\Message\Http\HttpRequest;
use phpOMS\Message\Http\HttpResponse;
use phpOMS\Message\Http\RequestStatusCode;
use phpOMS\Uri\HttpUri;
trait ApiControllerPermissionTrait
{
@ -31,7 +30,7 @@ trait ApiControllerPermissionTrait
public function testApiAddGroupPermission() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('permissionowner', PermissionOwner::GROUP);
@ -49,7 +48,7 @@ trait ApiControllerPermissionTrait
public function testApiAddGroupPermissionToAdmin() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('permissionowner', PermissionOwner::GROUP);
@ -67,7 +66,7 @@ trait ApiControllerPermissionTrait
public function testApiGroupPermissionGet() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('id', '2');
@ -86,7 +85,7 @@ trait ApiControllerPermissionTrait
public function testApiGroupPermissionCreateDelete() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('permissionowner', PermissionOwner::GROUP);
@ -111,7 +110,7 @@ trait ApiControllerPermissionTrait
public function testApiAddGroupPermissionInvalidData() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('permissionowner', PermissionOwner::GROUP);
@ -128,7 +127,7 @@ trait ApiControllerPermissionTrait
public function testApiAddGroupPermissionInvalidType() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('permissionowner', PermissionOwner::ACCOUNT);
@ -146,7 +145,7 @@ trait ApiControllerPermissionTrait
public function testApiGroupPermissionUpdate() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('id', 1);
@ -173,7 +172,7 @@ trait ApiControllerPermissionTrait
public function testApiAddAccountPermission() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('permissionowner', PermissionOwner::ACCOUNT);
@ -192,7 +191,7 @@ trait ApiControllerPermissionTrait
public function testApiAccountPermissionGet() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('id', '1');
@ -211,7 +210,7 @@ trait ApiControllerPermissionTrait
public function testApiAccountPermissionCreateDelete() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('permissionowner', PermissionOwner::ACCOUNT);
@ -236,7 +235,7 @@ trait ApiControllerPermissionTrait
public function testApiAddAccountPermissionInvalidData() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('permissionowner', PermissionOwner::ACCOUNT);
@ -253,7 +252,7 @@ trait ApiControllerPermissionTrait
public function testApiAddAccountPermissionInvalidType() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('permissionowner', PermissionOwner::GROUP);
@ -271,7 +270,7 @@ trait ApiControllerPermissionTrait
public function testApiAccountPermissionUpdate() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('id', 1);

View File

@ -18,7 +18,6 @@ use Modules\Admin\Models\SettingsEnum;
use phpOMS\Message\Http\HttpRequest;
use phpOMS\Message\Http\HttpResponse;
use phpOMS\Message\Http\RequestStatusCode;
use phpOMS\Uri\HttpUri;
trait ApiControllerSettingsTrait
{
@ -30,7 +29,7 @@ trait ApiControllerSettingsTrait
public function testApiSettingsGet() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('name', SettingsEnum::PASSWORD_INTERVAL);
@ -47,7 +46,7 @@ trait ApiControllerSettingsTrait
public function testApiSettingsSet() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('settings', \json_encode([['name' => SettingsEnum::PASSWORD_INTERVAL, 'content' => '60']]));
@ -68,7 +67,7 @@ trait ApiControllerSettingsTrait
public function testApiAccountLocalizationLoadSet() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('account_id', 1);
@ -93,7 +92,7 @@ trait ApiControllerSettingsTrait
public function testApiAccountLocalizationSet() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('account_id', 1);
@ -107,7 +106,7 @@ trait ApiControllerSettingsTrait
$this->module->apiSettingsAccountLocalizationSet($request, $response);
$l11n = $response->getDataArray('')['response'];
self::assertEquals($l11n->getCurrency(), 'EUR');
self::assertEquals($l11n->currency, 'EUR');
}
/**
@ -117,7 +116,7 @@ trait ApiControllerSettingsTrait
public function testInvalidPermissionAccountLocalizationSet() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 2;
$request->setData('account_id', 1);

View File

@ -59,13 +59,13 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase
protected string $appName = 'Api';
};
$this->app->dbPool = $GLOBALS['dbpool'];
$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/');
$this->app->dispatcher = new Dispatcher($this->app);
$this->app->eventManager = new EventManager($this->app->dispatcher);
$this->app->dbPool = $GLOBALS['dbpool'];
$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/');
$this->app->dispatcher = new Dispatcher($this->app);
$this->app->eventManager = new EventManager($this->app->dispatcher);
$this->app->eventManager->importFromFile(__DIR__ . '/../../../../Web/Api/Hooks.php');
$this->app->sessionManager = new HttpSession(36000);
$this->app->l11nManager = new L11nManager();

View File

@ -38,8 +38,8 @@ class Helper {
$account->name3 = \ucfirst(Text::LOREM_IPSUM[\mt_rand(0, $LOREM_COUNT - 1)]);
$account->tries = 0;
$account->setEmail(Email::generateEmail());
$account->setStatus(AccountStatus::ACTIVE);
$account->setType(AccountType::USER);
$account->status = AccountStatus::ACTIVE;
$account->type = AccountType::USER;
AccountMapper::create()->execute($account);

View File

@ -44,8 +44,8 @@ final class AccountMapperTest extends \PHPUnit\Framework\TestCase
$account->name3 = 'Duck';
$account->tries = 0;
$account->setEmail('d.duck@duckburg.com');
$account->setStatus(AccountStatus::ACTIVE);
$account->setType(AccountType::USER);
$account->status = AccountStatus::ACTIVE;
$account->type = AccountType::USER;
$id = AccountMapper::create()->execute($account);
self::assertGreaterThan(0, $account->id);
@ -57,8 +57,8 @@ final class AccountMapperTest extends \PHPUnit\Framework\TestCase
self::assertEquals($account->name1, $accountR->name1);
self::assertEquals($account->name2, $accountR->name2);
self::assertEquals($account->name3, $accountR->name3);
self::assertEquals($account->getStatus(), $accountR->getStatus());
self::assertEquals($account->getType(), $accountR->getType());
self::assertEquals($account->status, $accountR->status);
self::assertEquals($account->type, $accountR->type);
self::assertEquals($account->getEmail(), $accountR->getEmail());
self::assertEquals($account->tries, $accountR->tries);
}
@ -126,13 +126,13 @@ final class AccountMapperTest extends \PHPUnit\Framework\TestCase
public function testInvalidLoginAccountStatus() : void
{
/** @var Account $accountR */
$accountR = AccountMapper::get()->where('id', 1)->execute();
$accountR->setStatus(AccountStatus::BANNED);
$accountR = AccountMapper::get()->where('id', 1)->execute();
$accountR->status = AccountStatus::BANNED;
AccountMapper::update()->execute($accountR);
self::assertEquals(LoginReturnType::INACTIVE, AccountMapper::login($accountR->login, 'orange'));
$accountR->setStatus(AccountStatus::ACTIVE);
$accountR->status = AccountStatus::ACTIVE;
AccountMapper::update()->execute($accountR);
}

View File

@ -37,13 +37,13 @@ final class AddressMapperTest extends \PHPUnit\Framework\TestCase
$address->fao = 'fao';
$address->addressAddition = 'addition';
$address->postal = '0123456789';
$address->setType(AddressType::BUSINESS);
$address->city = 'city';
$address->address = 'Some address here';
$address->state = 'This is a state 123';
$address->setCountry('DE');
$address->lat = 12.1;
$address->lon = 11.2;
$address->type = AddressType::BUSINESS;
$address->city = 'city';
$address->address = 'Some address here';
$address->state = 'This is a state 123';
$address->country = 'DE';
$address->lat = 12.1;
$address->lon = 11.2;
$id = AddressMapper::create()->execute($address);
self::assertGreaterThan(0, $address->id);
@ -53,7 +53,7 @@ final class AddressMapperTest extends \PHPUnit\Framework\TestCase
self::assertEquals($address->name, $addressR->name);
self::assertEquals($address->fao, $addressR->fao);
self::assertEquals($address->addressAddition, $addressR->addressAddition);
self::assertEquals($address->getType(), $addressR->getType());
self::assertEquals($address->type, $addressR->type);
self::assertEquals($address->postal, $addressR->postal);
self::assertEquals($address->address, $addressR->address);
self::assertEquals($address->state, $addressR->state);

View File

@ -44,7 +44,7 @@ final class ModuleTest extends \PHPUnit\Framework\TestCase
self::assertEquals('', $this->module->id);
self::assertInstanceOf('\DateTimeImmutable', $this->module->createdAt);
self::assertEquals('', $this->module->name);
self::assertEquals(ModuleStatus::INACTIVE, $this->module->getStatus());
self::assertEquals(ModuleStatus::INACTIVE, $this->module->status);
self::assertEquals(\json_encode($this->module->jsonSerialize()), $this->module->__toString());
self::assertEquals($this->module->jsonSerialize(), $this->module->toArray());
}
@ -67,8 +67,8 @@ final class ModuleTest extends \PHPUnit\Framework\TestCase
*/
public function testStatusInputOutput() : void
{
$this->module->setStatus(ModuleStatus::ACTIVE);
self::assertEquals(ModuleStatus::ACTIVE, $this->module->getStatus());
$this->module->status = ModuleStatus::ACTIVE;
self::assertEquals(ModuleStatus::ACTIVE, $this->module->status);
}
/**
@ -81,16 +81,4 @@ final class ModuleTest extends \PHPUnit\Framework\TestCase
self::assertEquals(\json_encode($this->module->jsonSerialize()), $this->module->__toString());
self::assertEquals($this->module->jsonSerialize(), $this->module->toArray());
}
/**
* @testdox A invalid status throws a InvalidEnumValue exception
* @covers Modules\Admin\Models\Module
* @group module
*/
public function testInvalidStatus() : void
{
$this->expectException(\phpOMS\Stdlib\Base\Exception\InvalidEnumValue::class);
$this->module->setStatus(9999);
}
}