reply: set method to abstract update queries
[minimedit.git] / issue / index.php
index 2c50624f9a7fc1cbc7fae406ce4fb65f76eea1a6..10efc5ebcc87537a549c056f3ca9b2cbe81031a4 100644 (file)
@@ -14,9 +14,15 @@ if ($id) {
        $Article->title .= ': '.htmlspecialchars($row->subject);
        print "<h2>{$Article->title}</h2>\n";
        print $row->body;
        $Article->title .= ': '.htmlspecialchars($row->subject);
        print "<h2>{$Article->title}</h2>\n";
        print $row->body;
+       printf('<p><em>%s</em>%s <small class=date>%s</small></p>'."\n",
+               'Geplaatst',
+               $row->author ? " door <strong>{$row->author}</strong>" : '',
+               showdate(preg_split('/\D/', $row->created))
+       );
        if ($row->closed) {
        if ($row->closed) {
-               printf('<p><strong>%s</strong> <small class=date>%s</small></p>'."\n",
-                       'Opgelost', showdate(preg_split('/\D/', $row->closed))
+               printf('<p><em>%s</em>%s <small class=date>%s</small></p>'."\n",
+                       'Opgelost', '',
+                       showdate(preg_split('/\D/', $row->closed))
                );
        }
        $Args = "/$id";  # minimal reference
                );
        }
        $Args = "/$id";  # minimal reference
@@ -27,7 +33,7 @@ if ($id) {
 if ($_POST) {
                $html = nl2br(htmlspecialchars($_POST['body']));
                $html = empty($html) ? NULL : "<p>$html</p>";
 if ($_POST) {
                $html = nl2br(htmlspecialchars($_POST['body']));
                $html = empty($html) ? NULL : "<p>$html</p>";
-               $query = $Db->insert('issues', [
+               $query = $Db->set('issues', [
                        'page'    => $Page,
                        'subject' => $_POST['subject'],
                        'body'    => $html,
                        'page'    => $Page,
                        'subject' => $_POST['subject'],
                        'body'    => $html,
@@ -39,7 +45,12 @@ if ($_POST) {
                $_POST = [];
 }
 
                $_POST = [];
 }
 
-$query = $Db->query('SELECT * FROM issues ORDER BY updated DESC');
+$sql = 'SELECT * FROM issues';
+if (isset($_GET['open'])) {
+       $sql .= ' WHERE closed IS NULL';
+}
+$sql .= ' ORDER BY closed IS NOT NULL, updated DESC';
+$query = $Db->query($sql);
 
 ob_start();
 print '<ul>';
 
 ob_start();
 print '<ul>';