reply: share parent data from issue page
authorMischa POSLAWSKY <perl@shiar.org>
Thu, 7 Nov 2019 04:04:09 +0000 (05:04 +0100)
committerMischa POSLAWSKY <perl@shiar.org>
Sat, 9 Nov 2019 06:08:13 +0000 (07:08 +0100)
Provide easy access to selected metadata.

issue/index.php
widget/reply.php

index 10efc5ebcc87537a549c056f3ca9b2cbe81031a4..835f1f0ec14bec32682cee4f72dc2adaae865baf 100644 (file)
@@ -6,23 +6,23 @@ require_once 'database.inc.php';
 if ($id) {
        $Article->title = "Issue #$id";
 
-       $row = $Db->query(
+       $Issue = $Db->query(
                'SELECT * FROM issues WHERE id = ?', [$id]
        )->fetch();
-       if (!$row) throw new Exception('Issuenummer niet gevonden');
+       if (!$Issue) throw new Exception('Issuenummer niet gevonden');
 
-       $Article->title .= ': '.htmlspecialchars($row->subject);
+       $Article->title .= ': '.htmlspecialchars($Issue->subject);
        print "<h2>{$Article->title}</h2>\n";
-       print $row->body;
+       print $Issue->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))
+               $Issue->author ? " door <strong>{$Issue->author}</strong>" : '',
+               showdate(preg_split('/\D/', $Issue->created))
        );
-       if ($row->closed) {
+       if ($Issue->closed) {
                printf('<p><em>%s</em>%s <small class=date>%s</small></p>'."\n",
                        'Opgelost', '',
-                       showdate(preg_split('/\D/', $row->closed))
+                       showdate(preg_split('/\D/', $Issue->closed))
                );
        }
        $Args = "/$id";  # minimal reference
index 4d504bbeb122c30ec7e4bb4888dbcfc32a57a785..4c7a3045d80ae11c7bf7bd6375214330e09b7ef1 100644 (file)
@@ -1,5 +1,5 @@
 <?php
-global $User, $Db;
+global $User, $Db, $Issue;
 require_once 'database.inc.php';
 
 print '<h3>Reacties</h3>'."\n";
@@ -16,9 +16,10 @@ if ($_POST) {
                if (!$query->rowCount()) {
                        throw new Exception('Fout bij opslaan');
                }
-               if (@list ($cat, $issue) = explode('/', $Page) and ctype_digit($issue)) {
+
+               if (isset($Issue)) {
                        $row = ['updated' => ['now()']];
-                       $Db->set('issues', $row, ['page = ? AND id = ?', $cat, $issue]);
+                       $Db->set('issues', $row, ['id = ?', $Issue->id]);
                }
                $_POST['reply'] = NULL;
        }