From 4acdd7f1c3b2b78933d7953e8777df73af3189aa Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Tue, 28 Sep 2021 17:50:31 +0200 Subject: [PATCH] issue: reply option to mark announced publication Can be unchecked to decrease message visibility. --- database.inc.php | 3 +++ upload.inc.php | 3 +++ widget/comments.sql | 1 + widget/reply.php | 15 +++++++++++++++ 4 files changed, 22 insertions(+) diff --git a/database.inc.php b/database.inc.php index b2244b9..9b65ce6 100644 --- a/database.inc.php +++ b/database.inc.php @@ -29,6 +29,9 @@ class DB $params = array_merge($params, $val); return $sql; } + elseif (is_bool($val)) { + return $val ? 'TRUE' : 'FALSE'; + } $params[] = $val; return '?'; diff --git a/upload.inc.php b/upload.inc.php index d87fa2d..ff4ecd3 100644 --- a/upload.inc.php +++ b/upload.inc.php @@ -84,6 +84,9 @@ function createcomment($input, &$Issue = NULL) $reply['raw'] = $body; $reply['message'] = messagehtml($body); } + if (isset($input['announce'])) { + $reply['announced'] = !!$input['announce']; + } if ($_FILES and !empty($_FILES['image'])) { $target = 'data/upload'; if (!file_exists($target)) { diff --git a/widget/comments.sql b/widget/comments.sql index b805a2a..fc261f8 100644 --- a/widget/comments.sql +++ b/widget/comments.sql @@ -14,6 +14,7 @@ CREATE TABLE comments ( page text, raw text, message text, + announced boolean NOT NULL DEFAULT TRUE, created timestamptz DEFAULT now(), author text, id serial NOT NULL PRIMARY KEY diff --git a/widget/reply.php b/widget/reply.php index b740c2a..010b1de 100644 --- a/widget/reply.php +++ b/widget/reply.php @@ -88,6 +88,21 @@ if ($User->login) { ); print "

\n"; } + { + print '

'; + printf( + '' + . "Geplaatste berichten zijn hier direct zichtbaar voor bewoners.\n" + . '' + . ''."\n", + 'announce', + '1', + ($_POST['announce'] ?? TRUE) ? ' checked' : '', + ' onclick="this.nextSibling.hidden = !this.checked"', + "De eerste regel wordt ook weergegeven op het scherm in de hal." + ); + print "

\n"; + } if (isset($Issue)) { printf( '

' -- 2.30.0