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 print '<section class="replies">';
29 for ($i = 0; $row = $query->fetch(); $i++) {
30 $rowuser = new User("profile/{$row->author}");
31 printf('<article id="%d">', $row->id);
33 # subsequent reply header
34 printf('<strong>%s</strong>', $rowuser->html);
37 $Page->teaser = $row->raw;
39 $rowdate = showdate(preg_split('/\D/', $row->created));
40 if ($User->admin('beheer')) {
42 $rowdate = "<s>$rowdate</s> " . showdate(preg_split('/\D/', $row->updated));
44 if ($User->admin('user') || $User->login === $row->author) {
45 $rowdate .= sprintf(' <a href="%s" title="%s" class=icon>%s</a>',
46 "/{$Page->link}/{$row->id}", 'reactie aanpassen', "\u{270D}");
49 printf(' <small class=date>%s</small>', $rowdate);
50 if ($html = $row->message) {
51 $html = preg_replace('/(?<=<img )/',
52 $imagecount > 2 ? 'loading="lazy" ' : '', $html, -1, $found);
53 $imagecount += $found;
55 $html = "<blockquote>\n$html</blockquote>\n";
59 if ($changes = json_decode($row->journal)) {
61 foreach ($changes as $change) {
63 if ($change->col == 'closed') {
64 printf('<em>%s</em>', isset($change->value) ? 'Gesloten' : 'Heropend');
67 printf("<em>%s</em> %s",
68 $journalcol[$change->col], sprintf(
69 !isset($change->old_value) ? 'gewijzigd naar <q>%2$s</q>' :
70 (!isset($change->value) ? 'verwijderd (<s>%s</s>)' :
71 'gewijzigd van <q>%s</q> naar <q>%s</q>'),
72 $change->old_value, $change->value
84 print '<article><hr />';
85 print '<form method="post" action="" enctype="multipart/form-data">';
86 if (isset($Issue) and $User->admin("edit {$Page->link}")) {
90 '<label for="%s">%s:</label> '
91 . '<input id="%1$s" name="%1$s" value="%s" />'."\n",
93 $journalcol['subject'],
94 htmlspecialchars($Issue->subject ?? '')
100 '<label for="%s">%s:</label> '
101 . '<input id="%1$s" name="%1$s" value="%s" />'."\n",
103 $journalcol['assign'],
104 htmlspecialchars($Issue->assign ?? '')
107 '<input type="hidden" name="%s" value="" />' .
108 '<input type="checkbox" id="%1$s" name="%1$s" value="%s"%s />'
109 . '<label for="%1$s"> %s</label>'."\n",
112 isset($Issue->closed) ? ' checked' : '',
121 '<input type="hidden" name="%s" value="" />'
122 . "Geplaatste berichten zijn hier direct zichtbaar voor bewoners.\n"
123 . '<input type="checkbox" id="%1$s" name="%1$s" value="%s"%s%s />'
124 . '<label for="%1$s"> %s</label>'."\n",
127 ($_POST['announce'] ?? TRUE) ? ' checked' : '',
128 ' onclick="this.nextSibling.hidden = !this.checked"',
129 "De eerste regel wordt ook weergegeven op het scherm in de hal."
135 '<p><label for="%s">%s:</label> '
136 . '<input id="%1$s" name="%1$s" value=""%s /></p>'."\n",
137 'image', 'Beeldmateriaal', ' type="file" accept="image/*"'
140 printf('<textarea id="%s" name="%1$s" cols=60 rows=3 placeholder="%s">%s</textarea>'."\n",
142 "Bericht van {$User->login}",
145 print '<input type="submit" value="Plaatsen" />'."\n";
147 print '<script src="/upload/progress.js"></script>';
148 print "</article>\n";
151 print "</section>\n\n";