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

View File

@@ -252,7 +252,12 @@ $page404 = $pagesBase . '/errorpages/404.php';
if (str_starts_with($uriPath, 'modules/install')) { if (str_starts_with($uriPath, 'modules/install')) {
$target = $pagesBase . '/modules/install.php'; $target = $pagesBase . '/modules/install.php';
} elseif (str_starts_with($uriPath, 'modules/setup/')) { } 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'; $target = $pagesBase . '/modules/setup.php';
} elseif (str_starts_with($uriPath, 'modules/access/')) { } elseif (str_starts_with($uriPath, 'modules/access/')) {
$_GET['module'] = trim(substr($uriPath, strlen('modules/access/')), '/'); $_GET['module'] = trim(substr($uriPath, strlen('modules/access/')), '/');