X-Git-Url: http://git.shiar.net/minimedit.git/blobdiff_plain/c824b14c0f6fb372ca4e72fe244b3aade6c29541..HEAD:/widget/reply.php?ds=sidebyside
diff --git a/widget/reply.php b/widget/reply.php
index abb364c..0c5d5a3 100644
--- a/widget/reply.php
+++ b/widget/reply.php
@@ -1,58 +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');
- }
- if (@list ($cat, $issue) = explode('/', $Page) and ctype_digit($issue)) {
- $Db->query(
- 'UPDATE issues SET updated = now() WHERE page = ? AND id = ?',
- [$cat, $issue]
- );
- }
+ $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: {$e->getMessage()}.
\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()) {
+$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";
}
-if ($User) {
- print '- ';
- print '
\n";
+ print "";
+ print '';
+ print "\n";
}
-print "
\n\n";
+print "\n\n";