xyxc
All checks were successful
Deploy / deploy-production (push) Has been skipped
Deploy / deploy-staging (push) Successful in 6s

This commit is contained in:
2026-05-06 00:38:16 +02:00
parent 7eeed06a40
commit bec6fb1e0a
2 changed files with 102 additions and 61 deletions

View File

@@ -5,6 +5,7 @@ $error = null;
$notice = null;
$testGroup = null;
$dbTestMessages = [];
$currentSection = trim((string) ($_GET['section'] ?? 'general'));
require_admin();
@@ -14,6 +15,11 @@ if (!$module) {
return;
}
$allowedSetupSections = ['general', 'access', 'cron', 'custom'];
if (!in_array($currentSection, $allowedSetupSections, true)) {
$currentSection = 'general';
}
$fields = (array)($module['setup']['fields'] ?? []);
$hasGlobalDebugField = false;
foreach ($fields as $field) {
@@ -438,6 +444,10 @@ $renderField = function (array $field) use (&$current, $getNested, $driverOption
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$isSchedulerAutosave = isset($_POST['scheduler_autosave']) && (string) $_POST['scheduler_autosave'] === '1';
$isSchedulerTest = isset($_POST['scheduler_test']) && (string) $_POST['scheduler_test'] === '1';
$submittedSetupSection = trim((string) ($_POST['setup_section'] ?? $currentSection));
if (!in_array($submittedSetupSection, $allowedSetupSections, true)) {
$submittedSetupSection = $currentSection;
}
$payload = [];
if ($isSchedulerAutosave || $isSchedulerTest) {
@@ -599,21 +609,23 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
}
} else {
modules()->saveSettings($moduleName, $current);
$selectedUsers = is_array($_POST['auth_user_values'] ?? null) ? $_POST['auth_user_values'] : [];
$selectedGroups = is_array($_POST['auth_group_values'] ?? null) ? $_POST['auth_group_values'] : [];
$manualUserValues = preg_split('/[,\\n]+/', (string) ($_POST['auth_users'] ?? '')) ?: [];
$manualGroupValues = preg_split('/[,\\n]+/', (string) ($_POST['auth_groups'] ?? '')) ?: [];
modules()->saveAuth($moduleName, [
'required' => isset($_POST['auth_required']),
'users' => array_merge($selectedUsers, $manualUserValues),
'groups' => array_merge($selectedGroups, $manualGroupValues),
]);
if ($submittedSetupSection === 'access') {
$selectedUsers = is_array($_POST['auth_user_values'] ?? null) ? $_POST['auth_user_values'] : [];
$selectedGroups = is_array($_POST['auth_group_values'] ?? null) ? $_POST['auth_group_values'] : [];
$manualUserValues = preg_split('/[,\\n]+/', (string) ($_POST['auth_users'] ?? '')) ?: [];
$manualGroupValues = preg_split('/[,\\n]+/', (string) ($_POST['auth_groups'] ?? '')) ?: [];
modules()->saveAuth($moduleName, [
'required' => isset($_POST['auth_required']),
'users' => array_merge($selectedUsers, $manualUserValues),
'groups' => array_merge($selectedGroups, $manualGroupValues),
]);
}
if ($isFxRatesSetup && modules()->hasFunction($moduleName, 'save_runtime_settings')) {
module_fn($moduleName, 'save_runtime_settings', $payload);
$current = modules()->settings($moduleName);
}
$refreshSchedulerState();
if (empty($payload['debug_enabled'])) {
if ($submittedSetupSection === 'general' && array_key_exists('debug_enabled', $payload) && empty($payload['debug_enabled'])) {
module_debug_clear($moduleName);
}
$notice = 'Setup gespeichert.';
@@ -658,42 +670,62 @@ $knownUserValues = array_column($knownUsers, 'sub');
$manualUsers = array_values(array_filter($allowedUsers, fn (string $value): bool => !in_array($value, $knownUserValues, true)));
$manualGroups = array_values(array_filter($allowedGroups, fn (string $value): bool => !in_array($value, $knownGroups, true)));
$hasCustomSection = $customSetupFields !== [] || $setupActions !== [] || $isFxRatesSetup;
$sectionUrls = [
'general' => '/modules/setup/' . rawurlencode($moduleName) . '/general',
'access' => '/modules/setup/' . rawurlencode($moduleName) . '/access',
'cron' => '/modules/setup/' . rawurlencode($moduleName) . '/cron',
'custom' => '/modules/setup/' . rawurlencode($moduleName) . '/custom',
];
$sectionTitles = [
'general' => 'Allgemein',
'access' => 'Zugriffsrechte',
'cron' => 'Cron Einstellungen',
'custom' => 'Custom Settings',
];
if ($currentSection === 'custom' && !$hasCustomSection) {
$currentSection = 'general';
}
$GLOBALS['layout_header_context'] = 'Setup / ' . ($sectionTitles[$currentSection] ?? 'Allgemein');
?>
<div class="setup-shell">
<div class="pill">Setup</div>
<h1 class="setup-title"><?= e($module['title']) ?> Einrichtung</h1>
<p class="muted">Trage die benötigten Informationen für das Modul ein.</p>
<div class="module-shell"><div class="module-page-bg"><div class="module-page-stack">
<div class="submenu-box">
<div class="module-hero-top module-hero-top--compact">
<nav class="module-tabs" aria-label="Setup-Navigation">
<a class="module-button <?= $currentSection === 'general' ? 'module-button--tab-active' : 'module-button--tab' ?>" href="<?= e($sectionUrls['general']) ?>">Allgemein</a>
<a class="module-button <?= $currentSection === 'access' ? 'module-button--tab-active' : 'module-button--tab' ?>" href="<?= e($sectionUrls['access']) ?>">Zugriffsrechte</a>
<a class="module-button <?= $currentSection === 'cron' ? 'module-button--tab-active' : 'module-button--tab' ?>" href="<?= e($sectionUrls['cron']) ?>">Cron Einstellungen</a>
<?php if ($hasCustomSection): ?>
<a class="module-button <?= $currentSection === 'custom' ? 'module-button--tab-active' : 'module-button--tab' ?>" href="<?= e($sectionUrls['custom']) ?>">Custom Settings</a>
<?php endif; ?>
</nav>
<div class="module-submenu-actions">
<a class="module-button module-button--secondary module-button--small" href="/modules">Nexus Übersicht</a>
<a class="module-button module-button--secondary module-button--small" href="/module/<?= e($moduleName) ?>">Zurück zum Modul</a>
</div>
</div>
</div>
<?php if ($error): ?>
<div class="bg-red-900 border-l-4 border-red-500 text-red-100 p-4 mb-6" role="alert">
<section class="section-box bg-red-900 border-l-4 border-red-500 text-red-100" role="alert">
<?= e($error) ?>
</div>
</section>
<?php elseif ($notice): ?>
<div class="setup-notice">
<section class="section-box" style="border-color:var(--accent-2);">
<?= e($notice) ?>
</div>
</section>
<?php endif; ?>
<div class="setup-shell__layout">
<aside class="setup-shell__sidebar setup-shell__sidebar--left" aria-label="Setup-Bereiche">
<div class="setup-nav">
<span class="pill">Bereiche</span>
<a class="nav-link setup-nav__link" href="#setup-general">Allgemein</a>
<a class="nav-link setup-nav__link" href="#setup-access">Zugriffsrechte</a>
<a class="nav-link setup-nav__link" href="#setup-cron">Cron Einstellungen</a>
<?php if ($hasCustomSection): ?>
<a class="nav-link setup-nav__link" href="#setup-custom">Custom Settings</a>
<?php endif; ?>
</div>
</aside>
<div class="setup-shell__content">
<form method="post" class="setup-form">
<datalist id="timezone-options">
<?php foreach ($timezoneOptions as $timezoneOption): ?>
<option value="<?= e((string) $timezoneOption['value']) ?>"><?= e((string) $timezoneOption['label']) ?></option>
<?php endforeach; ?>
</datalist>
<section class="section-box">
<div class="pill">Setup</div>
<h2 style="margin-top:.75rem;"><?= e($module['title']) ?> <?= e($sectionTitles[$currentSection] ?? 'Allgemein') ?></h2>
<p class="muted">Trage die benötigten Informationen für das Modul ein.</p>
<form method="post" class="setup-form" style="margin-top:1rem;">
<input type="hidden" name="setup_section" value="<?= e($currentSection) ?>">
<datalist id="timezone-options">
<?php foreach ($timezoneOptions as $timezoneOption): ?>
<option value="<?= e((string) $timezoneOption['value']) ?>"><?= e((string) $timezoneOption['label']) ?></option>
<?php endforeach; ?>
</datalist>
<?php if ($isFxRatesSetup): ?>
<?php
$fxCatalog = is_array($current['currency_catalog'] ?? null) ? $current['currency_catalog'] : [];
@@ -719,6 +751,7 @@ $hasCustomSection = $customSetupFields !== [] || $setupActions !== [] || $isFxRa
array_keys($fxCatalogOptions)
), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
?>
<?php if ($currentSection === 'custom'): ?>
<section class="setup-panel" id="setup-custom">
<div class="setup-panel__head">
<div>
@@ -764,7 +797,9 @@ $hasCustomSection = $customSetupFields !== [] || $setupActions !== [] || $isFxRa
</label>
</div>
</section>
<?php endif; ?>
<?php if ($currentSection === 'general'): ?>
<section class="setup-panel" id="setup-general">
<div class="setup-panel__head">
<div>
@@ -820,7 +855,9 @@ $hasCustomSection = $customSetupFields !== [] || $setupActions !== [] || $isFxRa
</div>
</div>
</section>
<?php endif; ?>
<?php if ($currentSection === 'custom'): ?>
<section class="setup-panel">
<div class="setup-panel__head">
<div>
@@ -843,7 +880,9 @@ $hasCustomSection = $customSetupFields !== [] || $setupActions !== [] || $isFxRa
</div>
</div>
</section>
<?php endif; ?>
<?php if ($currentSection === 'access'): ?>
<section class="setup-panel" id="setup-access">
<div class="setup-panel__head">
<div>
@@ -904,7 +943,9 @@ $hasCustomSection = $customSetupFields !== [] || $setupActions !== [] || $isFxRa
</div>
</div>
</section>
<?php endif; ?>
<?php if ($currentSection === 'cron'): ?>
<section class="setup-panel" id="setup-cron">
<div class="setup-panel__head">
<div>
@@ -921,8 +962,9 @@ $hasCustomSection = $customSetupFields !== [] || $setupActions !== [] || $isFxRa
</label>
</div>
</section>
<?php endif; ?>
<?php if ($intervalTaskStatuses !== []): ?>
<?php if ($currentSection === 'cron' && $intervalTaskStatuses !== []): ?>
<section class="setup-panel">
<div class="setup-panel__head">
<div>
@@ -947,7 +989,7 @@ $hasCustomSection = $customSetupFields !== [] || $setupActions !== [] || $isFxRa
</section>
<?php endif; ?>
<?php if ($cronTaskDefinitions !== []): ?>
<?php if ($currentSection === 'cron' && $cronTaskDefinitions !== []): ?>
<section class="setup-panel">
<div class="setup-panel__head">
<div>
@@ -1277,7 +1319,7 @@ $hasCustomSection = $customSetupFields !== [] || $setupActions !== [] || $isFxRa
}
</style>
<?php else: ?>
<?php if ($generalSetupFields !== []): ?>
<?php if ($currentSection === 'general' && $generalSetupFields !== []): ?>
<section class="setup-panel" id="setup-general">
<div class="setup-panel__head">
<div>
@@ -1293,6 +1335,7 @@ $hasCustomSection = $customSetupFields !== [] || $setupActions !== [] || $isFxRa
</section>
<?php endif; ?>
<?php if ($currentSection === 'access'): ?>
<section class="setup-panel" id="setup-access">
<div class="setup-panel__head">
<div>
@@ -1353,7 +1396,9 @@ $hasCustomSection = $customSetupFields !== [] || $setupActions !== [] || $isFxRa
</div>
</div>
</section>
<?php endif; ?>
<?php if ($currentSection === 'cron'): ?>
<section class="setup-panel" id="setup-cron">
<div class="setup-panel__head">
<div>
@@ -1372,8 +1417,9 @@ $hasCustomSection = $customSetupFields !== [] || $setupActions !== [] || $isFxRa
<p class="muted">Dieses Modul hat keine eigenen Zeitzonenfelder. Intervall-Tasks und Cron-Jobs koennen trotzdem weiter unten verwaltet werden.</p>
<?php endif; ?>
</section>
<?php endif; ?>
<?php if ($intervalTaskStatuses !== []): ?>
<?php if ($currentSection === 'cron' && $intervalTaskStatuses !== []): ?>
<section class="setup-panel">
<div class="setup-panel__head">
<div>
@@ -1402,7 +1448,7 @@ $hasCustomSection = $customSetupFields !== [] || $setupActions !== [] || $isFxRa
</section>
<?php endif; ?>
<?php if ($cronTaskDefinitions !== []): ?>
<?php if ($currentSection === 'cron' && $cronTaskDefinitions !== []): ?>
<section class="setup-panel">
<div class="setup-panel__head">
<div>
@@ -1481,7 +1527,7 @@ $hasCustomSection = $customSetupFields !== [] || $setupActions !== [] || $isFxRa
</section>
<?php endif; ?>
<?php if ($setupActions !== []): ?>
<?php if ($currentSection === 'custom' && $setupActions !== []): ?>
<section class="setup-panel"<?= $customSetupFields === [] ? ' id="setup-custom"' : '' ?>>
<div class="setup-panel__head">
<div>
@@ -1516,7 +1562,7 @@ $hasCustomSection = $customSetupFields !== [] || $setupActions !== [] || $isFxRa
</section>
<?php endif; ?>
<?php if (is_array($moduleStatusPanel)): ?>
<?php if ($currentSection === 'general' && is_array($moduleStatusPanel)): ?>
<section class="setup-panel setup-panel--flat">
<div class="setup-panel__head">
<div>
@@ -1541,7 +1587,7 @@ $hasCustomSection = $customSetupFields !== [] || $setupActions !== [] || $isFxRa
</section>
<?php endif; ?>
<?php if ($dbGroups !== []): ?>
<?php if ($currentSection === 'general' && $dbGroups !== []): ?>
<section class="setup-panel"<?= $generalSetupFields === [] ? ' id="setup-general"' : '' ?>>
<div class="setup-panel__head">
<div>
@@ -1613,7 +1659,7 @@ $hasCustomSection = $customSetupFields !== [] || $setupActions !== [] || $isFxRa
</section>
<?php endif; ?>
<?php if ($customSetupFields !== []): ?>
<?php if ($currentSection === 'custom' && $customSetupFields !== []): ?>
<section class="setup-panel" id="setup-custom">
<div class="setup-panel__head">
<div>
@@ -1633,17 +1679,8 @@ $hasCustomSection = $customSetupFields !== [] || $setupActions !== [] || $isFxRa
<button class="cta-button" type="submit">Setup speichern</button>
</div>
<?php endif; ?>
</form>
</div>
<aside class="setup-shell__sidebar setup-shell__sidebar--right" aria-label="Setup-Aktionen">
<div class="setup-nav">
<span class="pill">Aktionen</span>
<a class="nav-link setup-nav__link" href="/modules">Nexus Übersicht</a>
<a class="nav-link setup-nav__link" href="/module/<?= e($moduleName) ?>">Zurück zum Modul</a>
</div>
</aside>
</div>
</form>
</section>
<div class="scheduler-modal" data-scheduler-modal hidden>
<div class="scheduler-modal__backdrop" data-scheduler-close></div>
<div class="scheduler-modal__dialog" role="dialog" aria-modal="true" aria-labelledby="scheduler-modal-title">
@@ -2541,5 +2578,4 @@ $hasCustomSection = $customSetupFields !== [] || $setupActions !== [] || $isFxRa
overflow: hidden;
}
</style>
</form>
</div>
</div></div></div>

View File

@@ -252,7 +252,12 @@ $page404 = $pagesBase . '/errorpages/404.php';
if (str_starts_with($uriPath, 'modules/install')) {
$target = $pagesBase . '/modules/install.php';
} elseif (str_starts_with($uriPath, 'modules/setup/')) {
$_GET['module'] = trim(substr($uriPath, strlen('modules/setup/')), '/');
$setupPath = trim(substr($uriPath, strlen('modules/setup/')), '/');
$setupParts = $setupPath === '' ? [] : explode('/', $setupPath, 2);
$_GET['module'] = trim((string) ($setupParts[0] ?? ''));
if (isset($setupParts[1]) && trim((string) $setupParts[1]) !== '') {
$_GET['section'] = trim((string) $setupParts[1]);
}
$target = $pagesBase . '/modules/setup.php';
} elseif (str_starts_with($uriPath, 'modules/access/')) {
$_GET['module'] = trim(substr($uriPath, strlen('modules/access/')), '/');