3 require_once 'database.inc.php';
4 @list ($id, $title) = explode('/', ltrim($Page->path, '/'));
6 if ($id and ctype_digit($id)) {
7 $Page->title = "Issue #$id";
8 $Page->path = "/$id"; # minimal reference
10 'SELECT * FROM issues WHERE page = ? AND id = ?', [$Page->handler, $id]
12 if (!$Issue) throw new Exception('Issuenummer niet gevonden');
14 $replies = $Page->widget('reply'); # handle updates
16 $Page->title .= ': '.htmlspecialchars($Issue->subject);
17 $Page->teaser = $Issue->body;
19 $Page->body = $replies; # find image
21 print "<h2>{$Page->title}</h2>\n";
22 print '<aside class="metadata"><dl>'."\n";
23 print '<dt>Geplaatst</dt>';
24 printf('<dd>%s</dd>'."\n", showdate(preg_split('/\D/', $Issue->created)));
25 if ($Issue->author and $author = new User('profile/'.$Issue->author, FALSE)) {
26 printf('<dd>%s</dd>'."\n", $author->html);
29 print '<dt>Toegewezen aan</dt>';
30 printf('<dd>%s</dd>'."\n", htmlspecialchars($Issue->assign));
33 print '<dt>Opgelost</dt>';
34 printf('<dd>%s</dd>'."\n", showdate(preg_split('/\D/', $Issue->closed)));
36 print "</dl></aside>\n\n";
44 elseif (!$User) return;
47 require_once 'upload.inc.php';
48 $query = $Db->set('issues', [
49 'page' => $Page->handler,
50 'subject' => $_POST['subject'],
51 'body' => messagehtml($_POST['body']),
52 'author' => $User->login,
54 if (!$query->rowCount()) {
55 throw new Exception('Issue niet opgeslagen.');
60 $subsql = "SELECT count(*) FROM comments WHERE page=i.page||'/'||i.id";
61 $cols = "*, ($subsql AND message IS NOT NULL) AS replycount";
62 $cols .= ", ($subsql AND message ~ '<img') AS imagecount";
63 $sql = "SELECT $cols FROM issues i WHERE page = ?";
64 if (isset($_GET['open'])) {
65 $sql .= ' AND closed IS NULL';
67 $sql .= ' ORDER BY closed IS NOT NULL, updated DESC';
68 $query = $Db->query($sql, [$Page->handler]);
71 require 'issue/feed.inc.php';
76 while ($row = $query->fetch()) {
77 printf('<li%s><div><a href="%s">',
78 $row->closed ? ' class="disabled"' : '',
79 "/{$Page->handler}/{$row->id}/{$row->link}"
81 printf($row->closed ? '<s>%s</s>' : '%s', htmlspecialchars($row->subject));
83 printf(' <small class="date">%s</small>',
84 showdate(array_slice(preg_split('/\D/', $row->updated), 0, 3))
87 if ($row->replycount) {
88 printf(' <span class=right>%s %d</span>',
89 '<span class="icon icon-comment" title="reacties">🗨</span>',
93 if ($row->imagecount) {
94 print ' <span class="right icon icon-camera" title="afbeeldingen">📷</span>';
96 if (isset($row->assign)) {
97 print ' <em class="right">'.$row->assign.'</em>';
99 print "</a></div></li>\n";
102 $Page->place['issuelist'] = ob_get_clean();