summaryrefslogtreecommitdiff
path: root/src/application/actions/deletepost
diff options
context:
space:
mode:
authorJonas Kohl2024-10-17 10:56:01 +0200
committerJonas Kohl2024-10-17 10:56:01 +0200
commitfe0f414dc0211a4014581dc03fcfd514ed7ed02d (patch)
treecd86fc00cd9b7a97eabb9668e0a39e2b4b3e5357 /src/application/actions/deletepost
parente0e89b9fdbf301e0ead944636023947a67aca57d (diff)
Transition templating to Twig
Diffstat (limited to 'src/application/actions/deletepost')
-rw-r--r--src/application/actions/deletepost/post.php21
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()]);
}