2 global $User, $Db, $Issue;
3 require_once 'database.inc.php';
6 'assign' => 'Toegewezen aan',
11 $html = nl2br(htmlspecialchars($_POST['reply']));
12 $html = "<p>$html</p>";
13 $query = $Db->set('comments', [
16 'author' => $User->login,
18 if (!$query->rowCount()) {
19 throw new Exception('Fout bij opslaan');
21 $newcomment = $Db->dbh->lastInsertId('comments_id_seq');
25 foreach (array_keys($journalcol) as $col) {
26 if (!isset($_POST[$col])) continue;
27 $row[$col] = $_POST[$col] ?: NULL;
29 if (isset($_POST['status'])) {
30 $reset = !empty($_POST['status']);
31 if (isset($Issue->closed) !== $reset) {
32 $row['closed'] = $reset ? ['now()'] : NULL;
35 $derived = ['updated' => ['now()']];
36 $filter = ['id = ? RETURNING *', $Issue->id];
37 $subquery = $Db->set('issues', $row + $derived, $filter);
39 if ($updated = $subquery->fetch()) {
40 foreach (array_keys($row) as $col) {
41 if ($updated->$col === $Issue->$col) continue; # unaltered
43 'comment_id' => $newcomment,
46 'old_value' => $Issue->$col,
47 'value' => $updated->$col,
52 $_POST['reply'] = NULL;
54 catch (Exception $e) {
55 print "<p class=warn>Antwoord niet opgeslagen: {$e->getMessage()}.</p>\n\n";
59 $query = $Db->query('SELECT * FROM comments WHERE page = ? ORDER BY created', [$Page]);
61 print '<ul class="replies">';
63 while ($row = $query->fetch()) {
64 $rowuser = new User("profile/{$row->author}");
66 printf('<strong>%s</strong> <small class=date>%s</small>',
67 $rowuser->html, showdate(preg_split('/\D/', $row->created))
69 printf("<blockquote>%s</blockquote>\n", $row->message);
75 print '<form method="post" action="">';
76 if (isset($Issue) and $User->admin("edit $Page")) {
79 '<label for="%s">%s:</label> '
80 . '<input id="%1$s" name="%1$s" value="%s" />'."\n",
82 $journalcol['assign'],
83 htmlspecialchars($Issue->assign ?? '')
86 '<input type="hidden" name="%s" value="" />' .
87 '<input type="checkbox" id="%1$s" name="%1$s" value="%s"%s />'
88 . '<label for="%1$s"> %s</label>'."\n",
91 isset($Issue->closed) ? ' checked' : '',
96 printf('<textarea id="%s" name="%1$s" cols=60 rows=3 placeholder="%s">%s</textarea>'."\n",
98 "Bericht van {$User->login}",
101 print '<input type="submit" value="Plaatsen" />'."\n";
102 print "</form></li>\n";