106 lines
4.1 KiB
PHP
106 lines
4.1 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')) {
|
|
modules()->setEnabled($name, $action === 'enable');
|
|
$notice = $action === 'enable' ? 'Modul aktiviert.' : 'Modul deaktiviert.';
|
|
$modules = modules()->all();
|
|
} elseif ($name !== '' && $action === 'migrate') {
|
|
$applied = modules()->applyPendingMigrations($name);
|
|
$notice = count($applied) . ' Migration(en) angewendet.';
|
|
$modules = modules()->all();
|
|
} else {
|
|
$error = 'Ungültige Aktion.';
|
|
}
|
|
}
|
|
|
|
$active = [];
|
|
$inactive = [];
|
|
foreach ($modules as $m) {
|
|
if (!empty($m['enabled'])) {
|
|
$active[] = $m;
|
|
} else {
|
|
$inactive[] = $m;
|
|
}
|
|
}
|
|
?>
|
|
<?php require_auth(); ?>
|
|
<div class="card">
|
|
<div class="pill">Module</div>
|
|
<h1 style="margin-top:.75rem;">Module installieren/aktivieren</h1>
|
|
<p class="muted">Erkannte Module basieren auf Ordnern in <code>modules/</code>.</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; ?>
|
|
|
|
<h3 style="margin-top:1.25rem;">Aktive Module</h3>
|
|
<div style="margin-top:.5rem;" class="grid">
|
|
<?php foreach ($active as $module): ?>
|
|
<?php
|
|
$migrationStatus = modules()->migrationStatus($module['name']);
|
|
$pendingMigrations = $migrationStatus['pending'] ?? [];
|
|
?>
|
|
<div class="card" style="background:var(--panel-2);">
|
|
<strong><?= e($module['title']) ?></strong>
|
|
<div class="muted" style="font-size:.85rem;"><?= e($module['description'] ?? '') ?></div>
|
|
<div style="margin-top:.75rem; display:flex; gap:10px;">
|
|
<a class="nav-link" href="/module/<?= e($module['name']) ?>">Öffnen</a>
|
|
<?php if ($pendingMigrations !== []): ?>
|
|
<form method="post" style="margin:0;">
|
|
<input type="hidden" name="module" value="<?= e($module['name']) ?>">
|
|
<button class="cta-button" name="action" value="migrate">Migrationen anwenden</button>
|
|
</form>
|
|
<?php endif; ?>
|
|
<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>
|
|
|
|
<h3 style="margin-top:1.5rem;">Deaktivierte Module</h3>
|
|
<div style="margin-top:.5rem;" class="grid">
|
|
<?php foreach ($inactive as $module): ?>
|
|
<?php
|
|
$migrationStatus = modules()->migrationStatus($module['name']);
|
|
$pendingMigrations = $migrationStatus['pending'] ?? [];
|
|
?>
|
|
<div class="card" style="background:var(--panel-2);">
|
|
<strong><?= e($module['title']) ?></strong>
|
|
<div class="muted" style="font-size:.85rem;"><?= e($module['description'] ?? '') ?></div>
|
|
<div style="margin-top:.75rem; display:flex; gap:10px;">
|
|
<a class="nav-link" href="/modules/setup/<?= e($module['name']) ?>">Setup</a>
|
|
<?php if ($pendingMigrations !== []): ?>
|
|
<form method="post" style="margin:0;">
|
|
<input type="hidden" name="module" value="<?= e($module['name']) ?>">
|
|
<button class="cta-button" name="action" value="migrate">Migrationen anwenden</button>
|
|
</form>
|
|
<?php endif; ?>
|
|
<form method="post" style="margin:0;">
|
|
<input type="hidden" name="module" value="<?= e($module['name']) ?>">
|
|
<button class="cta-button" name="action" value="enable">Aktivieren</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</div>
|