X-Git-Url: http://git.shiar.net/minimedit.git/blobdiff_plain/55cb3025c5506ec7faaa1818a4d8161aaad19c27..10356b51f95050d0aec0cd1807d5ba1ec46d475a:/issue/index.php?ds=sidebyside diff --git a/issue/index.php b/issue/index.php index d8f9c26..cefe00f 100644 --- a/issue/index.php +++ b/issue/index.php @@ -3,34 +3,47 @@ global $User, $Db; require_once 'database.inc.php'; @list ($id, $title) = explode('/', ltrim($Args, '/')); -if ($id) { +if ($id and ctype_digit($id)) { $Article->title = "Issue #$id"; - - $row = $Db->query( - 'SELECT * FROM issues WHERE id = ?', [$id] + $Args = "/$id"; # minimal reference + $Issue = $Db->query( + 'SELECT * FROM issues WHERE page = ? AND id = ?', [$Page, $id] )->fetch(); - if (!$row) throw new Exception('Issuenummer niet gevonden'); + if (!$Issue) throw new Exception('Issuenummer niet gevonden'); + + $replies = placeholder_include('reply'); # handle updates - $Article->title .= ': '.htmlspecialchars($row->subject); + $Article->title .= ': '.htmlspecialchars($Issue->subject); print "
%s %s
'."\n", - 'Opgelost', showdate(preg_split('/\D/', $row->closed)) - ); + print "$html
"; - $query = $Db->insert('issues', [ + require_once 'upload.inc.php'; + $query = $Db->set('issues', [ 'page' => $Page, 'subject' => $_POST['subject'], - 'body' => $html, + 'body' => messagehtml($_POST['body']), 'author' => $User->login, ]); if (!$query->rowCount()) { @@ -39,18 +52,34 @@ if ($_POST) { $_POST = []; } -$query = $Db->query('SELECT * FROM issues ORDER BY created DESC'); +$cols = "*, (SELECT count(*) FROM comments WHERE" + . " page=i.page||'/'||i.id AND message IS NOT NULL) AS replycount"; +$sql = "SELECT $cols FROM issues i WHERE page = ?"; +if (isset($_GET['open'])) { + $sql .= ' AND closed IS NULL'; +} +$sql .= ' ORDER BY closed IS NOT NULL, updated DESC'; +$query = $Db->query($sql, [$Page]); + +if ($id == 'feed') { + require 'issue/feed.inc.php'; +} ob_start(); print '