2 global $User, $Db, $Issue;
3 require_once 'database.inc.php';
4 require_once 'upload.inc.php';
8 $newcomment = createcomment($_POST, $Issue);
9 $target = "/{$Page->link}?last=$newcomment#$newcomment";
10 abort($target, ($Page->api ? 200 : 303) . ' reply success');
11 $_POST['reply'] = NULL;
13 catch (Exception $e) {
15 abort(ucfirst($e->getMessage()), '500 reply error');
17 printf("<p class=warn>Antwoord niet opgeslagen: %s.</p>\n\n",
18 nl2br(htmlspecialchars($e->getMessage()))
23 $cols = "*, (SELECT json_agg(journal.*) FROM journal WHERE comment_id = comments.id AND property = 'attr') AS journal";
24 $query = $Db->query("SELECT $cols FROM comments WHERE page = ? ORDER BY created", [$Page->link]);
26 if ($row = $query->fetch()) {
28 $Page->teaser = $row->raw;
31 print '<ul class="replies">';
34 while ($row = $query->fetch()) {
35 $rowuser = new User("profile/{$row->author}");
36 printf('<li id="%d">', $row->id);
37 printf('<strong>%s</strong> <small class=date>%s</small>',
38 $rowuser->html, showdate(preg_split('/\D/', $row->created))
40 if ($html = $row->message) {
41 $html = preg_replace('/(?<=<img )/',
42 $imagecount > 2 ? 'loading="lazy" ' : '', $html, -1, $found);
43 $imagecount += $found;
44 printf("<blockquote>\n%s</blockquote>\n", $html);
46 if ($changes = json_decode($row->journal)) {
48 foreach ($changes as $change) {
50 if ($change->col == 'closed') {
51 printf('<em>%s</em>', isset($change->value) ? 'Gesloten' : 'Heropend');
54 printf("<em>%s</em> %s",
55 $journalcol[$change->col], sprintf(
56 !isset($change->old_value) ? 'gewijzigd naar <q>%2$s</q>' :
57 (!isset($change->value) ? 'verwijderd (<s>%s</s>)' :
58 'gewijzigd van <q>%s</q> naar <q>%s</q>'),
59 $change->old_value, $change->value
72 print '<form method="post" action="" enctype="multipart/form-data">';
73 if (isset($Issue) and $User->admin("edit {$Page->link}")) {
77 '<label for="%s">%s:</label> '
78 . '<input id="%1$s" name="%1$s" value="%s" />'."\n",
80 $journalcol['subject'],
81 htmlspecialchars($Issue->subject ?? '')
87 '<label for="%s">%s:</label> '
88 . '<input id="%1$s" name="%1$s" value="%s" />'."\n",
90 $journalcol['assign'],
91 htmlspecialchars($Issue->assign ?? '')
94 '<input type="hidden" name="%s" value="" />' .
95 '<input type="checkbox" id="%1$s" name="%1$s" value="%s"%s />'
96 . '<label for="%1$s"> %s</label>'."\n",
99 isset($Issue->closed) ? ' checked' : '',
108 '<input type="hidden" name="%s" value="" />'
109 . "Geplaatste berichten zijn hier direct zichtbaar voor bewoners.\n"
110 . '<input type="checkbox" id="%1$s" name="%1$s" value="%s"%s%s />'
111 . '<label for="%1$s"> %s</label>'."\n",
114 ($_POST['announce'] ?? TRUE) ? ' checked' : '',
115 ' onclick="this.nextSibling.hidden = !this.checked"',
116 "De eerste regel wordt ook weergegeven op het scherm in de hal."
122 '<p><label for="%s">%s:</label> '
123 . '<input id="%1$s" name="%1$s" value=""%s /></p>'."\n",
124 'image', 'Beeldmateriaal', ' type="file" accept="image/*"'
127 printf('<textarea id="%s" name="%1$s" cols=60 rows=3 placeholder="%s">%s</textarea>'."\n",
129 "Bericht van {$User->login}",
132 print '<input type="submit" value="Plaatsen" />'."\n";
134 print '<script src="/upload/progress.js"></script>';