big restructure
This commit is contained in:
18
pages/admin/settings/expire-remember-tokens().php
Normal file
18
pages/admin/settings/expire-remember-tokens().php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
use MintyPHP\Support\Flash;
|
||||
use MintyPHP\Support\Guard;
|
||||
use MintyPHP\Router;
|
||||
use MintyPHP\Service\Access\PermissionService;
|
||||
use MintyPHP\Service\Auth\RememberMeService;
|
||||
|
||||
Guard::requireLogin();
|
||||
Guard::requirePermission(PermissionService::SETTINGS_UPDATE);
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
Router::redirect('admin/settings');
|
||||
}
|
||||
|
||||
$count = RememberMeService::expireAllTokensByAdmin();
|
||||
Flash::success(sprintf(t('%d login tokens expired'), $count), 'admin/settings', 'login_tokens_expired');
|
||||
Router::redirect('admin/settings');
|
||||
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
|
||||
use MintyPHP\Router;
|
||||
use MintyPHP\Service\BrandingFaviconService;
|
||||
use MintyPHP\Service\Branding\BrandingFaviconService;
|
||||
use MintyPHP\Support\Flash;
|
||||
use MintyPHP\Support\Guard;
|
||||
use MintyPHP\Service\PermissionService;
|
||||
use MintyPHP\Service\Access\PermissionService;
|
||||
|
||||
Guard::requireLogin();
|
||||
Guard::requirePermission(PermissionService::SETTINGS_UPDATE);
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
|
||||
use MintyPHP\Router;
|
||||
use MintyPHP\Service\BrandingFaviconService;
|
||||
use MintyPHP\Service\Branding\BrandingFaviconService;
|
||||
use MintyPHP\Support\Flash;
|
||||
use MintyPHP\Support\Guard;
|
||||
use MintyPHP\Service\PermissionService;
|
||||
use MintyPHP\Service\Access\PermissionService;
|
||||
|
||||
Guard::requireLogin();
|
||||
Guard::requirePermission(PermissionService::SETTINGS_UPDATE);
|
||||
|
||||
@@ -4,17 +4,18 @@ use MintyPHP\Buffer;
|
||||
use MintyPHP\Support\Flash;
|
||||
use MintyPHP\Support\Guard;
|
||||
use MintyPHP\Router;
|
||||
use MintyPHP\Service\SettingService;
|
||||
use MintyPHP\Service\TenantService;
|
||||
use MintyPHP\Service\RoleService;
|
||||
use MintyPHP\Service\DepartmentService;
|
||||
use MintyPHP\Service\PermissionService;
|
||||
use MintyPHP\Service\Settings\SettingService;
|
||||
use MintyPHP\Service\Tenant\TenantService;
|
||||
use MintyPHP\Service\Access\RoleService;
|
||||
use MintyPHP\Service\Org\DepartmentService;
|
||||
use MintyPHP\Service\Access\PermissionService;
|
||||
use MintyPHP\Repository\Auth\RememberTokenRepository;
|
||||
|
||||
Guard::requireLogin();
|
||||
Guard::requirePermission(PermissionService::SETTINGS_VIEW);
|
||||
|
||||
$tenants = TenantService::list();
|
||||
$roles = RoleService::list();
|
||||
$roles = RoleService::listActive();
|
||||
$departments = DepartmentService::list();
|
||||
|
||||
$sortByDescription = static function ($a, $b) {
|
||||
@@ -32,6 +33,7 @@ $values = [
|
||||
'app_locale' => SettingService::getAppLocale(),
|
||||
'app_theme' => SettingService::getAppTheme(),
|
||||
'app_theme_user' => SettingService::isUserThemeAllowed(),
|
||||
'app_registration' => SettingService::isRegistrationEnabled(),
|
||||
'app_primary_color' => SettingService::getAppPrimaryColor(),
|
||||
'smtp_host' => SettingService::getSmtpHost(),
|
||||
'smtp_port' => SettingService::getSmtpPort(),
|
||||
@@ -40,6 +42,7 @@ $values = [
|
||||
'smtp_from' => SettingService::getSmtpFrom(),
|
||||
'smtp_from_name' => SettingService::getSmtpFromName(),
|
||||
];
|
||||
$activeLoginTokens = RememberTokenRepository::countActive();
|
||||
$settings = [
|
||||
'default_tenant' => SettingService::get(SettingService::DEFAULT_TENANT_KEY),
|
||||
'default_role' => SettingService::get(SettingService::DEFAULT_ROLE_KEY),
|
||||
@@ -48,6 +51,7 @@ $settings = [
|
||||
'app_locale' => SettingService::get(SettingService::APP_LOCALE_KEY),
|
||||
'app_theme' => SettingService::get(SettingService::APP_THEME_KEY),
|
||||
'app_theme_user' => SettingService::get(SettingService::APP_THEME_USER_KEY),
|
||||
'app_registration' => SettingService::get(SettingService::APP_REGISTRATION_KEY),
|
||||
'app_primary_color' => SettingService::get(SettingService::APP_PRIMARY_COLOR_KEY),
|
||||
'smtp_host' => SettingService::get(SettingService::SMTP_HOST_KEY),
|
||||
'smtp_port' => SettingService::get(SettingService::SMTP_PORT_KEY),
|
||||
@@ -70,6 +74,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$appLocale = trim((string) ($_POST['app_locale'] ?? ''));
|
||||
$appTheme = trim((string) ($_POST['app_theme'] ?? ''));
|
||||
$appThemeUser = isset($_POST['app_theme_user']);
|
||||
$appRegistration = isset($_POST['app_registration']);
|
||||
$rawPrimaryColor = $_POST['app_primary_color'] ?? '';
|
||||
if (is_array($rawPrimaryColor)) {
|
||||
$rawPrimaryColor = '';
|
||||
@@ -93,6 +98,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
SettingService::setAppLocale($appLocale);
|
||||
SettingService::setAppTheme($appTheme);
|
||||
SettingService::setUserThemeAllowed($appThemeUser);
|
||||
SettingService::setRegistrationEnabled($appRegistration);
|
||||
$primaryOk = SettingService::setAppPrimaryColor($appPrimaryColor);
|
||||
if (!$primaryOk) {
|
||||
$appPrimaryColor = '';
|
||||
@@ -120,6 +126,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$cacheData['app_locale'] = $appLocale !== '' ? $appLocale : null;
|
||||
$cacheData['app_theme'] = $appTheme !== '' ? $appTheme : null;
|
||||
$cacheData['app_theme_user'] = $appThemeUser ? '1' : '0';
|
||||
$cacheData['app_registration'] = $appRegistration ? '1' : '0';
|
||||
$cacheData['app_primary_color'] = $appPrimaryColor !== '' ? $appPrimaryColor : null;
|
||||
file_put_contents($cacheFile, "<?php\nreturn " . var_export($cacheData, true) . ";\n");
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
*/
|
||||
|
||||
use MintyPHP\Session;
|
||||
use MintyPHP\Service\BrandingLogoService;
|
||||
use MintyPHP\Service\BrandingFaviconService;
|
||||
use MintyPHP\Service\Branding\BrandingLogoService;
|
||||
use MintyPHP\Service\Branding\BrandingFaviconService;
|
||||
|
||||
$values = $values ?? [];
|
||||
$settings = $settings ?? [];
|
||||
@@ -20,13 +20,16 @@ $appTitle = (string) ($values['app_title'] ?? '');
|
||||
$appLocale = (string) ($values['app_locale'] ?? '');
|
||||
$appTheme = (string) ($values['app_theme'] ?? '');
|
||||
$appThemeUser = !empty($values['app_theme_user']);
|
||||
$appRegistration = !empty($values['app_registration']);
|
||||
$appPrimaryColor = (string) ($values['app_primary_color'] ?? '');
|
||||
$themes = appThemes();
|
||||
$smtpHost = (string) ($values['smtp_host'] ?? '');
|
||||
$smtpPort = (string) ($values['smtp_port'] ?? '');
|
||||
$smtpUser = (string) ($values['smtp_user'] ?? '');
|
||||
$smtpSecure = (string) ($values['smtp_secure'] ?? '');
|
||||
$smtpFrom = (string) ($values['smtp_from'] ?? '');
|
||||
$smtpFromName = (string) ($values['smtp_from_name'] ?? '');
|
||||
$activeLoginTokens = (int) ($activeLoginTokens ?? 0);
|
||||
$defaultTenantDesc = $settings['default_tenant']['description'] ?? 'setting.default_tenant';
|
||||
$defaultRoleDesc = $settings['default_role']['description'] ?? 'setting.default_role';
|
||||
$defaultDepartmentDesc = $settings['default_department']['description'] ?? 'setting.default_department';
|
||||
@@ -34,6 +37,7 @@ $appTitleDesc = $settings['app_title']['description'] ?? 'setting.app_title';
|
||||
$appLocaleDesc = $settings['app_locale']['description'] ?? 'setting.app_locale';
|
||||
$appThemeDesc = $settings['app_theme']['description'] ?? 'setting.app_theme';
|
||||
$appThemeUserDesc = $settings['app_theme_user']['description'] ?? 'setting.app_theme_user';
|
||||
$appRegistrationDesc = $settings['app_registration']['description'] ?? 'setting.app_registration';
|
||||
$appPrimaryColorDesc = $settings['app_primary_color']['description'] ?? 'setting.app_primary_color';
|
||||
$smtpHostDesc = $settings['smtp_host']['description'] ?? 'setting.smtp_host';
|
||||
$smtpPortDesc = $settings['smtp_port']['description'] ?? 'setting.smtp_port';
|
||||
@@ -53,9 +57,13 @@ $disabledAttr = $isReadOnly ? 'disabled' : '';
|
||||
|
||||
<div class="app-details-container">
|
||||
<section>
|
||||
<div class="app-breadcrumb">
|
||||
<a href="/admin">Startseite</a><i class="bi bi-chevron-right"></i><?php e(t('Settings')); ?>
|
||||
</div>
|
||||
<?php
|
||||
$breadcrumbs = [
|
||||
['label' => t('Home'), 'path' => 'admin'],
|
||||
['label' => t('Settings')],
|
||||
];
|
||||
require templatePath('partials/app-breadcrumb.phtml');
|
||||
?>
|
||||
<div class="app-details-titlebar">
|
||||
<h1>
|
||||
<?php e(t('Settings')); ?>
|
||||
@@ -79,6 +87,18 @@ $disabledAttr = $isReadOnly ? 'disabled' : '';
|
||||
<input type="text" name="app_title" value="<?php e($appTitle); ?>" placeholder="<?php e(APP_NAME); ?>" <?php e($readonlyAttr); ?>>
|
||||
<small><?php e(t($appTitleDesc)); ?></small>
|
||||
</label>
|
||||
<fieldset>
|
||||
<legend>
|
||||
<small>
|
||||
<?php e(t($appRegistrationDesc)); ?>
|
||||
</small>
|
||||
</legend>
|
||||
<label class="app-field">
|
||||
<input type="checkbox" name="app_registration" value="1" <?php e($appRegistration ? 'checked' : ''); ?>
|
||||
<?php e($disabledAttr); ?>>
|
||||
<span><?php e(t('Allow registration')); ?></span>
|
||||
</label>
|
||||
</fieldset>
|
||||
</details>
|
||||
<hr>
|
||||
<details name="appearance">
|
||||
@@ -89,12 +109,11 @@ $disabledAttr = $isReadOnly ? 'disabled' : '';
|
||||
<legend><small><?php e(t('Default theme')); ?></small></legend>
|
||||
<select name="app_theme" <?php e($disabledAttr); ?>>
|
||||
<option value=""><?php e(t('None')); ?></option>
|
||||
<option value="light" <?php e($appTheme === 'light' ? 'selected' : ''); ?>>
|
||||
<?php e(t('Light')); ?>
|
||||
</option>
|
||||
<option value="dark" <?php e($appTheme === 'dark' ? 'selected' : ''); ?>>
|
||||
<?php e(t('Dark')); ?>
|
||||
</option>
|
||||
<?php foreach ($themes as $key => $label): ?>
|
||||
<option value="<?php e($key); ?>" <?php e($appTheme === $key ? 'selected' : ''); ?>>
|
||||
<?php e(t($label)); ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<small><?php e(t($appThemeDesc)); ?></small>
|
||||
</fieldset>
|
||||
@@ -271,6 +290,31 @@ $disabledAttr = $isReadOnly ? 'disabled' : '';
|
||||
<hr>
|
||||
<?php Session::getCsrfInput(); ?>
|
||||
</form>
|
||||
<?php if ($canUpdateSettings): ?>
|
||||
<div>
|
||||
<details name="danger-zone">
|
||||
<summary><?php e(t('Danger zone')); ?></summary>
|
||||
<hr>
|
||||
<fieldset>
|
||||
<legend><small><?php e(t('Login tokens')); ?></small></legend>
|
||||
<p class="muted">
|
||||
<?php e(t('This will mark all remember-me tokens as expired. Users will need to sign in again.')); ?>
|
||||
</p>
|
||||
<p class="muted">
|
||||
<?php e(sprintf(t('%d active login tokens'), $activeLoginTokens)); ?>
|
||||
</p>
|
||||
<form method="post" action="admin/settings/expire-remember-tokens"
|
||||
onsubmit="return confirm('<?php e(t('Expire all login tokens?')); ?>');">
|
||||
<button type="submit" class="danger">
|
||||
<?php e(t('Expire all login tokens')); ?>
|
||||
</button>
|
||||
<?php Session::getCsrfInput(); ?>
|
||||
</form>
|
||||
</fieldset>
|
||||
</details>
|
||||
<hr>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</section>
|
||||
<aside id="app-details-aside-section">
|
||||
<div class="app-details-aside-section">
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
|
||||
use MintyPHP\Router;
|
||||
use MintyPHP\Service\BrandingLogoService;
|
||||
use MintyPHP\Service\Branding\BrandingLogoService;
|
||||
use MintyPHP\Support\Flash;
|
||||
use MintyPHP\Support\Guard;
|
||||
use MintyPHP\Service\PermissionService;
|
||||
use MintyPHP\Service\Access\PermissionService;
|
||||
|
||||
Guard::requireLogin();
|
||||
Guard::requirePermission(PermissionService::SETTINGS_UPDATE);
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
|
||||
use MintyPHP\Router;
|
||||
use MintyPHP\Service\BrandingLogoService;
|
||||
use MintyPHP\Service\Branding\BrandingLogoService;
|
||||
use MintyPHP\Support\Flash;
|
||||
use MintyPHP\Support\Guard;
|
||||
use MintyPHP\Service\PermissionService;
|
||||
use MintyPHP\Service\Access\PermissionService;
|
||||
|
||||
Guard::requireLogin();
|
||||
Guard::requirePermission(PermissionService::SETTINGS_UPDATE);
|
||||
|
||||
Reference in New Issue
Block a user