git.shiar.nl
/
minimedit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
issue: ordered overview including closed tickets
[minimedit.git]
/
issue
/
index.php
diff --git
a/issue/index.php
b/issue/index.php
index 62182ac28356c72c40bc029118f9c798a6497bc7..35a1116b153b72cd26de0973b8e64842ecc5dad3 100644
(file)
--- a/
issue/index.php
+++ b/
issue/index.php
@@
-1,5
+1,5
@@
<?php
<?php
-global $User, $Db;
+global $User, $Db
, $Issue
;
require_once 'database.inc.php';
@list ($id, $title) = explode('/', ltrim($Page->path, '/'));
require_once 'database.inc.php';
@list ($id, $title) = explode('/', ltrim($Page->path, '/'));
@@
-14,9
+14,8
@@
if ($id and ctype_digit($id)) {
$replies = $Page->widget('reply'); # handle updates
$Page->title .= ': '.htmlspecialchars($Issue->subject);
$replies = $Page->widget('reply'); # handle updates
$Page->title .= ': '.htmlspecialchars($Issue->subject);
- $Page->teaser = $Issue->body;
- if ($Page->api) return;
$Page->body = $replies; # find image
$Page->body = $replies; # find image
+ if ($Page->api) return;
print "<h2>{$Page->title}</h2>\n";
print '<aside class="metadata"><dl>'."\n";
print "<h2>{$Page->title}</h2>\n";
print '<aside class="metadata"><dl>'."\n";
@@
-36,35
+35,47
@@
if ($id and ctype_digit($id)) {
print "</dl></aside>\n\n";
print '<div>';
print "</dl></aside>\n\n";
print '<div>';
- print $Issue->body;
print $replies;
print "</div>\n";
return;
}
print $replies;
print "</div>\n";
return;
}
-if ($_POST) {
+if ($Page->api) return;
+if ($_POST and isset($_POST['subject'])) {
require_once 'upload.inc.php';
require_once 'upload.inc.php';
+ if (strlen($_POST['subject']) < 2) {
+ throw new Exception('Een minimaal onderwerp is verplicht om een issue aan te maken.');
+ }
$query = $Db->set('issues', [
'page' => $Page->handler,
'subject' => $_POST['subject'],
$query = $Db->set('issues', [
'page' => $Page->handler,
'subject' => $_POST['subject'],
- '
body' => messagehtml($_POST['body']
),
+ '
link' => preg_replace('/\b(?:de|het|een)\s+|\W+/', '-', strtolower($_POST['subject'])
),
'author' => $User->login,
]);
if (!$query->rowCount()) {
throw new Exception('Issue niet opgeslagen.');
}
'author' => $User->login,
]);
if (!$query->rowCount()) {
throw new Exception('Issue niet opgeslagen.');
}
+ $row = $query->fetch();
+ if (!$row->id) {
+ throw new Exception('Issue niet goed opgeslagen.');
+ }
+ try {
+ createcomment($_POST, $row);
+ }
+ catch (Exception $e) {
+ throw new Exception("Issueinhoud niet opgeslagen: {$e->getMessage()}.");
+ }
$_POST = [];
}
$_POST = [];
}
-if ($Page->api) return;
$subsql = "SELECT count(*) FROM comments WHERE page=i.page||'/'||i.id";
$subsql = "SELECT count(*) FROM comments WHERE page=i.page||'/'||i.id";
-$cols = "*, ($subsql AND message IS NOT NULL) AS replycount";
+$cols = "*, ($subsql AND message IS NOT NULL)
- 1
AS replycount";
$cols .= ", ($subsql AND message ~ '<img') AS imagecount";
$sql = "SELECT $cols FROM issues i WHERE page = ?";
if (isset($_GET['open'])) {
$sql .= ' AND closed IS NULL';
}
$cols .= ", ($subsql AND message ~ '<img') AS imagecount";
$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';
+$sql .= ' ORDER BY updated DESC';
$query = $Db->query($sql, [$Page->handler]);
if ($id == 'feed') {
$query = $Db->query($sql, [$Page->handler]);
if ($id == 'feed') {