mirror of
https://github.com/Karaka-Management/oms-Admin.git
synced 2026-01-11 13:38:39 +00:00
update settings
This commit is contained in:
parent
4c4a20d22e
commit
84da86be29
71
Admin/Install/Media.install.json
Normal file
71
Admin/Install/Media.install.json
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
[
|
||||
{
|
||||
"type": "collection",
|
||||
"create_directory": true,
|
||||
"name": "Admin",
|
||||
"virtualPath": "/Modules",
|
||||
"user": 1
|
||||
},
|
||||
{
|
||||
"type": "collection",
|
||||
"create_directory": true,
|
||||
"name": "Templates",
|
||||
"virtualPath": "/Modules/Admin",
|
||||
"user": 1
|
||||
},
|
||||
{
|
||||
"type": "upload",
|
||||
"create_collection": true,
|
||||
"name": "Pdf Exporter",
|
||||
"virtualPath": "/Modules/Admin/Templates",
|
||||
"path": "/Modules/Admin/Templates/Pdf Exporter",
|
||||
"files": [
|
||||
"/Modules/Admin/Admin/Install/Media/PdfExporter"
|
||||
],
|
||||
"user": 1
|
||||
},
|
||||
{
|
||||
"type": "upload",
|
||||
"create_collection": true,
|
||||
"name": "Excel Exporter",
|
||||
"virtualPath": "/Modules/Admin/Templates",
|
||||
"path": "/Modules/Admin/Templates/Excel Exporter",
|
||||
"files": [
|
||||
"/Modules/Admin/Admin/Install/Media/ExcelExporter"
|
||||
],
|
||||
"user": 1
|
||||
},
|
||||
{
|
||||
"type": "upload",
|
||||
"create_collection": true,
|
||||
"name": "Csv Exporter",
|
||||
"virtualPath": "/Modules/Admin/Templates",
|
||||
"path": "/Modules/Admin/Templates/Csv Exporter",
|
||||
"files": [
|
||||
"/Modules/Admin/Admin/Install/Media/CsvExporter"
|
||||
],
|
||||
"user": 1
|
||||
},
|
||||
{
|
||||
"type": "upload",
|
||||
"create_collection": true,
|
||||
"name": "Word Exporter",
|
||||
"virtualPath": "/Modules/Admin/Templates",
|
||||
"path": "/Modules/Admin/Templates/Word Exporter",
|
||||
"files": [
|
||||
"/Modules/Admin/Admin/Install/Media/WordExporter"
|
||||
],
|
||||
"user": 1
|
||||
},
|
||||
{
|
||||
"type": "upload",
|
||||
"create_collection": true,
|
||||
"name": "Email Exporter",
|
||||
"virtualPath": "/Modules/Admin/Templates",
|
||||
"path": "/Modules/Admin/Templates/Email Exporter",
|
||||
"files": [
|
||||
"/Modules/Admin/Admin/Install/Media/EmailExporter"
|
||||
],
|
||||
"user": 1
|
||||
}
|
||||
]
|
||||
68
Admin/Install/Media.php
Normal file
68
Admin/Install/Media.php
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
/**
|
||||
* Karaka
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\Admin\Admin\Install
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://karaka.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Admin\Admin\Install;
|
||||
|
||||
use Model\Setting;
|
||||
use Model\SettingMapper;
|
||||
use Modules\Admin\Models\SettingsEnum;
|
||||
use phpOMS\Application\ApplicationAbstract;
|
||||
|
||||
/**
|
||||
* Media class.
|
||||
*
|
||||
* @package Modules\Admin\Admin\Install
|
||||
* @license OMS License 1.0
|
||||
* @link https://karaka.app
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Media
|
||||
{
|
||||
/**
|
||||
* Install media providing
|
||||
*
|
||||
* @param ApplicationAbstract $app Application
|
||||
* @param string $path Module path
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function install(ApplicationAbstract $app, string $path) : void
|
||||
{
|
||||
$media = \Modules\Media\Admin\Installer::installExternal($app, ['path' => __DIR__ . '/Media.install.json']);
|
||||
|
||||
$defaultPdfExport = (int) \reset($media['upload'][0]);
|
||||
$defaultExcelExport = (int) \reset($media['upload'][1]);
|
||||
$defaultCsvExport = (int) \reset($media['upload'][2]);
|
||||
$defaultWordExport = (int) \reset($media['upload'][3]);
|
||||
$defaultEmailExport = (int) \reset($media['upload'][4]);
|
||||
|
||||
SettingMapper::create()->execute(
|
||||
new Setting(0, SettingsEnum::DEFAULT_PDF_EXPORT_TEMPLATE, (string) $defaultPdfExport, '\\d+', 1, 'Admin')
|
||||
);
|
||||
SettingMapper::create()->execute(
|
||||
new Setting(0, SettingsEnum::DEFAULT_EXCEL_EXPORT_TEMPLATE, (string) $defaultExcelExport, '\\d+', 1, 'Admin')
|
||||
);
|
||||
SettingMapper::create()->execute(
|
||||
new Setting(0, SettingsEnum::DEFAULT_CSV_EXPORT_TEMPLATE, (string) $defaultCsvExport, '\\d+', 1, 'Admin')
|
||||
);
|
||||
SettingMapper::create()->execute(
|
||||
new Setting(0, SettingsEnum::DEFAULT_WORD_EXPORT_TEMPLATE, (string) $defaultWordExport, '\\d+', 1, 'Admin')
|
||||
);
|
||||
SettingMapper::create()->execute(
|
||||
new Setting(0, SettingsEnum::DEFAULT_EMAIL_EXPORT_TEMPLATE, (string) $defaultEmailExport, '\\d+', 1, 'Admin')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
|
||||
|
|
@ -0,0 +1 @@
|
|||
|
||||
|
|
@ -0,0 +1 @@
|
|||
|
||||
|
|
@ -0,0 +1 @@
|
|||
|
||||
|
|
@ -0,0 +1 @@
|
|||
|
||||
|
|
@ -16,8 +16,8 @@ namespace Modules\Admin\Admin;
|
|||
|
||||
use Model\Setting;
|
||||
use Model\SettingMapper;
|
||||
use Model\SettingsEnum;
|
||||
use Modules\Admin\Models\LocalizationMapper;
|
||||
use Modules\Admin\Models\SettingsEnum;
|
||||
use phpOMS\Application\ApplicationAbstract;
|
||||
use phpOMS\Config\SettingsInterface;
|
||||
use phpOMS\DataStorage\Database\Connection\SQLiteConnection;
|
||||
|
|
@ -78,19 +78,19 @@ final class Installer extends InstallerAbstract
|
|||
**/
|
||||
private static function installDefaultSettings() : void
|
||||
{
|
||||
SettingMapper::create()->execute(new Setting(0, SettingsEnum::PASSWORD_PATTERN, ''));
|
||||
SettingMapper::create()->execute(new Setting(0, SettingsEnum::LOGIN_TRIES, '3', '\\d+'));
|
||||
SettingMapper::create()->execute(new Setting(0, SettingsEnum::LOGIN_TIMEOUT, '3', '\\d+'));
|
||||
SettingMapper::create()->execute(new Setting(0, SettingsEnum::PASSWORD_INTERVAL, '90', '\\d+'));
|
||||
SettingMapper::create()->execute(new Setting(0, SettingsEnum::PASSWORD_HISTORY, '3', '\\d+'));
|
||||
SettingMapper::create()->execute(new Setting(0, SettingsEnum::LOGGING_STATUS, '1', '[0-3]'));
|
||||
SettingMapper::create()->execute(new Setting(0, SettingsEnum::LOGGING_PATH, ''));
|
||||
SettingMapper::create()->execute(new Setting(0, SettingsEnum::PASSWORD_PATTERN, '', module: 'Admin'));
|
||||
SettingMapper::create()->execute(new Setting(0, SettingsEnum::LOGIN_TRIES, '3', '\\d+', module: 'Admin'));
|
||||
SettingMapper::create()->execute(new Setting(0, SettingsEnum::LOGIN_TIMEOUT, '3', '\\d+', module: 'Admin'));
|
||||
SettingMapper::create()->execute(new Setting(0, SettingsEnum::PASSWORD_INTERVAL, '90', '\\d+', module: 'Admin'));
|
||||
SettingMapper::create()->execute(new Setting(0, SettingsEnum::PASSWORD_HISTORY, '3', '\\d+', module: 'Admin'));
|
||||
SettingMapper::create()->execute(new Setting(0, SettingsEnum::LOGGING_STATUS, '1', '[0-3]', module: 'Admin'));
|
||||
SettingMapper::create()->execute(new Setting(0, SettingsEnum::LOGGING_PATH, '', module: 'Admin'));
|
||||
|
||||
SettingMapper::create()->execute(new Setting(0, SettingsEnum::DEFAULT_ORGANIZATION, '1', '\\d+'));
|
||||
SettingMapper::create()->execute(new Setting(0, SettingsEnum::DEFAULT_ORGANIZATION, '1', '\\d+', module: 'Admin'));
|
||||
|
||||
SettingMapper::create()->execute(new Setting(0, SettingsEnum::LOGIN_STATUS, '1', '[0-3]'));
|
||||
SettingMapper::create()->execute(new Setting(0, SettingsEnum::LOGIN_STATUS, '1', '[0-3]', module: 'Admin'));
|
||||
|
||||
SettingMapper::create()->execute(new Setting(0, SettingsEnum::DEFAULT_LOCALIZATION, '1', '\\d+'));
|
||||
SettingMapper::create()->execute(new Setting(0, SettingsEnum::DEFAULT_LOCALIZATION, '1', '\\d+', module: 'Admin'));
|
||||
|
||||
SettingMapper::create()->execute(new Setting(0, SettingsEnum::MAIL_SERVER_ADDR, 'admin@karaka.email', "(?:[a-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+\/=?^_`{|}~-]+)*|\"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])", module: 'Admin'));
|
||||
SettingMapper::create()->execute(new Setting(0, SettingsEnum::MAIL_SERVER_TYPE, SubmitType::MAIL, module: 'Admin'));
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ return [
|
|||
],
|
||||
],
|
||||
|
||||
'^.*/admin/module/settings\?id=Admin.*$' => [
|
||||
'^.*/admin/module/settings.*$' => [
|
||||
[
|
||||
'dest' => '\Modules\Admin\Controller\BackendController:viewModuleSettings',
|
||||
'verb' => RouteVerb::GET,
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\Admin\Controller;
|
||||
|
||||
use Model\SettingsEnum;
|
||||
use Modules\Admin\Models\SettingsEnum;
|
||||
use Modules\Admin\Models\Account;
|
||||
use Modules\Admin\Models\AccountCredentialMapper;
|
||||
use Modules\Admin\Models\AccountMapper;
|
||||
|
|
@ -509,7 +509,7 @@ final class ApiController extends Controller
|
|||
->execute()
|
||||
->l11n;
|
||||
|
||||
if ((bool) ($request->getData('load') ?? false)) {
|
||||
if (($request->getData('localization_load') ?? '-1') !== '-1') {
|
||||
$locale = \explode('_', $request->getData('localization_load'));
|
||||
$l11n->loadFromLanguage($locale[0], $locale[1]);
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ namespace Modules\Admin\Controller;
|
|||
|
||||
use Model\NullSetting;
|
||||
use Model\SettingMapper;
|
||||
use Model\SettingsEnum;
|
||||
use Modules\Admin\Models\AccountMapper;
|
||||
use Modules\Admin\Models\AccountPermissionMapper;
|
||||
use Modules\Admin\Models\GroupMapper;
|
||||
|
|
@ -24,6 +23,7 @@ use Modules\Admin\Models\GroupPermissionMapper;
|
|||
use Modules\Admin\Models\LocalizationMapper;
|
||||
use Modules\Admin\Models\NullAccountPermission;
|
||||
use Modules\Admin\Models\NullGroupPermission;
|
||||
use Modules\Admin\Models\SettingsEnum;
|
||||
use Modules\Auditor\Models\AuditMapper;
|
||||
use phpOMS\Contract\RenderableInterface;
|
||||
use phpOMS\Localization\NullLocalization;
|
||||
|
|
@ -529,18 +529,21 @@ final class BackendController extends Controller
|
|||
if ($request->getData('id') === 'Admin') {
|
||||
$view->setTemplate('/Modules/' . ($request->getData('id') ?? '') . '/Admin/Settings/Theme/Backend/settings');
|
||||
} elseif (\is_file(__DIR__ . '/../../' . ($request->getData('id') ?? '') . '/Admin/Settings/Theme/Backend/settings.tpl.php')) {
|
||||
return new NullView();
|
||||
return $this->app->moduleManager->get($request->getData('id'))->viewModuleSettings($request, $response, $data);
|
||||
} else {
|
||||
$view->setTemplate('/Modules/Admin/Theme/Backend/modules-settings');
|
||||
}
|
||||
|
||||
$generalSettings = $this->app->appSettings->get(null, [
|
||||
$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_ORGANIZATION,
|
||||
SettingsEnum::LOGIN_STATUS, SettingsEnum::DEFAULT_LOCALIZATION, SettingsEnum::MAIL_SERVER_ADDR,
|
||||
]);
|
||||
],
|
||||
module: 'Admin'
|
||||
);
|
||||
|
||||
$view->setData('generalSettings', $generalSettings);
|
||||
$view->setData('defaultlocalization', LocalizationMapper::get()->where('id', (int) $generalSettings[SettingsEnum::DEFAULT_LOCALIZATION]->content)->execute());
|
||||
$view->setData('defaultlocalization', LocalizationMapper::get()->where('id', (int) $generalSettings[SettingsEnum::DEFAULT_LOCALIZATION . '::Admin']->content)->execute());
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
|
|
|||
90
Models/SettingsEnum.php
Normal file
90
Models/SettingsEnum.php
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
<?php
|
||||
/**
|
||||
* Karaka
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\Admin\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://karaka.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Admin\Models;
|
||||
|
||||
use phpOMS\Stdlib\Base\Enum;
|
||||
|
||||
/**
|
||||
* Default settings enum.
|
||||
*
|
||||
* @package Modules\Admin\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://karaka.app
|
||||
* @since 1.0.0
|
||||
*/
|
||||
abstract class SettingsEnum extends Enum
|
||||
{
|
||||
/* Logging settings */
|
||||
public const PASSWORD_PATTERN = '1000000001';
|
||||
|
||||
public const LOGIN_TIMEOUT = '1000000002';
|
||||
|
||||
public const PASSWORD_INTERVAL = '1000000003';
|
||||
|
||||
public const PASSWORD_HISTORY = '1000000004';
|
||||
|
||||
public const LOGIN_TRIES = '1000000005';
|
||||
|
||||
public const LOGGING_STATUS = '1000000006';
|
||||
|
||||
public const LOGGING_PATH = '1000000007';
|
||||
|
||||
/* Organization settings */
|
||||
public const DEFAULT_ORGANIZATION = '1000000009';
|
||||
|
||||
/* Login settings */
|
||||
public const LOGIN_FORGOTTEN_COUNT = '1000000010';
|
||||
|
||||
public const LOGIN_FORGOTTEN_DATE = '1000000011';
|
||||
|
||||
public const LOGIN_FORGOTTEN_TOKEN = '1000000012';
|
||||
|
||||
public const LOGIN_STATUS = '1000000013';
|
||||
|
||||
/* Localization settings */
|
||||
public const DEFAULT_LOCALIZATION = '1000000014';
|
||||
|
||||
/* Mail settings */
|
||||
public const MAIL_SERVER_ADDR = '1000000015';
|
||||
|
||||
public const MAIL_SERVER_TYPE = '1000000016';
|
||||
|
||||
public const MAIL_SERVER_USER = '1000000017';
|
||||
|
||||
public const MAIL_SERVER_PASS = '1000000018';
|
||||
|
||||
public const MAIL_SERVER_CERT = '1000000019';
|
||||
|
||||
public const MAIL_SERVER_KEY = '1000000020';
|
||||
|
||||
public const MAIL_SERVER_KEYPASS = '1000000021';
|
||||
|
||||
public const MAIL_SERVER_TLS = '1000000022';
|
||||
|
||||
/* Cli settings */
|
||||
public const CLI_ACTIVE = '1000000023';
|
||||
|
||||
/* Global default templates */
|
||||
public const DEFAULT_PDF_EXPORT_TEMPLATE = '1000000024';
|
||||
|
||||
public const DEFAULT_CSV_EXPORT_TEMPLATE = '1000000025';
|
||||
|
||||
public const DEFAULT_EXCEL_EXPORT_TEMPLATE = '1000000026';
|
||||
|
||||
public const DEFAULT_WORD_EXPORT_TEMPLATE = '1000000027';
|
||||
|
||||
public const DEFAULT_EMAIL_EXPORT_TEMPLATE = '1000000028';
|
||||
|
||||
}
|
||||
|
|
@ -92,14 +92,16 @@ echo $this->getData('nav')->render(); ?>
|
|||
</label>
|
||||
<tbody>
|
||||
<?php
|
||||
$c = 0; foreach ($accounts as $key => $value) : ++$c;
|
||||
$url = UriFactory::build('{/prefix}admin/account/settings?{?}&id=' . $value->getId());
|
||||
$color = 'darkred';
|
||||
$c = 0;
|
||||
foreach ($accounts as $key => $value) : ++$c;
|
||||
$url = UriFactory::build('{/prefix}admin/account/settings?{?}&id=' . $value->getId());
|
||||
$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->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'; }
|
||||
?>
|
||||
<tr tabindex="0" data-href="<?= $url; ?>">
|
||||
<td data-label="<?= $this->getHtml('ID', '0', '0'); ?>"><a href="<?= $url; ?>"><?= $value->getId(); ?></a>
|
||||
<td data-label="<?= $this->getHtml('Status'); ?>"><a href="<?= $url; ?>"><span class="tag <?= $color; ?>"><?= $this->getHtml('Status'. $value->getStatus()); ?></span></a>
|
||||
|
|
|
|||
|
|
@ -272,7 +272,7 @@ echo $this->getData('nav')->render(); ?>
|
|||
<td data-tpl-text="/unit" data-tpl-value="/unit"><?= $value->getUnit(); ?>
|
||||
<td data-tpl-text="/app" data-tpl-value="/app"><?= $value->getApp(); ?>
|
||||
<td data-tpl-text="/module" data-tpl-value="/module"><?= $value->getModule(); ?>
|
||||
<td data-tpl-text="/type" data-tpl-value="/type"><?= $value->getType(); ?>
|
||||
<td data-tpl-text="/type" data-tpl-value="/type"><?= $value->getCategory(); ?>
|
||||
<td data-tpl-text="/ele" data-tpl-value="/ele"><?= $value->getElement(); ?>
|
||||
<td data-tpl-text="/comp" data-tpl-value="/comp"><?= $value->getComponent(); ?>
|
||||
<td>
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
"directory": "Admin",
|
||||
"dependencies": {},
|
||||
"providing": {
|
||||
"Media": "*",
|
||||
"Navigation": "*"
|
||||
},
|
||||
"load": [
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\Admin\tests\Controller\Api;
|
||||
|
||||
use Model\SettingsEnum;
|
||||
use Modules\Admin\Models\SettingsEnum;
|
||||
use phpOMS\Message\Http\HttpRequest;
|
||||
use phpOMS\Message\Http\HttpResponse;
|
||||
use phpOMS\Message\Http\RequestStatusCode;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user