From 8f15909ab03c23abb708d7e4c8ecc628ff0f3cdf Mon Sep 17 00:00:00 2001 From: Maaxxs <61059039+MaaxxsDev@users.noreply.github.com> Date: Tue, 22 Sep 2026 18:06:42 +0200 Subject: [PATCH] Announcements: option to hide the author name on the banner (still recorded in the audit log) Co-Authored-By: Claude Opus 5 --- admin/site.php | 5 +++++ admin/site_action.php | 3 +++ includes/site_notice.php | 3 ++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/admin/site.php b/admin/site.php index 0246e2a..c5c331f 100644 --- a/admin/site.php +++ b/admin/site.php @@ -25,6 +25,7 @@ $form = [ 'level' => setting_get('announcement_level') ?: 'info', 'until' => setting_get('announcement_until'), 'public' => setting_get('announcement_public') === '1', + 'show_author' => setting_get('announcement_show_author') !== '0', ]; $hasStoredAnnouncement = trim($form['title'] . $form['text']) !== ''; $isExpired = $hasStoredAnnouncement && $announcement === null; @@ -121,6 +122,10 @@ include __DIR__ . '/../includes/header.php'; > Auch auf der öffentlichen Startseite zeigen (für Besucher ohne Anmeldung) +
diff --git a/admin/site_action.php b/admin/site_action.php index 1126e71..1d11e83 100644 --- a/admin/site_action.php +++ b/admin/site_action.php @@ -59,6 +59,7 @@ switch ($action) { $level = (string) ($_POST['level'] ?? 'info'); $untilRaw = trim((string) ($_POST['until'] ?? '')); $public = !empty($_POST['public']); + $showAuthor = !empty($_POST['show_author']); $error = null; if ($title === '' && $text === '') { @@ -93,6 +94,7 @@ switch ($action) { setting_set('announcement_until', $until); setting_set('announcement_public', $public ? '1' : '0'); setting_set('announcement_by', $myName); + setting_set('announcement_show_author', $showAuthor ? '1' : '0'); // Neue ID: auch wer die vorige weggeklickt hat, sieht diese wieder setting_set('announcement_id', (string) time()); @@ -101,6 +103,7 @@ switch ($action) { 'Stufe' => ANNOUNCEMENT_LEVELS[$level], 'Anzeigen bis' => $until !== '' ? date('d.m.Y H:i', strtotime($until)) . ' Uhr' : 'bis sie entfernt wird', 'Öffentlich' => $public ? 'ja, auch auf der Startseite' : '', + 'Autor' => $showAuthor ? 'wird angezeigt' : 'ausgeblendet', 'Nachricht' => mb_strimwidth($text, 0, 500, '…'), ], $level === 'urgent' ? 'warning' : 'info', 'site'); set_flash('success', 'Ankündigung wird jetzt allen angezeigt.'); diff --git a/includes/site_notice.php b/includes/site_notice.php index a8a7161..f3abb21 100644 --- a/includes/site_notice.php +++ b/includes/site_notice.php @@ -118,7 +118,8 @@ function announcement_current(): ?array 'level' => isset(ANNOUNCEMENT_LEVELS[$level]) ? $level : 'info', 'until' => $until, 'public' => setting_get('announcement_public') === '1', - 'by' => setting_get('announcement_by'), + // Autor nur, wenn er beim Speichern nicht ausgeblendet wurde ('0'); aeltere Ankuendigungen zeigen ihn + 'by' => setting_get('announcement_show_author') === '0' ? '' : setting_get('announcement_by'), ]; }