page: apply admin restrictions from .private contents
[minimedit.git] / issue / index.php
index 8b42d11f7c499699a2d51ac4debb80ff628478d8..0c18142f06e71c709e997e76514212ebeb1c3c8e 100644 (file)
@@ -15,8 +15,8 @@ if ($id and ctype_digit($id)) {
 
        $Page->title .= ': '.htmlspecialchars($Issue->subject);
        $Page->teaser = $Issue->body;
 
        $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";
@@ -42,8 +42,12 @@ if ($id and ctype_digit($id)) {
        return;
 }
 
        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'],
@@ -55,7 +59,6 @@ if ($_POST) {
                }
                $_POST = [];
 }
                }
                $_POST = [];
 }
-if ($Page->api) return;
 
 $subsql = "SELECT count(*) FROM comments WHERE page=i.page||'/'||i.id";
 $cols = "*, ($subsql AND message IS NOT NULL) AS replycount";
 
 $subsql = "SELECT count(*) FROM comments WHERE page=i.page||'/'||i.id";
 $cols = "*, ($subsql AND message IS NOT NULL) AS replycount";