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}/$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 print "<p class=warn>Antwoord niet opgeslagen: {$e->getMessage()}.</p>\n\n";
21 $cols = '*, (SELECT json_agg(journal.*) FROM journal WHERE comment_id = comments.id) AS journal';
22 $query = $Db->query("SELECT $cols FROM comments WHERE page = ? ORDER BY created", [$Page->link]);
24 if ($row = $query->fetch()) {
26 $Page->teaser = $row->raw;
29 print '<ul class="replies">';
32 while ($row = $query->fetch()) {
33 $rowuser = new User("profile/{$row->author}");
34 printf('<li id="%d">', $row->id);
35 printf('<strong>%s</strong> <small class=date>%s</small>',
36 $rowuser->html, showdate(preg_split('/\D/', $row->created))
38 if ($html = $row->message) {
39 $html = preg_replace('/(?<=<img )/',
40 $imagecount > 2 ? 'loading="lazy" ' : '', $html, -1, $found);
41 $imagecount += $found;
42 printf("<blockquote>\n%s</blockquote>\n", $html);
44 if ($changes = json_decode($row->journal)) {
46 foreach ($changes as $change) {
48 if ($change->col == 'closed') {
49 printf('<em>%s</em>', isset($change->value) ? 'Gesloten' : 'Heropend');
52 printf("<em>%s</em> %s",
53 $journalcol[$change->col], sprintf(
54 !isset($change->old_value) ? 'gewijzigd naar <q>%2$s</q>' :
55 (!isset($change->value) ? 'verwijderd (<s>%s</s>)' :
56 'gewijzigd van <q>%s</q> naar <q>%s</q>'),
57 $change->old_value, $change->value
70 print '<form method="post" action="" enctype="multipart/form-data">';
71 if (isset($Issue) and $User->admin("edit {$Page->link}")) {
74 '<label for="%s">%s:</label> '
75 . '<input id="%1$s" name="%1$s" value="%s" />'."\n",
77 $journalcol['assign'],
78 htmlspecialchars($Issue->assign ?? '')
81 '<input type="hidden" name="%s" value="" />' .
82 '<input type="checkbox" id="%1$s" name="%1$s" value="%s"%s />'
83 . '<label for="%1$s"> %s</label>'."\n",
86 isset($Issue->closed) ? ' checked' : '',
94 '<input type="hidden" name="%s" value="" />'
95 . "Geplaatste berichten zijn hier direct zichtbaar voor bewoners.\n"
96 . '<input type="checkbox" id="%1$s" name="%1$s" value="%s"%s%s />'
97 . '<label for="%1$s"> %s</label>'."\n",
100 ($_POST['announce'] ?? TRUE) ? ' checked' : '',
101 ' onclick="this.nextSibling.hidden = !this.checked"',
102 "De eerste regel wordt ook weergegeven op het scherm in de hal."
108 '<p><label for="%s">%s:</label> '
109 . '<input id="%1$s" name="%1$s" value=""%s /></p>'."\n",
110 'image', 'Beeldmateriaal', ' type="file" accept="image/*"'
113 printf('<textarea id="%s" name="%1$s" cols=60 rows=3 placeholder="%s">%s</textarea>'."\n",
115 "Bericht van {$User->login}",
118 print '<input type="submit" value="Plaatsen" />'."\n";
120 print '<script src="/upload/progress.js"></script>';