issue: indicate reply updates to admins
[minimedit.git] / widget / reply.php
index 6fe9eb1fc5eadcf5b3a098734ab2dde733277a9d..7e7d327f3c2728d13a2cbc449a7d0a964f3c2060 100644 (file)
@@ -6,7 +6,7 @@ require_once 'upload.inc.php';
 if ($_POST) {
        try {
                $newcomment = createcomment($_POST, $Issue);
-               $target = "/{$Page->link}/$newcomment#$newcomment";
+               $target = "/{$Page->link}?last=$newcomment#$newcomment";
                abort($target, ($Page->api ? 200 : 303) . ' reply success');
                $_POST['reply'] = NULL;
        }
@@ -14,11 +14,13 @@ if ($_POST) {
                if ($Page->api) {
                        abort(ucfirst($e->getMessage()), '500 reply error');
                }
-               print "<p class=warn>Antwoord niet opgeslagen: {$e->getMessage()}.</p>\n\n";
+               printf("<p class=warn>Antwoord niet opgeslagen: %s.</p>\n\n",
+                       nl2br(htmlspecialchars($e->getMessage()))
+               );
        }
 }
 
-$cols = '*, (SELECT json_agg(journal.*) FROM journal WHERE comment_id = comments.id) AS journal';
+$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()) {
@@ -32,8 +34,12 @@ $imagecount = 0;
 while ($row = $query->fetch()) {
        $rowuser = new User("profile/{$row->author}");
        printf('<li id="%d">', $row->id);
+       $rowdate = showdate(preg_split('/\D/', $row->created));
+       if ($User->admin('beheer') and $row->updated) {
+               $rowdate = "<s>$rowdate</s> " . showdate(preg_split('/\D/', $row->updated));
+       }
        printf('<strong>%s</strong> <small class=date>%s</small>',
-               $rowuser->html, showdate(preg_split('/\D/', $row->created))
+               $rowuser->html, $rowdate
        );
        if ($html = $row->message) {
                $html = preg_replace('/(?<=<img )/',