X-Git-Url: http://git.shiar.net/minimedit.git/blobdiff_plain/dffe1a696198bbbda380d4bf0cc6300a0d1e6748..90195dc7b356af20763a01246d9e5611f8d667d0:/widget/reply.php diff --git a/widget/reply.php b/widget/reply.php index 9761cf2..fd01a94 100644 --- a/widget/reply.php +++ b/widget/reply.php @@ -2,13 +2,16 @@ global $User, $Db, $Issue; require_once 'database.inc.php'; +$journalcol = [ + 'assign' => 'Toegewezen aan', +]; + if ($_POST) { + require_once 'upload.inc.php'; try { - $html = nl2br(htmlspecialchars($_POST['reply'])); - $html = "

$html

"; $query = $Db->set('comments', [ 'page' => $Page, - 'message' => $html, + 'message' => messagehtml($_POST['reply']), 'author' => $User->login, ]); if (!$query->rowCount()) { @@ -18,7 +21,7 @@ if ($_POST) { if (isset($Issue)) { $row = []; - foreach (['assign'] as $col) { + foreach (array_keys($journalcol) as $col) { if (!isset($_POST[$col])) continue; $row[$col] = $_POST[$col] ?: NULL; } @@ -43,6 +46,7 @@ if ($_POST) { 'value' => $updated->$col, ]); } + $Issue = $updated; } } $_POST['reply'] = NULL; @@ -52,7 +56,8 @@ if ($_POST) { } } -$query = $Db->query('SELECT * FROM comments WHERE page = ? ORDER BY created', [$Page]); +$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]); print '