baseline
This commit is contained in:
26
pages/admin/settings/favicon().php
Normal file
26
pages/admin/settings/favicon().php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
use MintyPHP\Router;
|
||||
use MintyPHP\Service\BrandingFaviconService;
|
||||
use MintyPHP\Support\Flash;
|
||||
use MintyPHP\Support\Guard;
|
||||
use MintyPHP\Service\PermissionService;
|
||||
|
||||
Guard::requireLogin();
|
||||
Guard::requirePermission(PermissionService::SETTINGS_UPDATE);
|
||||
|
||||
if (($_SERVER['REQUEST_METHOD'] ?? 'GET') !== 'POST') {
|
||||
Router::redirect('admin/settings');
|
||||
return;
|
||||
}
|
||||
|
||||
$result = BrandingFaviconService::saveUpload($_FILES['favicon'] ?? []);
|
||||
if (!($result['ok'] ?? false)) {
|
||||
$error = $result['error'] ?? t('Upload failed');
|
||||
Flash::error($error, 'admin/settings', 'favicon_upload_failed');
|
||||
Router::redirect('admin/settings');
|
||||
return;
|
||||
}
|
||||
|
||||
Flash::success('Favicon updated', 'admin/settings', 'favicon_updated');
|
||||
Router::redirect('admin/settings');
|
||||
19
pages/admin/settings/favicon-delete().php
Normal file
19
pages/admin/settings/favicon-delete().php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
use MintyPHP\Router;
|
||||
use MintyPHP\Service\BrandingFaviconService;
|
||||
use MintyPHP\Support\Flash;
|
||||
use MintyPHP\Support\Guard;
|
||||
use MintyPHP\Service\PermissionService;
|
||||
|
||||
Guard::requireLogin();
|
||||
Guard::requirePermission(PermissionService::SETTINGS_UPDATE);
|
||||
|
||||
if (($_SERVER['REQUEST_METHOD'] ?? 'GET') !== 'POST') {
|
||||
Router::redirect('admin/settings');
|
||||
return;
|
||||
}
|
||||
|
||||
BrandingFaviconService::delete();
|
||||
Flash::success('Favicon removed', 'admin/settings', 'favicon_removed');
|
||||
Router::redirect('admin/settings');
|
||||
130
pages/admin/settings/index().php
Normal file
130
pages/admin/settings/index().php
Normal file
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
|
||||
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;
|
||||
|
||||
Guard::requireLogin();
|
||||
Guard::requirePermission(PermissionService::SETTINGS_VIEW);
|
||||
|
||||
$tenants = TenantService::list();
|
||||
$roles = RoleService::list();
|
||||
$departments = DepartmentService::list();
|
||||
|
||||
$sortByDescription = static function ($a, $b) {
|
||||
return strcmp((string) ($a['description'] ?? ''), (string) ($b['description'] ?? ''));
|
||||
};
|
||||
usort($tenants, $sortByDescription);
|
||||
usort($roles, $sortByDescription);
|
||||
usort($departments, $sortByDescription);
|
||||
|
||||
$values = [
|
||||
'default_tenant_id' => SettingService::getDefaultTenantId(),
|
||||
'default_role_id' => SettingService::getDefaultRoleId(),
|
||||
'default_department_id' => SettingService::getDefaultDepartmentId(),
|
||||
'app_title' => SettingService::getAppTitle(),
|
||||
'app_locale' => SettingService::getAppLocale(),
|
||||
'app_theme' => SettingService::getAppTheme(),
|
||||
'app_theme_user' => SettingService::isUserThemeAllowed(),
|
||||
'app_primary_color' => SettingService::getAppPrimaryColor(),
|
||||
'smtp_host' => SettingService::getSmtpHost(),
|
||||
'smtp_port' => SettingService::getSmtpPort(),
|
||||
'smtp_user' => SettingService::getSmtpUser(),
|
||||
'smtp_secure' => SettingService::getSmtpSecure(),
|
||||
'smtp_from' => SettingService::getSmtpFrom(),
|
||||
'smtp_from_name' => SettingService::getSmtpFromName(),
|
||||
];
|
||||
$settings = [
|
||||
'default_tenant' => SettingService::get(SettingService::DEFAULT_TENANT_KEY),
|
||||
'default_role' => SettingService::get(SettingService::DEFAULT_ROLE_KEY),
|
||||
'default_department' => SettingService::get(SettingService::DEFAULT_DEPARTMENT_KEY),
|
||||
'app_title' => SettingService::get(SettingService::APP_TITLE_KEY),
|
||||
'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_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),
|
||||
'smtp_user' => SettingService::get(SettingService::SMTP_USER_KEY),
|
||||
'smtp_password' => SettingService::get(SettingService::SMTP_PASSWORD_KEY),
|
||||
'smtp_secure' => SettingService::get(SettingService::SMTP_SECURE_KEY),
|
||||
'smtp_from' => SettingService::get(SettingService::SMTP_FROM_KEY),
|
||||
'smtp_from_name' => SettingService::get(SettingService::SMTP_FROM_NAME_KEY),
|
||||
];
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
if (!isset($_POST['settings_submit'])) {
|
||||
Router::redirect('admin/settings');
|
||||
}
|
||||
Guard::requirePermission(PermissionService::SETTINGS_UPDATE);
|
||||
$defaultTenantId = (int) ($_POST['default_tenant_id'] ?? 0);
|
||||
$defaultRoleId = (int) ($_POST['default_role_id'] ?? 0);
|
||||
$defaultDepartmentId = (int) ($_POST['default_department_id'] ?? 0);
|
||||
$appTitle = trim((string) ($_POST['app_title'] ?? ''));
|
||||
$appLocale = trim((string) ($_POST['app_locale'] ?? ''));
|
||||
$appTheme = trim((string) ($_POST['app_theme'] ?? ''));
|
||||
$appThemeUser = isset($_POST['app_theme_user']);
|
||||
$rawPrimaryColor = $_POST['app_primary_color'] ?? '';
|
||||
if (is_array($rawPrimaryColor)) {
|
||||
$rawPrimaryColor = '';
|
||||
}
|
||||
$appPrimaryColor = trim((string) $rawPrimaryColor);
|
||||
if (in_array(strtolower($appPrimaryColor), ['null', 'undefined'], true)) {
|
||||
$appPrimaryColor = '';
|
||||
}
|
||||
$smtpHost = trim((string) ($_POST['smtp_host'] ?? ''));
|
||||
$smtpPort = (int) ($_POST['smtp_port'] ?? 0);
|
||||
$smtpUser = trim((string) ($_POST['smtp_user'] ?? ''));
|
||||
$smtpPassword = (string) ($_POST['smtp_password'] ?? '');
|
||||
$smtpSecure = trim((string) ($_POST['smtp_secure'] ?? ''));
|
||||
$smtpFrom = trim((string) ($_POST['smtp_from'] ?? ''));
|
||||
$smtpFromName = trim((string) ($_POST['smtp_from_name'] ?? ''));
|
||||
|
||||
SettingService::setDefaultTenantId($defaultTenantId > 0 ? $defaultTenantId : null);
|
||||
SettingService::setDefaultRoleId($defaultRoleId > 0 ? $defaultRoleId : null);
|
||||
SettingService::setDefaultDepartmentId($defaultDepartmentId > 0 ? $defaultDepartmentId : null);
|
||||
SettingService::setAppTitle($appTitle);
|
||||
SettingService::setAppLocale($appLocale);
|
||||
SettingService::setAppTheme($appTheme);
|
||||
SettingService::setUserThemeAllowed($appThemeUser);
|
||||
$primaryOk = SettingService::setAppPrimaryColor($appPrimaryColor);
|
||||
if (!$primaryOk) {
|
||||
$appPrimaryColor = '';
|
||||
Flash::error('Primary color is invalid', 'admin/settings', 'app_primary_invalid');
|
||||
}
|
||||
SettingService::setSmtpHost($smtpHost);
|
||||
SettingService::setSmtpPort($smtpPort > 0 ? $smtpPort : null);
|
||||
SettingService::setSmtpUser($smtpUser);
|
||||
if (trim($smtpPassword) !== '') {
|
||||
SettingService::setSmtpPassword($smtpPassword);
|
||||
}
|
||||
SettingService::setSmtpSecure($smtpSecure);
|
||||
SettingService::setSmtpFrom($smtpFrom);
|
||||
SettingService::setSmtpFromName($smtpFromName);
|
||||
|
||||
$cacheFile = __DIR__ . '/../../../config/settings.php';
|
||||
$cacheData = [];
|
||||
if (is_file($cacheFile)) {
|
||||
$existing = include $cacheFile;
|
||||
if (is_array($existing)) {
|
||||
$cacheData = $existing;
|
||||
}
|
||||
}
|
||||
$cacheData['app_title'] = $appTitle !== '' ? $appTitle : null;
|
||||
$cacheData['app_locale'] = $appLocale !== '' ? $appLocale : null;
|
||||
$cacheData['app_theme'] = $appTheme !== '' ? $appTheme : null;
|
||||
$cacheData['app_theme_user'] = $appThemeUser ? '1' : '0';
|
||||
$cacheData['app_primary_color'] = $appPrimaryColor !== '' ? $appPrimaryColor : null;
|
||||
file_put_contents($cacheFile, "<?php\nreturn " . var_export($cacheData, true) . ";\n");
|
||||
|
||||
Flash::success('Settings updated', 'admin/settings', 'settings_updated');
|
||||
Router::redirect('admin/settings');
|
||||
}
|
||||
|
||||
Buffer::set('title', t('Settings'));
|
||||
353
pages/admin/settings/index(default).phtml
Normal file
353
pages/admin/settings/index(default).phtml
Normal file
@@ -0,0 +1,353 @@
|
||||
<?php
|
||||
/**
|
||||
* @var array $tenants
|
||||
* @var array $roles
|
||||
* @var array $departments
|
||||
* @var array $values
|
||||
* @var array $settings
|
||||
*/
|
||||
|
||||
use MintyPHP\Session;
|
||||
use MintyPHP\Service\BrandingLogoService;
|
||||
use MintyPHP\Service\BrandingFaviconService;
|
||||
|
||||
$values = $values ?? [];
|
||||
$settings = $settings ?? [];
|
||||
$defaultTenantId = (int) ($values['default_tenant_id'] ?? 0);
|
||||
$defaultRoleId = (int) ($values['default_role_id'] ?? 0);
|
||||
$defaultDepartmentId = (int) ($values['default_department_id'] ?? 0);
|
||||
$appTitle = (string) ($values['app_title'] ?? '');
|
||||
$appLocale = (string) ($values['app_locale'] ?? '');
|
||||
$appTheme = (string) ($values['app_theme'] ?? '');
|
||||
$appThemeUser = !empty($values['app_theme_user']);
|
||||
$appPrimaryColor = (string) ($values['app_primary_color'] ?? '');
|
||||
$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'] ?? '');
|
||||
$defaultTenantDesc = $settings['default_tenant']['description'] ?? 'setting.default_tenant';
|
||||
$defaultRoleDesc = $settings['default_role']['description'] ?? 'setting.default_role';
|
||||
$defaultDepartmentDesc = $settings['default_department']['description'] ?? 'setting.default_department';
|
||||
$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';
|
||||
$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';
|
||||
$smtpUserDesc = $settings['smtp_user']['description'] ?? 'setting.smtp_user';
|
||||
$smtpPasswordDesc = $settings['smtp_password']['description'] ?? 'setting.smtp_password';
|
||||
$smtpSecureDesc = $settings['smtp_secure']['description'] ?? 'setting.smtp_secure';
|
||||
$smtpFromDesc = $settings['smtp_from']['description'] ?? 'setting.smtp_from';
|
||||
$smtpFromNameDesc = $settings['smtp_from_name']['description'] ?? 'setting.smtp_from_name';
|
||||
$locales = defined('APP_LOCALES') ? APP_LOCALES : [];
|
||||
$hasLogo = BrandingLogoService::hasLogo();
|
||||
$hasFavicon = BrandingFaviconService::hasFavicon();
|
||||
$canUpdateSettings = can('settings.update');
|
||||
$isReadOnly = !$canUpdateSettings;
|
||||
$readonlyAttr = $isReadOnly ? 'readonly' : '';
|
||||
$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>
|
||||
<div class="app-details-titlebar">
|
||||
<h1>
|
||||
<?php e(t('Settings')); ?>
|
||||
</h1>
|
||||
<div class="app-details-titlebar-actions">
|
||||
<?php if ($canUpdateSettings): ?>
|
||||
<button type="submit" form="settings-form" class="primary">
|
||||
<?php e(t('Save')); ?>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form id="settings-form" method="post">
|
||||
<input type="hidden" name="settings_submit" value="1">
|
||||
<details name="general" open>
|
||||
<summary><?php e(t('General')); ?></summary>
|
||||
<hr>
|
||||
<label class="app-field">
|
||||
<span><?php e(t('App title')); ?></span>
|
||||
<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>
|
||||
</details>
|
||||
<hr>
|
||||
<details name="appearance">
|
||||
<summary><?php e(t('Appearance')); ?></summary>
|
||||
<hr>
|
||||
<div class="grid">
|
||||
<fieldset>
|
||||
<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>
|
||||
</select>
|
||||
<small><?php e(t($appThemeDesc)); ?></small>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend><small><?php e(t('Primary color')); ?></small></legend>
|
||||
<label class="app-field">
|
||||
<input type="color" name="app_primary_color"
|
||||
value="<?php e($appPrimaryColor !== '' ? $appPrimaryColor : '#2fa4a4'); ?>" <?php e($disabledAttr); ?>>
|
||||
<div>
|
||||
<div>
|
||||
<?php e(t('Choose color')); ?>
|
||||
</div>
|
||||
</div>
|
||||
</label>
|
||||
<small class="muted"><?php e(t($appPrimaryColorDesc)); ?></small>
|
||||
</fieldset>
|
||||
</div>
|
||||
<blockquote data-variant="info">
|
||||
<?php e(t('Tenants can override this color in their appearance settings.')); ?>
|
||||
</blockquote>
|
||||
<fieldset>
|
||||
<legend>
|
||||
<small>
|
||||
<?php e(t($appThemeUserDesc)); ?>
|
||||
</small>
|
||||
</legend>
|
||||
<label class="app-field">
|
||||
<input type="checkbox" name="app_theme_user" value="1" <?php e($appThemeUser ? 'checked' : ''); ?> <?php e($disabledAttr); ?>>
|
||||
<span><?php e(t('Allow user theme')); ?></span>
|
||||
</label>
|
||||
</fieldset>
|
||||
</details>
|
||||
<hr>
|
||||
<details name="smtp">
|
||||
<summary><?php e(t('Email settings')); ?></summary>
|
||||
<hr>
|
||||
<div class="grid">
|
||||
<label class="app-field">
|
||||
<span><?php e(t('SMTP host')); ?></span>
|
||||
<input type="text" name="smtp_host" value="<?php e($smtpHost); ?>" <?php e($readonlyAttr); ?>>
|
||||
<small><?php e(t($smtpHostDesc)); ?></small>
|
||||
</label>
|
||||
<label class="app-field">
|
||||
<span><?php e(t('SMTP port')); ?></span>
|
||||
<input type="number" name="smtp_port" value="<?php e($smtpPort); ?>" min="1" max="65535" <?php e($readonlyAttr); ?>>
|
||||
<small><?php e(t($smtpPortDesc)); ?></small>
|
||||
</label>
|
||||
</div>
|
||||
<div class="grid">
|
||||
<label class="app-field">
|
||||
<span><?php e(t('SMTP user')); ?></span>
|
||||
<input type="text" name="smtp_user" value="<?php e($smtpUser); ?>" autocomplete="username" <?php e($readonlyAttr); ?>>
|
||||
<small><?php e(t($smtpUserDesc)); ?></small>
|
||||
</label>
|
||||
<label class="app-field">
|
||||
<span><?php e(t('SMTP password')); ?></span>
|
||||
<input type="password" name="smtp_password" value="" autocomplete="new-password" <?php e($readonlyAttr); ?>>
|
||||
<small><?php e(t($smtpPasswordDesc)); ?></small>
|
||||
</label>
|
||||
</div>
|
||||
<div class="grid">
|
||||
<label class="app-field">
|
||||
<span><?php e(t('SMTP security')); ?></span>
|
||||
<select name="smtp_secure" <?php e($disabledAttr); ?>>
|
||||
<option value=""><?php e(t('None')); ?></option>
|
||||
<option value="tls" <?php e($smtpSecure === 'tls' ? 'selected' : ''); ?>>TLS</option>
|
||||
<option value="ssl" <?php e($smtpSecure === 'ssl' ? 'selected' : ''); ?>>SSL</option>
|
||||
</select>
|
||||
<small><?php e(t($smtpSecureDesc)); ?></small>
|
||||
</label>
|
||||
<label class="app-field">
|
||||
<span><?php e(t('SMTP from address')); ?></span>
|
||||
<input type="email" name="smtp_from" value="<?php e($smtpFrom); ?>" <?php e($readonlyAttr); ?>>
|
||||
<small><?php e(t($smtpFromDesc)); ?></small>
|
||||
</label>
|
||||
</div>
|
||||
<label class="app-field">
|
||||
<span><?php e(t('SMTP from name')); ?></span>
|
||||
<input type="text" name="smtp_from_name" value="<?php e($smtpFromName); ?>" <?php e($readonlyAttr); ?>>
|
||||
<small><?php e(t($smtpFromNameDesc)); ?></small>
|
||||
</label>
|
||||
</details>
|
||||
<hr>
|
||||
<details name="internationalization">
|
||||
<summary><?php e(t('Internationalization')); ?></summary>
|
||||
<hr>
|
||||
<label class="app-field">
|
||||
<span><?php e(t('Default language')); ?></span>
|
||||
<select name="app_locale" <?php e($disabledAttr); ?>>
|
||||
<option value=""><?php e(t('None')); ?></option>
|
||||
<?php foreach ($locales as $locale): ?>
|
||||
<?php
|
||||
$label = strtoupper($locale);
|
||||
if ($locale === 'de') {
|
||||
$label = t('German');
|
||||
} elseif ($locale === 'en') {
|
||||
$label = t('English');
|
||||
}
|
||||
?>
|
||||
<option value="<?php e($locale); ?>" <?php e($appLocale === $locale ? 'selected' : ''); ?>>
|
||||
<?php e($label); ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<small><?php e(t($appLocaleDesc)); ?></small>
|
||||
</label>
|
||||
</details>
|
||||
<hr>
|
||||
<details name="user-creation">
|
||||
<summary><?php e(t('User creation rules')); ?></summary>
|
||||
<hr>
|
||||
<div class="grid">
|
||||
<label class="app-field">
|
||||
<span>
|
||||
<?php e(t('Default tenant')); ?>
|
||||
</span>
|
||||
<select name="default_tenant_id" <?php e($disabledAttr); ?>>
|
||||
<option value="">
|
||||
<?php e(t('None')); ?>
|
||||
</option>
|
||||
<?php foreach ($tenants ?? [] as $tenant): ?>
|
||||
<?php $tenantId = (int) ($tenant['id'] ?? 0); ?>
|
||||
<?php if ($tenantId > 0): ?>
|
||||
<option value="<?php e((string) $tenantId); ?>" <?php e($tenantId === $defaultTenantId ? 'selected' : ''); ?>>
|
||||
<?php e($tenant['description'] ?? ''); ?>
|
||||
</option>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<small>
|
||||
<?php e(t($defaultTenantDesc)); ?>
|
||||
</small>
|
||||
</label>
|
||||
<label class="app-field">
|
||||
<span>
|
||||
<?php e(t('Default department')); ?>
|
||||
</span>
|
||||
<select name="default_department_id" <?php e($disabledAttr); ?>>
|
||||
<option value="">
|
||||
<?php e(t('None')); ?>
|
||||
</option>
|
||||
<?php foreach ($departments ?? [] as $department): ?>
|
||||
<?php $departmentId = (int) ($department['id'] ?? 0); ?>
|
||||
<?php if ($departmentId > 0): ?>
|
||||
<option value="<?php e((string) $departmentId); ?>" <?php e($departmentId === $defaultDepartmentId ? 'selected' : ''); ?>>
|
||||
<?php e($department['description'] ?? ''); ?>
|
||||
</option>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<small>
|
||||
<?php e(t($defaultDepartmentDesc)); ?>
|
||||
</small>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<label class="app-field">
|
||||
<span><?php e(t('Default role')); ?></span>
|
||||
<select name="default_role_id" <?php e($disabledAttr); ?>>
|
||||
<option value=""><?php e(t('None')); ?></option>
|
||||
<?php foreach ($roles ?? [] as $role): ?>
|
||||
<?php $roleId = (int) ($role['id'] ?? 0); ?>
|
||||
<?php if ($roleId > 0): ?>
|
||||
<option value="<?php e((string) $roleId); ?>" <?php e($roleId === $defaultRoleId ? 'selected' : ''); ?>>
|
||||
<?php e($role['description'] ?? ''); ?>
|
||||
</option>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<small><?php e(t($defaultRoleDesc)); ?></small>
|
||||
</label>
|
||||
|
||||
</details>
|
||||
<hr>
|
||||
<?php Session::getCsrfInput(); ?>
|
||||
</form>
|
||||
</section>
|
||||
<aside id="app-details-aside-section">
|
||||
<div class="app-details-aside-section">
|
||||
<div class="entity-avatar-block avatar-square avatar-ratio-16-9 avatar-borderless">
|
||||
<a data-fslightbox="app-logo" href="<?php e(appLogoUrl(256)); ?>">
|
||||
<img class="entity-avatar-image" src="<?php e(appLogoUrl(256)); ?>" alt="<?php e(t('App logo')); ?>">
|
||||
</a>
|
||||
</div>
|
||||
<hgroup>
|
||||
<h2><?php e(appTitle()); ?></h2>
|
||||
<p><?php e(t('Settings')); ?></p>
|
||||
</hgroup>
|
||||
<hr>
|
||||
<?php if ($canUpdateSettings): ?>
|
||||
<details name="app-logo">
|
||||
<summary>
|
||||
<?php e(t('Upload logo')); ?>
|
||||
</summary>
|
||||
<hr>
|
||||
<small>
|
||||
<?php e(t('Allowed file types: SVG, PNG, JPG, WEBP')); ?>
|
||||
</small>
|
||||
<hr>
|
||||
<form class="user-avatar-form" method="post" action="admin/settings/logo" enctype="multipart/form-data">
|
||||
<label class="user-avatar-upload">
|
||||
<input type="file" name="logo" accept="image/svg+xml,image/png,image/jpeg,image/webp">
|
||||
</label>
|
||||
<div class="grid">
|
||||
<button type="submit" class="primary">
|
||||
<?php e(t('Save')); ?>
|
||||
</button>
|
||||
<?php if ($hasLogo): ?>
|
||||
<button type="submit" class="danger" formaction="admin/settings/logo-delete" formmethod="post">
|
||||
<?php e(t('Remove logo')); ?>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php Session::getCsrfInput(); ?>
|
||||
</form>
|
||||
</details>
|
||||
<?php endif; ?>
|
||||
<hr>
|
||||
<?php if ($canUpdateSettings): ?>
|
||||
<details name="app-favicon">
|
||||
<summary>
|
||||
<?php e(t('Upload favicon')); ?>
|
||||
</summary>
|
||||
<hr>
|
||||
<?php if ($hasFavicon): ?>
|
||||
<div class="entity-avatar-block avatar-square avatar-borderless" style="--avatar-size: 48px;">
|
||||
<img class="entity-avatar-image" src="<?php e(asset('favicon/favicon-32x32.png')); ?>"
|
||||
alt="<?php e(t('Favicon')); ?>">
|
||||
</div>
|
||||
<small><?php e(t('Favicon preview')); ?></small>
|
||||
<hr>
|
||||
<?php endif; ?>
|
||||
<small><?php e(t('Allowed file types: PNG')); ?></small>
|
||||
<small><?php e(t('Square images are recommended (icons are center-cropped).')); ?></small>
|
||||
<hr>
|
||||
<form class="user-avatar-form" method="post" action="admin/settings/favicon" enctype="multipart/form-data">
|
||||
<label class="user-avatar-upload">
|
||||
<input type="file" name="favicon" accept="image/png">
|
||||
</label>
|
||||
<div class="grid">
|
||||
<button type="submit" class="primary">
|
||||
<?php e(t('Save')); ?>
|
||||
</button>
|
||||
<?php if ($hasFavicon): ?>
|
||||
<button type="submit" class="danger" formaction="admin/settings/favicon-delete" formmethod="post">
|
||||
<?php e(t('Remove favicon')); ?>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php Session::getCsrfInput(); ?>
|
||||
</form>
|
||||
</details>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</aside>
|
||||
</div>
|
||||
26
pages/admin/settings/logo().php
Normal file
26
pages/admin/settings/logo().php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
use MintyPHP\Router;
|
||||
use MintyPHP\Service\BrandingLogoService;
|
||||
use MintyPHP\Support\Flash;
|
||||
use MintyPHP\Support\Guard;
|
||||
use MintyPHP\Service\PermissionService;
|
||||
|
||||
Guard::requireLogin();
|
||||
Guard::requirePermission(PermissionService::SETTINGS_UPDATE);
|
||||
|
||||
if (($_SERVER['REQUEST_METHOD'] ?? 'GET') !== 'POST') {
|
||||
Router::redirect('admin/settings');
|
||||
return;
|
||||
}
|
||||
|
||||
$result = BrandingLogoService::saveUpload($_FILES['logo'] ?? []);
|
||||
if (!($result['ok'] ?? false)) {
|
||||
$error = $result['error'] ?? t('Upload failed');
|
||||
Flash::error($error, 'admin/settings', 'logo_upload_failed');
|
||||
Router::redirect('admin/settings');
|
||||
return;
|
||||
}
|
||||
|
||||
Flash::success('Logo updated', 'admin/settings', 'logo_updated');
|
||||
Router::redirect('admin/settings');
|
||||
19
pages/admin/settings/logo-delete().php
Normal file
19
pages/admin/settings/logo-delete().php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
use MintyPHP\Router;
|
||||
use MintyPHP\Service\BrandingLogoService;
|
||||
use MintyPHP\Support\Flash;
|
||||
use MintyPHP\Support\Guard;
|
||||
use MintyPHP\Service\PermissionService;
|
||||
|
||||
Guard::requireLogin();
|
||||
Guard::requirePermission(PermissionService::SETTINGS_UPDATE);
|
||||
|
||||
if (($_SERVER['REQUEST_METHOD'] ?? 'GET') !== 'POST') {
|
||||
Router::redirect('admin/settings');
|
||||
return;
|
||||
}
|
||||
|
||||
BrandingLogoService::delete();
|
||||
Flash::success('Logo removed', 'admin/settings', 'logo_removed');
|
||||
Router::redirect('admin/settings');
|
||||
Reference in New Issue
Block a user