X-Git-Url: http://git.shiar.nl/minimedit.git/blobdiff_plain/390f24390894684c6f6d4f70261883e6d828502d..7c9537015a7361681323e5a5ce2f10d9c0ee42d3:/widget/reply.php diff --git a/widget/reply.php b/widget/reply.php index 3984349..0935567 100644 --- a/widget/reply.php +++ b/widget/reply.php @@ -21,7 +21,7 @@ if ($_POST) { } } $query = $Db->set('comments', [ - 'page' => $Page, + 'page' => $Page->link, 'message' => $html, 'author' => $User->login, ]); @@ -60,21 +60,27 @@ if ($_POST) { $Issue = $updated; } } + + $target = "/{$Page->link}/$newcomment#$newcomment"; + abort($target, ($Page->api ? 200 : 303) . ' reply success'); $_POST['reply'] = NULL; } catch (Exception $e) { + if ($Page->api) { + abort(ucfirst($e->getMessage()), '500 reply error'); + } print "

Antwoord niet opgeslagen: {$e->getMessage()}.

\n\n"; } } $cols = '*, (SELECT json_agg(journal.*) FROM journal WHERE comment_id = comments.id) AS journal'; -$query = $Db->query("SELECT $cols FROM comments WHERE page = ? ORDER BY created", [$Page]); +$query = $Db->query("SELECT $cols FROM comments WHERE page = ? ORDER BY created", [$Page->link]); print '\n\n";