widget: unnamed options as placeholders instead of path
[minimedit.git] / widget / reply.php
index cedcc4919699194fe60926bf5a67adf316dfa38c..d305fc7c946e4abac1a8fcc761a0cb185bea6931 100644 (file)
@@ -10,17 +10,18 @@ if ($_POST) {
        require_once 'upload.inc.php';
        try {
                $html = messagehtml($_POST['reply']);
-               if ($_FILES and isset($_FILES['image'])) {
+               if ($_FILES and !empty($_FILES['image'])) {
                        $target = 'data/upload';
                        if (!file_exists($target)) {
                                throw new Exception("er is geen uploadmap aanwezig op $target");
                        }
                        $target .= '/' . $User->login;
-                       $result = userupload($_FILES['image'], $target);
-                       $html .= sprintf('<p><img src="/thumb/640x/%s" /></p>', $result);
+                       if ($result = userupload($_FILES['image'], $target)) {
+                               $html .= sprintf('<p><img src="/thumb/640x/%s" /></p>', $result);
+                       }
                }
                $query = $Db->set('comments', [
-                       'page'    => $Page,
+                       'page'    => $Page->link,
                        'message' => $html,
                        'author'  => $User->login,
                ]);
@@ -67,7 +68,7 @@ if ($_POST) {
 }
 
 $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]);
+$query = $Db->query("SELECT $cols FROM comments WHERE page = ? ORDER BY created", [$Page->link]);
 
 print '<ul class="replies">';
 
@@ -89,7 +90,7 @@ while ($row = $query->fetch()) {
                                printf("<em>%s</em> %s",
                                        $journalcol[$change->col], sprintf(
                                                !isset($change->old_value) ? 'gewijzigd naar <q>%2$s</q>' :
-                                               (!isset($change->value) ? 'verwijderd (<strike>%s</strike>)' :
+                                               (!isset($change->value) ? 'verwijderd (<s>%s</s>)' :
                                                'gewijzigd van <q>%s</q> naar <q>%s</q>'),
                                                $change->old_value, $change->value
                                        )
@@ -102,10 +103,10 @@ while ($row = $query->fetch()) {
        print "</li>\n";
 }
 
-if ($User) {
+if ($User->login) {
        print '<li>';
        print '<form method="post" action="" enctype="multipart/form-data">';
-       if (isset($Issue) and $User->admin("edit $Page")) {
+       if (isset($Issue) and $User->admin("edit {$Page->link}")) {
                print '<p>';
                printf(
                        '<label for="%s">%s:</label> '