2018-05-18 03:20:27 +02:00
|
|
|
<?php
|
2019-09-29 00:43:51 +02:00
|
|
|
namespace Misuzu;
|
|
|
|
|
2020-05-21 15:05:30 +00:00
|
|
|
use Misuzu\AuditLog;
|
2020-10-03 01:14:44 +00:00
|
|
|
use Misuzu\Forum\ForumTopic;
|
|
|
|
use Misuzu\Forum\ForumTopicNotFoundException;
|
|
|
|
use Misuzu\Forum\ForumPost;
|
|
|
|
use Misuzu\Forum\ForumPostNotFoundException;
|
2020-05-25 19:58:06 +00:00
|
|
|
use Misuzu\Users\User;
|
|
|
|
use Misuzu\Users\UserSession;
|
2020-05-21 15:05:30 +00:00
|
|
|
|
2018-10-04 22:30:55 +02:00
|
|
|
require_once '../../misuzu.php';
|
2018-05-18 03:20:27 +02:00
|
|
|
|
2020-10-03 01:14:44 +00:00
|
|
|
$postId = (int)filter_input(INPUT_GET, 'p', FILTER_SANITIZE_NUMBER_INT);
|
|
|
|
$topicId = (int)filter_input(INPUT_GET, 't', FILTER_SANITIZE_NUMBER_INT);
|
|
|
|
$moderationMode = (string)filter_input(INPUT_GET, 'm', FILTER_SANITIZE_STRING);
|
|
|
|
$submissionConfirmed = filter_input(INPUT_GET, 'confirm') === '1';
|
2018-05-20 22:12:45 +02:00
|
|
|
|
2020-05-25 19:58:06 +00:00
|
|
|
$topicUser = User::getCurrent();
|
2020-05-25 22:38:17 +00:00
|
|
|
$topicUserId = $topicUser === null ? 0 : $topicUser->getId();
|
2019-01-05 18:21:48 +01:00
|
|
|
|
2019-06-10 19:04:53 +02:00
|
|
|
if($topicId < 1 && $postId > 0) {
|
2019-01-05 18:21:48 +01:00
|
|
|
$postInfo = forum_post_find($postId, $topicUserId);
|
2018-05-22 01:05:25 +02:00
|
|
|
|
2020-10-03 01:14:44 +00:00
|
|
|
if(!empty($postInfo['topic_id']))
|
2019-01-04 01:11:31 +01:00
|
|
|
$topicId = (int)$postInfo['topic_id'];
|
2018-05-20 22:12:45 +02:00
|
|
|
}
|
|
|
|
|
2020-10-03 01:14:44 +00:00
|
|
|
try {
|
|
|
|
$topicInfo = ForumTopic::byId($topicId);
|
|
|
|
} catch(ForumTopicNotFoundException $ex) {
|
|
|
|
echo render_error(404);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$perms = forum_perms_get_user($topicInfo->getCategory()->getId(), $topicUserId)[MSZ_FORUM_PERMS_GENERAL];
|
2018-05-20 22:12:45 +02:00
|
|
|
|
2020-06-11 20:30:19 +00:00
|
|
|
if(isset($topicUser) && $topicUser->hasActiveWarning())
|
2018-12-28 06:03:42 +01:00
|
|
|
$perms &= ~MSZ_FORUM_PERM_SET_WRITE;
|
|
|
|
|
2019-01-12 00:00:53 +01:00
|
|
|
$canDeleteAny = perms_check($perms, MSZ_FORUM_PERM_DELETE_ANY_POST);
|
|
|
|
|
2020-10-03 01:14:44 +00:00
|
|
|
if($topicInfo->isDeleted() && !$canDeleteAny) {
|
2018-05-26 22:33:05 +02:00
|
|
|
echo render_error(404);
|
2018-05-20 22:12:45 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-06-10 19:04:53 +02:00
|
|
|
if(!perms_check($perms, MSZ_FORUM_PERM_VIEW_FORUM)) {
|
2018-08-23 22:06:48 +02:00
|
|
|
echo render_error(403);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-10-03 01:14:44 +00:00
|
|
|
$topicPostsTotal = $topicInfo->getActualPostCount(true);
|
|
|
|
$topicIsFrozen = $topicInfo->isArchived() || $topicInfo->isDeleted();
|
|
|
|
$canDeleteOwn = !$topicIsFrozen && !$topicInfo->isLocked() && perms_check($perms, MSZ_FORUM_PERM_DELETE_POST);
|
2019-01-12 00:00:53 +01:00
|
|
|
$canBumpTopic = !$topicIsFrozen && perms_check($perms, MSZ_FORUM_PERM_BUMP_TOPIC);
|
|
|
|
$canLockTopic = !$topicIsFrozen && perms_check($perms, MSZ_FORUM_PERM_LOCK_TOPIC);
|
2020-10-03 01:14:44 +00:00
|
|
|
$canNukeOrRestore = $canDeleteAny && $topicInfo->isDeleted();
|
|
|
|
$canDelete = !$topicInfo->isDeleted() && (
|
2019-01-12 00:00:53 +01:00
|
|
|
$canDeleteAny || (
|
|
|
|
$topicPostsTotal > 0
|
|
|
|
&& $topicPostsTotal <= MSZ_FORUM_TOPIC_DELETE_POST_LIMIT
|
|
|
|
&& $canDeleteOwn
|
2020-10-03 01:14:44 +00:00
|
|
|
&& $topicInfo->getUserId() === $topicUserId
|
2019-01-12 00:00:53 +01:00
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
$validModerationModes = [
|
|
|
|
'delete', 'restore', 'nuke',
|
|
|
|
'bump', 'lock', 'unlock',
|
|
|
|
];
|
|
|
|
|
2019-06-10 17:21:53 +02:00
|
|
|
if(in_array($moderationMode, $validModerationModes, true)) {
|
2019-01-12 00:00:53 +01:00
|
|
|
$redirect = !empty($_SERVER['HTTP_REFERER']) && empty($_SERVER['HTTP_X_MISUZU_XHR']) ? $_SERVER['HTTP_REFERER'] : '';
|
|
|
|
$isXHR = !$redirect;
|
|
|
|
|
2019-06-10 17:21:53 +02:00
|
|
|
if($isXHR) {
|
2019-01-12 00:00:53 +01:00
|
|
|
header('Content-Type: application/json; charset=utf-8');
|
2019-06-10 17:21:53 +02:00
|
|
|
} elseif(!is_local_url($redirect)) {
|
2019-01-12 00:00:53 +01:00
|
|
|
echo render_info('Possible request forgery detected.', 403);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-12-11 19:10:54 +01:00
|
|
|
if(!CSRF::validateRequest()) {
|
2019-01-12 00:00:53 +01:00
|
|
|
echo render_info_or_json($isXHR, "Couldn't verify this request, please refresh the page and try again.", 403);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-12-11 19:10:54 +01:00
|
|
|
header(CSRF::header());
|
2019-01-12 00:00:53 +01:00
|
|
|
|
2020-05-25 19:58:06 +00:00
|
|
|
if(!UserSession::hasCurrent()) {
|
2019-01-12 00:00:53 +01:00
|
|
|
echo render_info_or_json($isXHR, 'You must be logged in to manage posts.', 401);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-06-01 00:33:16 +00:00
|
|
|
if($topicUser->isBanned()) {
|
2019-01-12 00:00:53 +01:00
|
|
|
echo render_info_or_json($isXHR, 'You have been banned, check your profile for more information.', 403);
|
|
|
|
return;
|
|
|
|
}
|
2020-06-01 00:33:16 +00:00
|
|
|
if($topicUser->isSilenced()) {
|
2019-01-12 00:00:53 +01:00
|
|
|
echo render_info_or_json($isXHR, 'You have been silenced, check your profile for more information.', 403);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-06-10 19:04:53 +02:00
|
|
|
switch($moderationMode) {
|
2019-01-12 00:00:53 +01:00
|
|
|
case 'delete':
|
2020-10-03 01:14:44 +00:00
|
|
|
$canDeleteCode = forum_topic_can_delete($topicInfo, $topicUserId);
|
2019-01-12 00:00:53 +01:00
|
|
|
$canDeleteMsg = '';
|
|
|
|
$responseCode = 200;
|
|
|
|
|
2019-06-10 19:04:53 +02:00
|
|
|
switch($canDeleteCode) {
|
2019-01-12 00:00:53 +01:00
|
|
|
case MSZ_E_FORUM_TOPIC_DELETE_USER:
|
|
|
|
$responseCode = 401;
|
|
|
|
$canDeleteMsg = 'You must be logged in to delete topics.';
|
|
|
|
break;
|
|
|
|
case MSZ_E_FORUM_TOPIC_DELETE_TOPIC:
|
|
|
|
$responseCode = 404;
|
|
|
|
$canDeleteMsg = "This topic doesn't exist.";
|
|
|
|
break;
|
|
|
|
case MSZ_E_FORUM_TOPIC_DELETE_DELETED:
|
|
|
|
$responseCode = 404;
|
|
|
|
$canDeleteMsg = 'This topic has already been marked as deleted.';
|
|
|
|
break;
|
|
|
|
case MSZ_E_FORUM_TOPIC_DELETE_OWNER:
|
|
|
|
$responseCode = 403;
|
|
|
|
$canDeleteMsg = 'You can only delete your own topics.';
|
|
|
|
break;
|
|
|
|
case MSZ_E_FORUM_TOPIC_DELETE_OLD:
|
|
|
|
$responseCode = 401;
|
|
|
|
$canDeleteMsg = 'This topic has existed for too long. Ask a moderator to remove if it absolutely necessary.';
|
|
|
|
break;
|
|
|
|
case MSZ_E_FORUM_TOPIC_DELETE_PERM:
|
|
|
|
$responseCode = 401;
|
|
|
|
$canDeleteMsg = 'You are not allowed to delete topics.';
|
|
|
|
break;
|
|
|
|
case MSZ_E_FORUM_TOPIC_DELETE_POSTS:
|
|
|
|
$responseCode = 403;
|
|
|
|
$canDeleteMsg = 'This topic already has replies, you may no longer delete it. Ask a moderator to remove if it absolutely necessary.';
|
|
|
|
break;
|
|
|
|
case MSZ_E_FORUM_TOPIC_DELETE_OK:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$responseCode = 500;
|
|
|
|
$canDeleteMsg = sprintf('Unknown error \'%d\'', $canDelete);
|
|
|
|
}
|
|
|
|
|
2019-06-10 19:04:53 +02:00
|
|
|
if($canDeleteCode !== MSZ_E_FORUM_TOPIC_DELETE_OK) {
|
|
|
|
if($isXHR) {
|
2019-01-12 00:00:53 +01:00
|
|
|
http_response_code($responseCode);
|
|
|
|
echo json_encode([
|
|
|
|
'success' => false,
|
2020-10-03 01:14:44 +00:00
|
|
|
'topic_id' => $topicInfo->getId(),
|
2019-01-12 00:00:53 +01:00
|
|
|
'code' => $canDeleteCode,
|
|
|
|
'message' => $canDeleteMsg,
|
|
|
|
]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
echo render_info($canDeleteMsg, $responseCode);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-06-10 19:04:53 +02:00
|
|
|
if(!$isXHR) {
|
|
|
|
if(!isset($_GET['confirm'])) {
|
2019-12-04 19:16:22 +01:00
|
|
|
Template::render('forum.confirm', [
|
2019-01-12 00:00:53 +01:00
|
|
|
'title' => 'Confirm topic deletion',
|
|
|
|
'class' => 'far fa-trash-alt',
|
2020-10-03 01:14:44 +00:00
|
|
|
'message' => sprintf('You are about to delete topic #%d. Are you sure about that?', $topicInfo->getId()),
|
2019-01-12 00:00:53 +01:00
|
|
|
'params' => [
|
2020-10-03 01:14:44 +00:00
|
|
|
't' => $topicInfo->getId(),
|
2019-01-12 00:00:53 +01:00
|
|
|
'm' => 'delete',
|
|
|
|
],
|
|
|
|
]);
|
|
|
|
break;
|
2019-06-10 19:04:53 +02:00
|
|
|
} elseif(!$submissionConfirmed) {
|
2019-06-08 23:46:24 +02:00
|
|
|
url_redirect(
|
2019-06-02 00:44:01 +02:00
|
|
|
'forum-topic',
|
2020-10-03 01:14:44 +00:00
|
|
|
['topic' => $topicInfo->getId()]
|
2019-06-08 23:46:24 +02:00
|
|
|
);
|
2019-06-02 00:44:01 +02:00
|
|
|
break;
|
2019-01-12 00:00:53 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-03 01:14:44 +00:00
|
|
|
$deleteTopic = forum_topic_delete($topicInfo->getId());
|
2019-01-12 00:00:53 +01:00
|
|
|
|
2019-06-10 19:04:53 +02:00
|
|
|
if($deleteTopic) {
|
2020-10-03 01:14:44 +00:00
|
|
|
AuditLog::create(AuditLog::FORUM_TOPIC_DELETE, [$topicInfo->getId()]);
|
2019-01-22 15:24:30 +01:00
|
|
|
}
|
|
|
|
|
2019-06-10 19:04:53 +02:00
|
|
|
if($isXHR) {
|
2019-01-12 00:00:53 +01:00
|
|
|
echo json_encode([
|
|
|
|
'success' => $deleteTopic,
|
2020-10-03 01:14:44 +00:00
|
|
|
'topic_id' => $topicInfo->getId(),
|
2019-01-12 00:00:53 +01:00
|
|
|
'message' => $deleteTopic ? 'Topic deleted!' : 'Failed to delete topic.',
|
|
|
|
]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-06-10 19:04:53 +02:00
|
|
|
if(!$deleteTopic) {
|
2019-01-12 00:00:53 +01:00
|
|
|
echo render_error(500);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-06-08 23:46:24 +02:00
|
|
|
url_redirect('forum-category', [
|
2020-10-03 01:14:44 +00:00
|
|
|
'forum' => $topicInfo->getCategoryId(),
|
2019-06-08 23:46:24 +02:00
|
|
|
]);
|
2019-01-12 00:00:53 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'restore':
|
2019-06-10 19:04:53 +02:00
|
|
|
if(!$canNukeOrRestore) {
|
2019-01-12 00:00:53 +01:00
|
|
|
echo render_error(403);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-06-10 19:04:53 +02:00
|
|
|
if(!$isXHR) {
|
|
|
|
if(!isset($_GET['confirm'])) {
|
2019-12-04 19:16:22 +01:00
|
|
|
Template::render('forum.confirm', [
|
2019-01-12 00:00:53 +01:00
|
|
|
'title' => 'Confirm topic restore',
|
|
|
|
'class' => 'fas fa-magic',
|
2020-10-03 01:14:44 +00:00
|
|
|
'message' => sprintf('You are about to restore topic #%d. Are you sure about that?', $topicInfo->getId()),
|
2019-01-12 00:00:53 +01:00
|
|
|
'params' => [
|
2020-10-03 01:14:44 +00:00
|
|
|
't' => $topicInfo->getId(),
|
2019-01-12 00:00:53 +01:00
|
|
|
'm' => 'restore',
|
|
|
|
],
|
|
|
|
]);
|
|
|
|
break;
|
2019-06-10 19:04:53 +02:00
|
|
|
} elseif(!$submissionConfirmed) {
|
2019-06-08 23:46:24 +02:00
|
|
|
url_redirect('forum-topic', [
|
2020-10-03 01:14:44 +00:00
|
|
|
'topic' => $topicInfo->getId(),
|
2019-06-08 23:46:24 +02:00
|
|
|
]);
|
2019-06-02 00:44:01 +02:00
|
|
|
break;
|
2019-01-12 00:00:53 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-03 01:14:44 +00:00
|
|
|
$restoreTopic = forum_topic_restore($topicInfo->getId());
|
2019-01-12 00:00:53 +01:00
|
|
|
|
2019-06-10 19:04:53 +02:00
|
|
|
if(!$restoreTopic) {
|
2019-01-12 00:00:53 +01:00
|
|
|
echo render_error(500);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-10-03 01:14:44 +00:00
|
|
|
AuditLog::create(AuditLog::FORUM_TOPIC_RESTORE, [$topicInfo->getId()]);
|
2019-01-12 00:00:53 +01:00
|
|
|
http_response_code(204);
|
|
|
|
|
2019-06-10 19:04:53 +02:00
|
|
|
if(!$isXHR) {
|
2019-06-08 23:46:24 +02:00
|
|
|
url_redirect('forum-category', [
|
2020-10-03 01:14:44 +00:00
|
|
|
'forum' => $topicInfo->getCategoryId(),
|
2019-06-08 23:46:24 +02:00
|
|
|
]);
|
2019-01-12 00:00:53 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'nuke':
|
2019-06-10 19:04:53 +02:00
|
|
|
if(!$canNukeOrRestore) {
|
2019-01-12 00:00:53 +01:00
|
|
|
echo render_error(403);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-06-10 19:04:53 +02:00
|
|
|
if(!$isXHR) {
|
|
|
|
if(!isset($_GET['confirm'])) {
|
2019-12-04 19:16:22 +01:00
|
|
|
Template::render('forum.confirm', [
|
2019-01-12 00:00:53 +01:00
|
|
|
'title' => 'Confirm topic nuke',
|
|
|
|
'class' => 'fas fa-radiation',
|
2020-10-03 01:14:44 +00:00
|
|
|
'message' => sprintf('You are about to PERMANENTLY DELETE topic #%d. Are you sure about that?', $topicInfo->getId()),
|
2019-01-12 00:00:53 +01:00
|
|
|
'params' => [
|
2020-10-03 01:14:44 +00:00
|
|
|
't' => $topicInfo->getId(),
|
2019-01-12 00:00:53 +01:00
|
|
|
'm' => 'nuke',
|
|
|
|
],
|
|
|
|
]);
|
|
|
|
break;
|
2019-06-10 19:04:53 +02:00
|
|
|
} elseif(!$submissionConfirmed) {
|
2019-06-08 23:46:24 +02:00
|
|
|
url_redirect('forum-topic', [
|
2020-10-03 01:14:44 +00:00
|
|
|
'topic' => $topicInfo->getId(),
|
2019-06-08 23:46:24 +02:00
|
|
|
]);
|
2019-06-02 00:44:01 +02:00
|
|
|
break;
|
2019-01-12 00:00:53 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-03 01:14:44 +00:00
|
|
|
$nukeTopic = forum_topic_nuke($topicInfo->getId());
|
2019-01-12 00:00:53 +01:00
|
|
|
|
2019-06-10 19:04:53 +02:00
|
|
|
if(!$nukeTopic) {
|
2019-01-12 00:00:53 +01:00
|
|
|
echo render_error(500);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-10-03 01:14:44 +00:00
|
|
|
AuditLog::create(AuditLog::FORUM_TOPIC_NUKE, [$topicInfo->getId()]);
|
2019-01-12 00:00:53 +01:00
|
|
|
http_response_code(204);
|
|
|
|
|
2019-06-10 19:04:53 +02:00
|
|
|
if(!$isXHR) {
|
2019-06-08 23:46:24 +02:00
|
|
|
url_redirect('forum-category', [
|
2020-10-03 01:14:44 +00:00
|
|
|
'forum' => $topicInfo->getCategoryId(),
|
2019-06-08 23:46:24 +02:00
|
|
|
]);
|
2019-01-12 00:00:53 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'bump':
|
2020-10-03 01:14:44 +00:00
|
|
|
if($canBumpTopic && forum_topic_bump($topicInfo->getId())) {
|
|
|
|
AuditLog::create(AuditLog::FORUM_TOPIC_BUMP, [$topicInfo->getId()]);
|
2019-01-12 00:00:53 +01:00
|
|
|
}
|
|
|
|
|
2019-06-08 23:46:24 +02:00
|
|
|
url_redirect('forum-topic', [
|
2020-10-03 01:14:44 +00:00
|
|
|
'topic' => $topicInfo->getId(),
|
2019-06-08 23:46:24 +02:00
|
|
|
]);
|
2019-01-12 00:00:53 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'lock':
|
2020-10-03 01:14:44 +00:00
|
|
|
if($canLockTopic && !$topicInfo->isLocked() && forum_topic_lock($topicInfo->getId())) {
|
|
|
|
AuditLog::create(AuditLog::FORUM_TOPIC_LOCK, [$topicInfo->getId()]);
|
2019-01-12 00:00:53 +01:00
|
|
|
}
|
|
|
|
|
2019-06-08 23:46:24 +02:00
|
|
|
url_redirect('forum-topic', [
|
2020-10-03 01:14:44 +00:00
|
|
|
'topic' => $topicInfo->getId(),
|
2019-06-08 23:46:24 +02:00
|
|
|
]);
|
2019-01-12 00:00:53 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'unlock':
|
2020-10-03 01:14:44 +00:00
|
|
|
if($canLockTopic && $topicInfo->isLocked() && forum_topic_unlock($topicInfo->getId())) {
|
|
|
|
AuditLog::create(AuditLog::FORUM_TOPIC_UNLOCK, [$topicInfo->getId()]);
|
2019-01-12 00:00:53 +01:00
|
|
|
}
|
|
|
|
|
2019-06-08 23:46:24 +02:00
|
|
|
url_redirect('forum-topic', [
|
2020-10-03 01:14:44 +00:00
|
|
|
'topic' => $topicInfo->getId(),
|
2019-06-08 23:46:24 +02:00
|
|
|
]);
|
2019-01-12 00:00:53 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-10-03 01:14:44 +00:00
|
|
|
$topicPagination = new Pagination($topicInfo->getActualPostCount($canDeleteAny), MSZ_FORUM_POSTS_PER_PAGE, 'page');
|
2019-01-03 01:33:02 +01:00
|
|
|
|
2019-06-10 19:04:53 +02:00
|
|
|
if(isset($postInfo['preceeding_post_count'])) {
|
2019-04-30 22:55:12 +02:00
|
|
|
$preceedingPosts = $postInfo['preceeding_post_count'];
|
|
|
|
|
2019-06-10 19:04:53 +02:00
|
|
|
if($canDeleteAny) {
|
2019-04-30 22:55:12 +02:00
|
|
|
$preceedingPosts += $postInfo['preceeding_post_deleted_count'];
|
|
|
|
}
|
|
|
|
|
2019-12-06 02:04:10 +01:00
|
|
|
$topicPagination->setPage(floor($preceedingPosts / $topicPagination->getRange()), true);
|
2019-01-03 01:33:02 +01:00
|
|
|
}
|
|
|
|
|
2019-12-06 02:04:10 +01:00
|
|
|
if(!$topicPagination->hasValidOffset()) {
|
2019-01-03 01:33:02 +01:00
|
|
|
echo render_error(404);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-10-03 01:14:44 +00:00
|
|
|
$canReply = !$topicInfo->isArchived() && !$topicInfo->isLocked() && !$topicInfo->isDeleted() && perms_check($perms, MSZ_FORUM_PERM_CREATE_POST);
|
2018-12-28 06:03:42 +01:00
|
|
|
|
2020-10-03 01:14:44 +00:00
|
|
|
forum_topic_mark_read($topicUserId, $topicInfo->getId(), $topicInfo->getCategoryId());
|
2018-05-24 02:38:42 +02:00
|
|
|
|
2019-12-04 19:16:22 +01:00
|
|
|
Template::render('forum.topic', [
|
2020-10-03 01:14:44 +00:00
|
|
|
'topic_perms' => $perms,
|
|
|
|
'topic_breadcrumbs' => forum_get_breadcrumbs($topicInfo->getCategory()->getId()),
|
|
|
|
'topic_info' => $topicInfo,
|
2018-12-28 06:03:42 +01:00
|
|
|
'can_reply' => $canReply,
|
2019-01-03 01:33:02 +01:00
|
|
|
'topic_pagination' => $topicPagination,
|
2019-01-12 00:00:53 +01:00
|
|
|
'topic_can_delete' => $canDelete,
|
2020-10-03 01:14:44 +00:00
|
|
|
'topic_can_view_deleted' => $canDeleteAny,
|
2019-01-12 00:00:53 +01:00
|
|
|
'topic_can_nuke_or_restore' => $canNukeOrRestore,
|
|
|
|
'topic_can_bump' => $canBumpTopic,
|
|
|
|
'topic_can_lock' => $canLockTopic,
|
2018-05-20 22:12:45 +02:00
|
|
|
]);
|