issue/activity: prevent abbreviation of subsequent images
[minimedit.git] / widget / reply.php
index d305fc7c946e4abac1a8fcc761a0cb185bea6931..0a0e4e55848f275380f7a3d97ef910382e0545e7 100644 (file)
@@ -4,6 +4,7 @@ require_once 'database.inc.php';
 
 $journalcol = [
        'assign' => 'Toegewezen aan',
+       'subject' => 'Onderwerp',
 ];
 
 if ($_POST) {
@@ -17,7 +18,14 @@ if ($_POST) {
                        }
                        $target .= '/' . $User->login;
                        if ($result = userupload($_FILES['image'], $target)) {
-                               $html .= sprintf('<p><img src="/thumb/640x/%s" /></p>', $result);
+                               if (preg_match('(^image/)', $_FILES['image']['type'])) {
+                                       $html .= sprintf('<p><img src="/thumb/640x/%s" /></p>', $result);
+                               }
+                               else {
+                                       $html .= sprintf('<p>Bijgevoegd bestand: <a href="/%s" />%s</a></p>',
+                                               $result, basename($result)
+                                       );
+                               }
                        }
                }
                $query = $Db->set('comments', [
@@ -60,9 +68,15 @@ 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 "<p class=warn>Antwoord niet opgeslagen: {$e->getMessage()}.</p>\n\n";
        }
 }
@@ -74,7 +88,7 @@ print '<ul class="replies">';
 
 while ($row = $query->fetch()) {
        $rowuser = new User("profile/{$row->author}");
-       print '<li>';
+       printf('<li id="%d">', $row->id);
        printf('<strong>%s</strong> <small class=date>%s</small>',
                $rowuser->html, showdate(preg_split('/\D/', $row->created))
        );
@@ -139,7 +153,9 @@ if ($User->login) {
                ''
        );
        print '<input type="submit" value="Plaatsen" />'."\n";
-       print "</form></li>\n";
+       print "</form>";
+       print '<script src="/upload/progress.js"></script>';
+       print "</li>\n";
 }
 
 print "</ul>\n\n";