96 lines
4.0 KiB
PHP
96 lines
4.0 KiB
PHP
<?php
|
|
$modules = modules()->all();
|
|
$error = null;
|
|
$notice = null;
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
require_admin();
|
|
$name = (string)($_POST['module'] ?? '');
|
|
$action = (string)($_POST['action'] ?? '');
|
|
|
|
if ($name !== '' && ($action === 'enable' || $action === 'disable')) {
|
|
$enabled = $action === 'enable';
|
|
modules()->setEnabled($name, $enabled);
|
|
$notice = $enabled ? 'Modul aktiviert.' : 'Modul deaktiviert.';
|
|
$modules = modules()->all();
|
|
} else {
|
|
$error = 'Ungültige Aktion.';
|
|
}
|
|
}
|
|
?>
|
|
<div class="card">
|
|
<?php require_auth(); ?>
|
|
<div class="pill">Module</div>
|
|
<h1 style="margin-top:.75rem;">Module verwalten</h1>
|
|
<p class="muted">Hier siehst du nur aktive Module. Installierte Module kannst du unten verwalten.</p>
|
|
<p style="margin-top:.75rem;">
|
|
<a class="nav-link" href="/modules/sql-import">Zentralen SQL-Import oeffnen</a>
|
|
</p>
|
|
|
|
<?php if ($error): ?>
|
|
<div class="bg-red-900 border-l-4 border-red-500 text-red-100 p-4 mb-6" role="alert">
|
|
<?= e($error) ?>
|
|
</div>
|
|
<?php elseif ($notice): ?>
|
|
<div class="card" style="margin-top:1rem; border-color:var(--accent-2);">
|
|
<?= e($notice) ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<div style="margin-top:1rem;" class="grid">
|
|
<?php foreach ($modules as $module): ?>
|
|
<?php if (empty($module['enabled'])) { continue; } ?>
|
|
<?php
|
|
$auth = is_array($module['auth'] ?? null) ? $module['auth'] : [];
|
|
$authRequired = !empty($auth['required']);
|
|
$authUsers = is_array($auth['users'] ?? null) ? array_filter($auth['users']) : [];
|
|
$authGroups = is_array($auth['groups'] ?? null) ? array_filter($auth['groups']) : [];
|
|
$hasSpecificAccess = $authRequired && ($authUsers !== [] || $authGroups !== []);
|
|
$accessLabel = $hasSpecificAccess
|
|
? 'Spezielle Zugriffsrechte'
|
|
: ($authRequired ? 'Login erforderlich' : 'Kein Modulschutz');
|
|
?>
|
|
<div class="card" style="background:var(--panel-2);">
|
|
<div style="display:flex; align-items:center; justify-content:space-between; gap:12px;">
|
|
<div>
|
|
<strong><?= e($module['title']) ?></strong>
|
|
<div class="muted" style="font-size:.85rem;"><?= e($module['description'] ?? '') ?></div>
|
|
</div>
|
|
<div style="display:flex; gap:8px; flex-wrap:wrap; justify-content:flex-end;">
|
|
<span class="pill" style="border-color:var(--accent-2); color:var(--accent-2);">aktiv</span>
|
|
<span class="pill" title="<?= e($accessLabel) ?>" style="<?= $hasSpecificAccess ? 'border-color:#f59e0b; color:#fbbf24;' : '' ?>">
|
|
<?= e($accessLabel) ?>
|
|
</span>
|
|
</div>
|
|
</div>
|
|
<?php if ($hasSpecificAccess): ?>
|
|
<div class="muted" style="margin-top:.65rem; font-size:.85rem;">
|
|
<?php if ($authGroups !== []): ?>
|
|
Gruppen: <?= e(implode(', ', $authGroups)) ?>
|
|
<?php endif; ?>
|
|
<?php if ($authGroups !== [] && $authUsers !== []): ?>
|
|
·
|
|
<?php endif; ?>
|
|
<?php if ($authUsers !== []): ?>
|
|
Benutzer: <?= e((string)count($authUsers)) ?>
|
|
<?php endif; ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
<div style="margin-top:.75rem; display:flex; gap:10px; flex-wrap:wrap;">
|
|
<a class="nav-link" href="/module/<?= e($module['name']) ?>">Öffnen</a>
|
|
<a class="nav-link" href="/modules/setup/<?= e($module['name']) ?>">Setup</a>
|
|
<a class="nav-link" href="/modules/access/<?= e($module['name']) ?>">Zugriff</a>
|
|
<form method="post" style="margin:0;">
|
|
<input type="hidden" name="module" value="<?= e($module['name']) ?>">
|
|
<button class="cta-button" name="action" value="disable" style="background:var(--panel); color:var(--text);">Deaktivieren</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
|
|
<div style="margin-top:1.5rem;">
|
|
<a class="nav-link" href="/modules/install">Modul installieren/aktivieren</a>
|
|
</div>
|
|
</div>
|