X-Git-Url: http://git.shiar.nl/minimedit.git/blobdiff_plain/fac6ba761f971deb77a5686ead99ec6534f931d2..621fc2f9638a1a92aa8535310e7852de5542f11e:/widget/reply.php diff --git a/widget/reply.php b/widget/reply.php index ab04137..edffaa7 100644 --- a/widget/reply.php +++ b/widget/reply.php @@ -2,12 +2,24 @@ global $User, $Db, $Issue; require_once 'database.inc.php'; -print '

Reacties

'."\n"; +$journalcol = [ + 'assign' => 'Toegewezen aan', +]; if ($_POST) { + require_once 'upload.inc.php'; try { - $html = nl2br(htmlspecialchars($_POST['reply'])); - $html = "

$html

"; + $html = messagehtml($_POST['reply']); + if ($_FILES and !empty($_FILES['image'])) { + $target = 'data/upload'; + if (!file_exists($target)) { + throw new Exception("er is geen uploadmap aanwezig op $target"); + } + $target .= '/' . $User->login; + if ($result = userupload($_FILES['image'], $target)) { + $html .= sprintf('

', $result); + } + } $query = $Db->set('comments', [ 'page' => $Page, 'message' => $html, @@ -20,7 +32,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; } @@ -45,6 +57,7 @@ if ($_POST) { 'value' => $updated->$col, ]); } + $Issue = $updated; } } $_POST['reply'] = NULL; @@ -54,7 +67,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 '