X-Git-Url: http://git.shiar.net/minimedit.git/blobdiff_plain/176e85a6f5d6274e96a175d57b007c7afe677299..3a4f1ae1a32baa3658d54c3dadf268bab01308a2:/issue/index.php diff --git a/issue/index.php b/issue/index.php index 6b1c3dc..3f665db 100644 --- a/issue/index.php +++ b/issue/index.php @@ -3,40 +3,50 @@ 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($Issue->subject); + $Article->teaser = $Issue->body; + $Article->body = $replies; # find image - $Article->title .= ': '.htmlspecialchars($row->subject); print "

{$Article->title}

\n"; - print $row->body; - printf('

%s%s %s

'."\n", - 'Geplaatst', - $row->author ? " door {$row->author}" : '', - showdate(preg_split('/\D/', $row->created)) - ); - if ($row->closed) { - printf('

%s%s %s

'."\n", - 'Opgelost', '', - showdate(preg_split('/\D/', $row->closed)) - ); + print "
\n"; + print '
Geplaatst
'; + printf('
%s
'."\n", showdate(preg_split('/\D/', $Issue->created))); + if ($Issue->author and $author = new User('profile/'.$Issue->author, FALSE)) { + printf('
%s
'."\n", $author->html); } - $Args = "/$id"; # minimal reference - print placeholder_include('reply'); + if ($Issue->assign) { + print '
Toegewezen aan
'; + printf('
%s
'."\n", htmlspecialchars($Issue->assign)); + } + if ($Issue->closed) { + print '
Opgelost
'; + printf('
%s
'."\n", showdate(preg_split('/\D/', $Issue->closed))); + } + print "
\n\n"; + + print '
'; + print $Issue->body; + print $replies; + print "
\n"; return; } if ($_POST) { - $html = nl2br(htmlspecialchars($_POST['body'])); - $html = empty($html) ? NULL : "

$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()) { @@ -45,18 +55,46 @@ if ($_POST) { $_POST = []; } -$query = $Db->query('SELECT * FROM issues ORDER BY updated DESC'); +$subsql = "SELECT count(*) FROM comments WHERE page=i.page||'/'||i.id"; +$cols = "*, ($subsql AND message IS NOT NULL) AS replycount"; +$cols .= ", ($subsql AND message ~ 'query($sql, [$Page]); + +if ($id == 'feed') { + require 'issue/feed.inc.php'; +} ob_start(); print '\n"; $Place['issuelist'] = ob_get_clean();