230 lines
12 KiB
PHP
230 lines
12 KiB
PHP
<?php
|
|
require_once $_SERVER['DOCUMENT_ROOT'] . '/intranet_repo/general_files/initialise.php';
|
|
require_once __DIR__ . '/util/contentpanel_helpers.php';
|
|
require_once __DIR__ . '/util/view.php';
|
|
|
|
$generalPermission = $groups['Allgemein'] ?? null;
|
|
if (!in_array($generalPermission, [1, '1', true, 't', 'true'], true)) {
|
|
header('Location: /intranet_repo/projects/intranet/index.php', true, 303);
|
|
exit();
|
|
}
|
|
|
|
$today = date('Y-m-d');
|
|
contentpanel_cleanup_expired_news();
|
|
contentpanel_cleanup_expired_announcements($pdo, $today);
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
$action = trim((string) ($_POST['action'] ?? ''));
|
|
$tab = contentpanel_action_tab($action);
|
|
$flashType = 'success';
|
|
|
|
try {
|
|
contentpanel_verify_csrf($_POST['csrf_token'] ?? null);
|
|
|
|
$message = match ($action) {
|
|
'import_leitgedanken' => contentpanel_import_leitgedanken($pdo, $_FILES['leitgedanken_pdf'] ?? []),
|
|
'create_service' => contentpanel_create_service($pdo, $_POST),
|
|
'delete_service', 'delete_announcement' => contentpanel_delete_entry($pdo, $action, $_POST['id'] ?? null),
|
|
'create_announcement' => contentpanel_create_announcement($pdo, $_POST),
|
|
'upload_news' => contentpanel_upload_news($_POST, $_FILES['fileToUpload'] ?? [], $pdo, $user),
|
|
'delete_news' => contentpanel_delete_news_files((string) ($_POST['file_base'] ?? ''))
|
|
? 'Aushang wurde gelöscht.'
|
|
: throw new InvalidArgumentException('Ungültiger Dateiname oder Aushang konnte nicht vollständig gelöscht werden.'),
|
|
default => throw new InvalidArgumentException('Unbekannte Aktion.'),
|
|
};
|
|
} catch (InvalidArgumentException $exception) {
|
|
$message = $exception->getMessage();
|
|
$flashType = 'error';
|
|
} catch (Throwable $exception) {
|
|
error_log('Contentpanel action failed (' . $action . '): ' . $exception->getMessage());
|
|
$message = 'Die Aktion konnte nicht abgeschlossen werden. Bitte versuchen Sie es erneut.';
|
|
$flashType = 'error';
|
|
}
|
|
|
|
$_SESSION['contentpanel_flash'] = [
|
|
'tab' => $tab,
|
|
'message' => $message,
|
|
'type' => $flashType,
|
|
];
|
|
|
|
header('Location: insert.php#' . rawurlencode($tab), true, 303);
|
|
exit();
|
|
}
|
|
|
|
$flash = $_SESSION['contentpanel_flash'] ?? null;
|
|
unset($_SESSION['contentpanel_flash']);
|
|
|
|
$services = contentpanel_fetch_services($pdo, $today);
|
|
$announcements = contentpanel_fetch_announcements($pdo, $today);
|
|
$newsItems = contentpanel_list_news();
|
|
$pdo = null;
|
|
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="de" dir="ltr">
|
|
<head>
|
|
<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/intranet_repo/projects/_central/php/html_head.php'; ?>
|
|
<link rel="stylesheet" href="/intranet_repo/projects/_central/layouts/contentpanel.css?v=<?= (int) filemtime(__DIR__ . '/../../_central/layouts/contentpanel.css') ?>">
|
|
<script src="/intranet_repo/projects/_central/scripts/contentpanel.js?v=<?= (int) filemtime(__DIR__ . '/../../_central/scripts/contentpanel.js') ?>" defer></script>
|
|
</head>
|
|
<body class="theme-raspberry">
|
|
<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/intranet_repo/projects/_central/php/header.php'; ?>
|
|
|
|
<div class="header_title ht_raspberry text_white" id="header_title">
|
|
<span class="header_title_text">Schwarzes Brett</span>
|
|
</div>
|
|
|
|
<div class="sb-page">
|
|
<div class="content-tab-bar" role="tablist" aria-label="Schwarzes Brett">
|
|
<button type="button" class="content-tab-bar__item active" data-tab="gottesdienst">Gottesdienst</button>
|
|
<button type="button" class="content-tab-bar__item" data-tab="ansagen">Ansagen</button>
|
|
<button type="button" class="content-tab-bar__item" data-tab="dateien">Dateiverwaltung</button>
|
|
</div>
|
|
|
|
<section class="sb-tab-content active" id="tab-gottesdienst">
|
|
<?php contentpanel_flash($flash, 'gottesdienst'); ?>
|
|
|
|
<div class="sb-card">
|
|
<div class="sb-card-title">
|
|
<svg viewBox="0 0 24 24"><path d="M19 3h-1V1h-2v2H8V1H6v2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V8h14v11z"/></svg>
|
|
Geplante Gottesdienste
|
|
</div>
|
|
<?php contentpanel_entries($services, 'delete_service'); ?>
|
|
</div>
|
|
|
|
<div class="sb-card">
|
|
<div class="sb-card-title">
|
|
<svg viewBox="0 0 24 24"><path d="M9 16h6v-6h4l-7-7-7 7h4v6zm-4 2h14v2H5v-2z"/></svg>
|
|
Leitgedanken importieren
|
|
</div>
|
|
<form action="insert.php" method="post" enctype="multipart/form-data" data-upload-form>
|
|
<?php contentpanel_hidden('import_leitgedanken'); ?>
|
|
<div class="sb-form-grid sb-form-grid-single">
|
|
<?php contentpanel_field('leitgedanken_pdf', 'PDF hochladen (LG_*.pdf)', ['type' => 'file', 'required' => true, 'accept' => '.pdf,application/pdf']); ?>
|
|
<div class="sb-field-group">
|
|
<button type="submit" class="sb-btn sb-btn-primary sb-upload-button">Import starten</button>
|
|
<span class="sb-spinner" aria-label="Import läuft"></span>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
|
|
<div class="sb-card">
|
|
<div class="sb-card-title">
|
|
<svg viewBox="0 0 24 24"><path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/></svg>
|
|
Neuen Gottesdienst planen
|
|
</div>
|
|
<form method="post" action="insert.php">
|
|
<?php contentpanel_hidden('create_service'); ?>
|
|
<div class="sb-form-grid">
|
|
<?php contentpanel_field('bibeldatum', 'Datum des Gottesdienstes', ['type' => 'date', 'required' => true], true); ?>
|
|
<?php contentpanel_field('bibelwort', 'Bibelstelle', ['required' => true, 'placeholder' => 'z.B. Joh 3,16']); ?>
|
|
<?php contentpanel_field('bibelvers', 'Bibelvers', ['required' => true, 'placeholder' => 'Bibelvers eingeben']); ?>
|
|
<div class="sb-field-group sb-form-full sb-field-group-action">
|
|
<button type="submit" class="sb-btn sb-btn-primary">Eintragen</button>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</section>
|
|
|
|
<section class="sb-tab-content" id="tab-ansagen">
|
|
<?php contentpanel_flash($flash, 'ansagen'); ?>
|
|
|
|
<div class="sb-card">
|
|
<div class="sb-card-title">
|
|
<svg viewBox="0 0 24 24"><path d="M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm0 14H6l-2 2V4h16v12z"/></svg>
|
|
Geplante Ansagen
|
|
</div>
|
|
<?php contentpanel_entries($announcements, 'delete_announcement'); ?>
|
|
</div>
|
|
|
|
<div class="sb-card">
|
|
<div class="sb-card-title">
|
|
<svg viewBox="0 0 24 24"><path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/></svg>
|
|
Neue Ansage planen
|
|
</div>
|
|
<form method="post" action="insert.php">
|
|
<?php contentpanel_hidden('create_announcement'); ?>
|
|
<div class="sb-form-grid">
|
|
<?php contentpanel_field('ansage_titel', 'Titel', ['required' => true, 'placeholder' => 'Titel der Ansage'], true); ?>
|
|
<?php contentpanel_field('ansage_datum_von', 'Datum', ['type' => 'date', 'required' => true]); ?>
|
|
<?php contentpanel_field('ansage_datum_bis', 'Datum bis', ['type' => 'date']); ?>
|
|
<?php contentpanel_field('ansage_uhrzeit', 'Uhrzeit', ['type' => 'time']); ?>
|
|
<?php contentpanel_field('ansage_ort', 'Ort', ['placeholder' => 'z.B. Gemeindesaal']); ?>
|
|
<?php contentpanel_field('ansage_untertitel', 'Weitere Informationen', ['placeholder' => 'Zusätzliche Hinweise'], true); ?>
|
|
<div class="sb-field-group sb-form-full sb-field-group-action">
|
|
<button type="submit" class="sb-btn sb-btn-primary">Eintragen</button>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</section>
|
|
|
|
<section class="sb-tab-content" id="tab-dateien">
|
|
<?php contentpanel_flash($flash, 'dateien'); ?>
|
|
|
|
<div class="sb-card">
|
|
<div class="sb-card-title">
|
|
<svg viewBox="0 0 24 24"><path d="M14 2H6c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V8l-6-6zm4 18H6V4h7v5h5v11z"/></svg>
|
|
Aktuelle Aushänge
|
|
</div>
|
|
<div class="sb-aushang-grid">
|
|
<?php if ($newsItems === []): ?>
|
|
<div class="sb-empty">Keine Aushänge vorhanden.</div>
|
|
<?php else: ?>
|
|
<?php foreach ($newsItems as $item): ?>
|
|
<div class="sb-aushang-card">
|
|
<img src="<?= contentpanel_html($item['image_url']) ?>" alt="<?= contentpanel_html($item['title']) ?>" loading="lazy">
|
|
<div class="sb-aushang-title"><?= contentpanel_html($item['title']) ?></div>
|
|
<div class="sb-aushang-meta">
|
|
<?= $item['pages'] ?> <?= $item['pages'] === 1 ? 'Seite' : 'Seiten' ?> · Verfällt <?= contentpanel_html($item['expiry']) ?>
|
|
</div>
|
|
<form method="post" action="insert.php" class="sb-aushang-delete-form">
|
|
<?php contentpanel_hidden('delete_news', ['file_base' => $item['base']]); ?>
|
|
<button type="submit" class="sb-btn sb-btn-danger" data-confirm="Aushang wirklich löschen?">Löschen</button>
|
|
</form>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="sb-card">
|
|
<div class="sb-card-title">
|
|
<svg viewBox="0 0 24 24"><path d="M9 16h6v-6h4l-7-7-7 7h4v6zm-4 2h14v2H5v-2z"/></svg>
|
|
Neuen Aushang hochladen
|
|
</div>
|
|
<form action="insert.php" method="post" enctype="multipart/form-data" data-upload-form>
|
|
<?php contentpanel_hidden('upload_news'); ?>
|
|
<div class="sb-form-grid">
|
|
<?php contentpanel_field('date', 'Verfallsdatum', ['type' => 'date', 'id' => 'news_date', 'required' => true]); ?>
|
|
<?php contentpanel_field('name', 'Titel des Aushangs', ['id' => 'news_name', 'required' => true, 'placeholder' => 'Name des Dokuments']); ?>
|
|
<div class="sb-field-group sb-form-full">
|
|
<span class="sb-label">Darstellung</span>
|
|
<div class="sb-format-options" role="radiogroup" aria-label="Darstellung des Aushangs">
|
|
<label class="sb-format-option">
|
|
<input type="radio" name="format_mode" value="template" checked>
|
|
<span><strong>In NAK-Formatvorlage überführen</strong><small>Dokument wird automatisch in unser einheitliches Aushang-Layout gesetzt.</small></span>
|
|
</label>
|
|
<label class="sb-format-option">
|
|
<input type="radio" name="format_mode" value="original">
|
|
<span><strong>Original-PDF verwenden</strong><small>Das bestehende Layout bleibt unverändert.</small></span>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
<?php contentpanel_field('fileToUpload', 'PDF-Datei auswählen', ['type' => 'file', 'required' => true, 'accept' => '.pdf,application/pdf'], true); ?>
|
|
<div class="sb-field-group sb-form-full sb-field-group-action">
|
|
<button type="submit" class="sb-btn sb-btn-primary sb-upload-button">Datei hochladen</button>
|
|
<span class="sb-spinner" aria-label="Upload läuft"></span>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</section>
|
|
</div>
|
|
|
|
<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/intranet_repo/projects/_central/php/footer.php'; ?>
|
|
</body>
|
|
</html>
|