X-Git-Url: http://git.shiar.nl/minimedit.git/blobdiff_plain/772961fd4e9be46ad340cad1e55ee5f28cc5b968..8d0254ce8a1ebceb80a2d14af414af1ca0a972be:/widget/reply.php
diff --git a/widget/reply.php b/widget/reply.php
index ca38ce9..0a0e4e5 100644
--- a/widget/reply.php
+++ b/widget/reply.php
@@ -4,6 +4,7 @@ require_once 'database.inc.php';
$journalcol = [
'assign' => 'Toegewezen aan',
+ 'subject' => 'Onderwerp',
];
if ($_POST) {
@@ -17,11 +18,18 @@ if ($_POST) {
}
$target .= '/' . $User->login;
if ($result = userupload($_FILES['image'], $target)) {
- $html .= sprintf('
![](/thumb/640x/%s)
', $result);
+ if (preg_match('(^image/)', $_FILES['image']['type'])) {
+ $html .= sprintf('![](/thumb/640x/%s)
', $result);
+ }
+ else {
+ $html .= sprintf('Bijgevoegd bestand: %s
',
+ $result, basename($result)
+ );
+ }
}
}
$query = $Db->set('comments', [
- 'page' => $Page->handler,
+ 'page' => $Page->link,
'message' => $html,
'author' => $User->login,
]);
@@ -60,21 +68,27 @@ if ($_POST) {
$Issue = $updated;
}
}
+
+ $target = "/{$Page->link}/$newcomment#$newcomment";
+ abort($target, ($Page->api ? 200 : 303) . ' reply success');
$_POST['reply'] = NULL;
}
catch (Exception $e) {
+ if ($Page->api) {
+ abort(ucfirst($e->getMessage()), '500 reply error');
+ }
print "Antwoord niet opgeslagen: {$e->getMessage()}.
\n\n";
}
}
$cols = '*, (SELECT json_agg(journal.*) FROM journal WHERE comment_id = comments.id) AS journal';
-$query = $Db->query("SELECT $cols FROM comments WHERE page = ? ORDER BY created", [$Page->handler]);
+$query = $Db->query("SELECT $cols FROM comments WHERE page = ? ORDER BY created", [$Page->link]);
print '';
while ($row = $query->fetch()) {
$rowuser = new User("profile/{$row->author}");
- print '- ';
+ printf('
- ', $row->id);
printf('%s %s',
$rowuser->html, showdate(preg_split('/\D/', $row->created))
);
@@ -106,7 +120,7 @@ while ($row = $query->fetch()) {
if ($User->login) {
print '
- ';
print '
\n";
+ print "";
+ print '';
+ print "\n";
}
print "
\n\n";