X-Git-Url: http://git.shiar.net/minimedit.git/blobdiff_plain/d33a85fd3d187d76fd86f891bba2d9fe17a035a0..8216853ef9dabf609c67f2cfea3b71a5c9811c6e:/widget/reply.php
diff --git a/widget/reply.php b/widget/reply.php
index 6fc1fa5..4f6a2c8 100644
--- a/widget/reply.php
+++ b/widget/reply.php
@@ -1,52 +1,145 @@
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]);
+
+if ($row = $query->fetch()) {
+ print $row->message;
+ $Page->teaser = $row->raw;
+}
-print '';
+print '';
+$imagecount = 0;
while ($row = $query->fetch()) {
$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);
+ printf('%s', $rowuser->html);
+ $rowdate = showdate(preg_split('/\D/', $row->created));
+ if ($User->admin('beheer') and $row->updated) {
+ $rowdate = "$rowdate " . showdate(preg_split('/\D/', $row->updated));
+ }
+ printf(' %s', $rowdate);
+ if ($User->admin('beheer') and $User->admin('user') || $User->login === $row->author) {
+ printf(' %s',
+ "/{$Page->link}/{$row->id}", 'reactie aanpassen', "\u{270D}");
+ }
+ if ($html = $row->message) {
+ $html = preg_replace('/(?<=
2 ? 'loading="lazy" ' : '', $html, -1, $found);
+ $imagecount += $found;
+ printf("\n%s
\n", $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";
}
-if ($User) {
- print '- ';
- print '
\n";
+ print "";
+ print '';
+ print "\n";
}
-print "
\n\n";
+print "\n\n";