X-Git-Url: http://git.shiar.nl/minimedit.git/blobdiff_plain/4d7efe1c7eacff8a21bea95828ef0528a47f503e..6bdc514b94fb0127159c809e8f311cccc230d4ee:/widget/reply.php
diff --git a/widget/reply.php b/widget/reply.php
index cfa9487..0c5d5a3 100644
--- a/widget/reply.php
+++ b/widget/reply.php
@@ -1,50 +1,151 @@
Reacties'."\n";
+require_once 'upload.inc.php';
if ($_POST) {
try {
- $html = nl2br(htmlspecialchars($_POST['reply']));
- $html = "
$html
";
- $query = $Db->insert('comments', [
- 'page' => $Page,
- 'message' => $html,
- 'author' => $User->login,
- ]);
- if (!$query->rowCount()) {
- throw new Exception('Fout bij opslaan');
- }
+ $newcomment = createcomment($_POST, $Issue);
+ $target = "/{$Page->link}?last=$newcomment#$newcomment";
+ abort($target, ($Page->api ? 200 : 303) . ' reply success');
$_POST['reply'] = NULL;
}
catch (Exception $e) {
- print 'Antwoord niet opgeslagen.
'."\n\n";
+ if ($Page->api) {
+ abort(ucfirst($e->getMessage()), '500 reply error');
+ }
+ printf("Antwoord niet opgeslagen: %s.
\n\n",
+ nl2br(htmlspecialchars($e->getMessage()))
+ );
}
}
-$query = $Db->query('SELECT * FROM comments WHERE page = ? ORDER BY created', [$Page]);
+$cols = "*, (SELECT json_agg(journal.*) FROM journal WHERE comment_id = comments.id AND property = 'attr') AS journal";
+$query = $Db->query("SELECT $cols FROM comments WHERE page = ? ORDER BY created", [$Page->link]);
-print '';
+print '';
-while ($row = $query->fetch(PDO::FETCH_OBJ)) {
+$imagecount = 0;
+for ($i = 0; $row = $query->fetch(); $i++) {
$rowuser = new User("profile/{$row->author}");
- print '';
- printf('%s %s ',
- $rowuser->html, showdate(preg_split('/\D/', $row->created))
- );
- printf("%s \n", $row->message);
- print " \n";
+ printf('', $row->id);
+ if ($i) {
+ # subsequent reply header
+ printf('%s ', $rowuser->html);
+ }
+ else {
+ $Page->teaser = $row->raw;
+ }
+ $rowdate = showdate(preg_split('/\D/', $row->created));
+ if ($User->admin('beheer')) {
+ if ($row->updated) {
+ $rowdate = "$rowdate " . showdate(preg_split('/\D/', $row->updated));
+ }
+ if ($User->admin('user') || $User->login === $row->author) {
+ $rowdate .= sprintf(' %s ',
+ "/{$Page->link}/{$row->id}", 'reactie aanpassen', "\u{270D}");
+ }
+ }
+ printf(' %s ', $rowdate);
+ if ($html = $row->message) {
+ $html = preg_replace('/(?<= 2 ? 'loading="lazy" ' : '', $html, -1, $found);
+ $imagecount += $found;
+ if ($i) {
+ $html = "\n$html \n";
+ }
+ print $html;
+ }
+ if ($changes = json_decode($row->journal)) {
+ print '';
+ foreach ($changes as $change) {
+ print '';
+ if ($change->col == 'closed') {
+ printf('%s ', isset($change->value) ? 'Gesloten' : 'Heropend');
+ }
+ else {
+ printf("%s %s",
+ $journalcol[$change->col], sprintf(
+ !isset($change->old_value) ? 'gewijzigd naar %2$s ' :
+ (!isset($change->value) ? 'verwijderd (%s )' :
+ 'gewijzigd van %s naar %s '),
+ $change->old_value, $change->value
+ )
+ );
+ }
+ print " \n";
+ }
+ print " \n";
+ }
+ print " \n";
}
-print '';
-print ' \n";
+if ($User->login) {
+ print ' ';
+ print '';
+ if (isset($Issue) and $User->admin("edit {$Page->link}")) {
+ print "\n";
+ print '';
+ printf(
+ '%s: '
+ . ' '."\n",
+ 'subject',
+ $journalcol['subject'],
+ htmlspecialchars($Issue->subject ?? '')
+ );
+ print "
\n";
+
+ print '';
+ printf(
+ '%s: '
+ . ' '."\n",
+ 'assign',
+ $journalcol['assign'],
+ htmlspecialchars($Issue->assign ?? '')
+ );
+ printf(
+ ' ' .
+ ' '
+ . ' %s '."\n",
+ 'status',
+ 'resolved',
+ isset($Issue->closed) ? ' checked' : '',
+ 'Gesloten'
+ );
+ print "
\n";
+ print " \n";
+ }
+ {
+ print '';
+ printf(
+ ' '
+ . "Geplaatste berichten zijn hier direct zichtbaar voor bewoners.\n"
+ . ' '
+ . ' %s '."\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(
+ '%s: '
+ . '
'."\n",
+ 'image', 'Beeldmateriaal', ' type="file" accept="image/*"'
+ );
+ }
+ printf('%s '."\n",
+ 'reply',
+ "Bericht van {$User->login}",
+ ''
+ );
+ print ' '."\n";
+ print " ";
+ print '';
+ print " \n";
+}
-print " \n\n";
+print "\n\n";