diff options
Diffstat (limited to 'src/application/actions/deletepost')
-rw-r--r-- | src/application/actions/deletepost/post.php | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/src/application/actions/deletepost/post.php b/src/application/actions/deletepost/post.php index b711021..4cd9872 100644 --- a/src/application/actions/deletepost/post.php +++ b/src/application/actions/deletepost/post.php @@ -24,11 +24,11 @@ if (!$db->fetch($item) || $item->deleted) { exit; } -$topicAuthor = new User(); -$topicAuthor->id = $item->authorId; +$postAuthor = new User(); +$postAuthor->id = $item->authorId; -if (!$db->fetch($topicAuthor)) - $topicAuthor = null; +if (!$db->fetch($postAuthor)) + $postAuthor = null; $topic = new Topic(); $topic->id = $item->topicId; @@ -36,10 +36,10 @@ $topic->id = $item->topicId; if (!$db->fetch($topic)) $topic = null; -$canEdit = ($currentUser->id === $topicAuthor?->id && $topicAuthor?->hasPermission(UserPermissions::DELETE_OWN_POST)) +$canDelete = ($currentUser->id === $postAuthor?->id && $postAuthor?->hasPermission(UserPermissions::DELETE_OWN_POST)) || ($currentUser->hasPermission(UserPermissions::DELETE_OTHER_POST)); -if (!$canEdit) { +if (!$canDelete) { http_response_code(403); msg_error("You don't have permission to delete this post"); exit; @@ -75,16 +75,11 @@ if ($confirm !== null) { header("Location: ?_action=viewtopic&topic=" . urlencode($item->topicId)); } else { - _view("template_start", ["_title" => __("Delete post")]); - _view("template_navigation_start"); - _view("template_navigation", ["user" => RequestUtils::getAuthorizedUser($db)]); - _view("template_navigation_end"); - _view("form_delete_post_confirm", [ + render("delete_post.twig", [ "post" => $item, - "postAuthor" => $topicAuthor, + "postAuthor" => $postAuthor, "topicAuthor" => null, "attachments" => $attachments, "topic" => $topic, ]); - _view("template_end", [...getThemeAndLangInfo()]); } |