2018-05-18 01:20:27 +00:00
|
|
|
<?php
|
2019-09-28 22:43:51 +00:00
|
|
|
namespace Misuzu;
|
|
|
|
|
2018-10-04 20:30:55 +00:00
|
|
|
require_once '../../misuzu.php';
|
2018-05-18 01:20:27 +00:00
|
|
|
|
2019-03-18 22:02:30 +00:00
|
|
|
$postId = !empty($_GET['p']) && is_string($_GET['p']) ? (int)$_GET['p'] : 0;
|
|
|
|
$topicId = !empty($_GET['t']) && is_string($_GET['t']) ? (int)$_GET['t'] : 0;
|
|
|
|
$moderationMode = !empty($_GET['m']) && is_string($_GET['m']) ? (string)$_GET['m'] : '';
|
|
|
|
$submissionConfirmed = !empty($_GET['confirm']) && is_string($_GET['confirm']) && $_GET['confirm'] === '1';
|
2018-05-20 20:12:45 +00:00
|
|
|
|
2019-01-05 17:21:48 +00:00
|
|
|
$topicUserId = user_session_current('user_id', 0);
|
|
|
|
|
2019-06-10 17:04:53 +00:00
|
|
|
if($topicId < 1 && $postId > 0) {
|
2019-01-05 17:21:48 +00:00
|
|
|
$postInfo = forum_post_find($postId, $topicUserId);
|
2018-05-21 23:05:25 +00:00
|
|
|
|
2019-06-10 17:04:53 +00:00
|
|
|
if(!empty($postInfo['topic_id'])) {
|
2019-01-04 00:11:31 +00:00
|
|
|
$topicId = (int)$postInfo['topic_id'];
|
2018-05-21 23:05:25 +00:00
|
|
|
}
|
2018-05-20 20:12:45 +00:00
|
|
|
}
|
|
|
|
|
2019-01-11 23:00:53 +00:00
|
|
|
$topic = forum_topic_get($topicId, true);
|
2018-12-22 11:02:26 +00:00
|
|
|
$perms = $topic
|
2019-04-30 20:55:12 +00:00
|
|
|
? forum_perms_get_user($topic['forum_id'], $topicUserId)[MSZ_FORUM_PERMS_GENERAL]
|
2018-12-22 11:02:26 +00:00
|
|
|
: 0;
|
2018-05-20 20:12:45 +00:00
|
|
|
|
2019-06-10 17:04:53 +00:00
|
|
|
if(user_warning_check_restriction($topicUserId)) {
|
2018-12-28 05:03:42 +00:00
|
|
|
$perms &= ~MSZ_FORUM_PERM_SET_WRITE;
|
|
|
|
}
|
|
|
|
|
2019-01-11 23:00:53 +00:00
|
|
|
$topicIsDeleted = !empty($topic['topic_deleted']);
|
|
|
|
$canDeleteAny = perms_check($perms, MSZ_FORUM_PERM_DELETE_ANY_POST);
|
|
|
|
|
2019-06-10 17:04:53 +00:00
|
|
|
if(!$topic || ($topicIsDeleted && !$canDeleteAny)) {
|
2018-05-26 20:33:05 +00:00
|
|
|
echo render_error(404);
|
2018-05-20 20:12:45 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-06-10 17:04:53 +00:00
|
|
|
if(!perms_check($perms, MSZ_FORUM_PERM_VIEW_FORUM)) {
|
2018-08-23 20:06:48 +00:00
|
|
|
echo render_error(403);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-06-10 17:04:53 +00:00
|
|
|
if(!empty($topic['poll_id'])) {
|
2019-05-02 21:36:57 +00:00
|
|
|
$pollOptions = forum_poll_get_options($topic['poll_id']);
|
|
|
|
$pollUserAnswers = forum_poll_get_user_answers($topic['poll_id'], $topicUserId);
|
2019-04-17 23:59:33 +00:00
|
|
|
}
|
|
|
|
|
2019-06-10 17:04:53 +00:00
|
|
|
if(forum_has_priority_voting($topic['forum_type'])) {
|
2019-05-07 17:16:08 +00:00
|
|
|
$topicPriority = forum_topic_priority($topic['topic_id']);
|
|
|
|
}
|
|
|
|
|
2019-01-11 23:00:53 +00:00
|
|
|
$topicIsLocked = !empty($topic['topic_locked']);
|
|
|
|
$topicIsArchived = !empty($topic['topic_archived']);
|
2019-03-03 15:26:23 +00:00
|
|
|
$topicPostsTotal = (int)($topic['topic_count_posts'] + $topic['topic_count_posts_deleted']);
|
2019-01-11 23:00:53 +00:00
|
|
|
$topicIsFrozen = $topicIsArchived || $topicIsDeleted;
|
|
|
|
$canDeleteOwn = !$topicIsFrozen && !$topicIsLocked && perms_check($perms, MSZ_FORUM_PERM_DELETE_POST);
|
|
|
|
$canBumpTopic = !$topicIsFrozen && perms_check($perms, MSZ_FORUM_PERM_BUMP_TOPIC);
|
|
|
|
$canLockTopic = !$topicIsFrozen && perms_check($perms, MSZ_FORUM_PERM_LOCK_TOPIC);
|
|
|
|
$canNukeOrRestore = $canDeleteAny && $topicIsDeleted;
|
|
|
|
$canDelete = !$topicIsDeleted && (
|
|
|
|
$canDeleteAny || (
|
|
|
|
$topicPostsTotal > 0
|
|
|
|
&& $topicPostsTotal <= MSZ_FORUM_TOPIC_DELETE_POST_LIMIT
|
|
|
|
&& $canDeleteOwn
|
|
|
|
&& $topic['author_user_id'] === $topicUserId
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
$validModerationModes = [
|
|
|
|
'delete', 'restore', 'nuke',
|
|
|
|
'bump', 'lock', 'unlock',
|
|
|
|
];
|
|
|
|
|
2019-06-10 15:21:53 +00:00
|
|
|
if(in_array($moderationMode, $validModerationModes, true)) {
|
2019-01-11 23:00:53 +00:00
|
|
|
$redirect = !empty($_SERVER['HTTP_REFERER']) && empty($_SERVER['HTTP_X_MISUZU_XHR']) ? $_SERVER['HTTP_REFERER'] : '';
|
|
|
|
$isXHR = !$redirect;
|
|
|
|
|
2019-06-10 15:21:53 +00:00
|
|
|
if($isXHR) {
|
2019-01-11 23:00:53 +00:00
|
|
|
header('Content-Type: application/json; charset=utf-8');
|
2019-06-10 15:21:53 +00:00
|
|
|
} elseif(!is_local_url($redirect)) {
|
2019-01-11 23:00:53 +00:00
|
|
|
echo render_info('Possible request forgery detected.', 403);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-06-10 15:21:53 +00:00
|
|
|
if(!csrf_verify_request()) {
|
2019-01-11 23:00:53 +00:00
|
|
|
echo render_info_or_json($isXHR, "Couldn't verify this request, please refresh the page and try again.", 403);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-06-10 15:21:53 +00:00
|
|
|
csrf_http_header();
|
2019-01-11 23:00:53 +00:00
|
|
|
|
2019-06-10 15:21:53 +00:00
|
|
|
if(!user_session_active()) {
|
2019-01-11 23:00:53 +00:00
|
|
|
echo render_info_or_json($isXHR, 'You must be logged in to manage posts.', 401);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-06-10 15:21:53 +00:00
|
|
|
if(user_warning_check_expiration($topicUserId, MSZ_WARN_BAN) > 0) {
|
2019-01-11 23:00:53 +00:00
|
|
|
echo render_info_or_json($isXHR, 'You have been banned, check your profile for more information.', 403);
|
|
|
|
return;
|
|
|
|
}
|
2019-06-10 15:21:53 +00:00
|
|
|
if(user_warning_check_expiration($topicUserId, MSZ_WARN_SILENCE) > 0) {
|
2019-01-11 23:00:53 +00:00
|
|
|
echo render_info_or_json($isXHR, 'You have been silenced, check your profile for more information.', 403);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-06-10 17:04:53 +00:00
|
|
|
switch($moderationMode) {
|
2019-01-11 23:00:53 +00:00
|
|
|
case 'delete':
|
|
|
|
$canDeleteCode = forum_topic_can_delete($topic, $topicUserId);
|
|
|
|
$canDeleteMsg = '';
|
|
|
|
$responseCode = 200;
|
|
|
|
|
2019-06-10 17:04:53 +00:00
|
|
|
switch($canDeleteCode) {
|
2019-01-11 23:00:53 +00: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 17:04:53 +00:00
|
|
|
if($canDeleteCode !== MSZ_E_FORUM_TOPIC_DELETE_OK) {
|
|
|
|
if($isXHR) {
|
2019-01-11 23:00:53 +00:00
|
|
|
http_response_code($responseCode);
|
|
|
|
echo json_encode([
|
|
|
|
'success' => false,
|
|
|
|
'topic_id' => $topic['topic_id'],
|
|
|
|
'code' => $canDeleteCode,
|
|
|
|
'message' => $canDeleteMsg,
|
|
|
|
]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
echo render_info($canDeleteMsg, $responseCode);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-06-10 17:04:53 +00:00
|
|
|
if(!$isXHR) {
|
|
|
|
if(!isset($_GET['confirm'])) {
|
2019-01-11 23:00:53 +00:00
|
|
|
echo tpl_render('forum.confirm', [
|
|
|
|
'title' => 'Confirm topic deletion',
|
|
|
|
'class' => 'far fa-trash-alt',
|
|
|
|
'message' => sprintf('You are about to delete topic #%d. Are you sure about that?', $topic['topic_id']),
|
|
|
|
'params' => [
|
|
|
|
't' => $topic['topic_id'],
|
|
|
|
'm' => 'delete',
|
|
|
|
],
|
|
|
|
]);
|
|
|
|
break;
|
2019-06-10 17:04:53 +00:00
|
|
|
} elseif(!$submissionConfirmed) {
|
2019-06-08 21:46:24 +00:00
|
|
|
url_redirect(
|
2019-06-01 22:44:01 +00:00
|
|
|
'forum-topic',
|
|
|
|
['topic' => $topic['topic_id']]
|
2019-06-08 21:46:24 +00:00
|
|
|
);
|
2019-06-01 22:44:01 +00:00
|
|
|
break;
|
2019-01-11 23:00:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$deleteTopic = forum_topic_delete($topic['topic_id']);
|
|
|
|
|
2019-06-10 17:04:53 +00:00
|
|
|
if($deleteTopic) {
|
2019-01-22 14:24:30 +00:00
|
|
|
audit_log(MSZ_AUDIT_FORUM_TOPIC_DELETE, $topicUserId, [$topic['topic_id']]);
|
|
|
|
}
|
|
|
|
|
2019-06-10 17:04:53 +00:00
|
|
|
if($isXHR) {
|
2019-01-11 23:00:53 +00:00
|
|
|
echo json_encode([
|
|
|
|
'success' => $deleteTopic,
|
|
|
|
'topic_id' => $topic['topic_id'],
|
|
|
|
'message' => $deleteTopic ? 'Topic deleted!' : 'Failed to delete topic.',
|
|
|
|
]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-06-10 17:04:53 +00:00
|
|
|
if(!$deleteTopic) {
|
2019-01-11 23:00:53 +00:00
|
|
|
echo render_error(500);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-06-08 21:46:24 +00:00
|
|
|
url_redirect('forum-category', [
|
2019-01-24 20:54:24 +00:00
|
|
|
'forum' => $topic['forum_id'],
|
2019-06-08 21:46:24 +00:00
|
|
|
]);
|
2019-01-11 23:00:53 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'restore':
|
2019-06-10 17:04:53 +00:00
|
|
|
if(!$canNukeOrRestore) {
|
2019-01-11 23:00:53 +00:00
|
|
|
echo render_error(403);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-06-10 17:04:53 +00:00
|
|
|
if(!$isXHR) {
|
|
|
|
if(!isset($_GET['confirm'])) {
|
2019-01-11 23:00:53 +00:00
|
|
|
echo tpl_render('forum.confirm', [
|
|
|
|
'title' => 'Confirm topic restore',
|
|
|
|
'class' => 'fas fa-magic',
|
|
|
|
'message' => sprintf('You are about to restore topic #%d. Are you sure about that?', $topic['topic_id']),
|
|
|
|
'params' => [
|
|
|
|
't' => $topic['topic_id'],
|
|
|
|
'm' => 'restore',
|
|
|
|
],
|
|
|
|
]);
|
|
|
|
break;
|
2019-06-10 17:04:53 +00:00
|
|
|
} elseif(!$submissionConfirmed) {
|
2019-06-08 21:46:24 +00:00
|
|
|
url_redirect('forum-topic', [
|
2019-06-01 22:44:01 +00:00
|
|
|
'topic' => $topic['topic_id'],
|
2019-06-08 21:46:24 +00:00
|
|
|
]);
|
2019-06-01 22:44:01 +00:00
|
|
|
break;
|
2019-01-11 23:00:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$restoreTopic = forum_topic_restore($topic['topic_id']);
|
|
|
|
|
2019-06-10 17:04:53 +00:00
|
|
|
if(!$restoreTopic) {
|
2019-01-11 23:00:53 +00:00
|
|
|
echo render_error(500);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-01-22 14:24:30 +00:00
|
|
|
audit_log(MSZ_AUDIT_FORUM_TOPIC_RESTORE, $topicUserId, [$topic['topic_id']]);
|
2019-01-11 23:00:53 +00:00
|
|
|
http_response_code(204);
|
|
|
|
|
2019-06-10 17:04:53 +00:00
|
|
|
if(!$isXHR) {
|
2019-06-08 21:46:24 +00:00
|
|
|
url_redirect('forum-category', [
|
2019-01-24 20:54:24 +00:00
|
|
|
'forum' => $topic['forum_id'],
|
2019-06-08 21:46:24 +00:00
|
|
|
]);
|
2019-01-11 23:00:53 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'nuke':
|
2019-06-10 17:04:53 +00:00
|
|
|
if(!$canNukeOrRestore) {
|
2019-01-11 23:00:53 +00:00
|
|
|
echo render_error(403);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-06-10 17:04:53 +00:00
|
|
|
if(!$isXHR) {
|
|
|
|
if(!isset($_GET['confirm'])) {
|
2019-01-11 23:00:53 +00:00
|
|
|
echo tpl_render('forum.confirm', [
|
|
|
|
'title' => 'Confirm topic nuke',
|
|
|
|
'class' => 'fas fa-radiation',
|
|
|
|
'message' => sprintf('You are about to PERMANENTLY DELETE topic #%d. Are you sure about that?', $topic['topic_id']),
|
|
|
|
'params' => [
|
|
|
|
't' => $topic['topic_id'],
|
|
|
|
'm' => 'nuke',
|
|
|
|
],
|
|
|
|
]);
|
|
|
|
break;
|
2019-06-10 17:04:53 +00:00
|
|
|
} elseif(!$submissionConfirmed) {
|
2019-06-08 21:46:24 +00:00
|
|
|
url_redirect('forum-topic', [
|
2019-06-01 22:44:01 +00:00
|
|
|
'topic' => $topic['topic_id'],
|
2019-06-08 21:46:24 +00:00
|
|
|
]);
|
2019-06-01 22:44:01 +00:00
|
|
|
break;
|
2019-01-11 23:00:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$nukeTopic = forum_topic_nuke($topic['topic_id']);
|
|
|
|
|
2019-06-10 17:04:53 +00:00
|
|
|
if(!$nukeTopic) {
|
2019-01-11 23:00:53 +00:00
|
|
|
echo render_error(500);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-01-22 14:24:30 +00:00
|
|
|
audit_log(MSZ_AUDIT_FORUM_TOPIC_NUKE, $topicUserId, [$topic['topic_id']]);
|
2019-01-11 23:00:53 +00:00
|
|
|
http_response_code(204);
|
|
|
|
|
2019-06-10 17:04:53 +00:00
|
|
|
if(!$isXHR) {
|
2019-06-08 21:46:24 +00:00
|
|
|
url_redirect('forum-category', [
|
2019-01-24 20:54:24 +00:00
|
|
|
'forum' => $topic['forum_id'],
|
2019-06-08 21:46:24 +00:00
|
|
|
]);
|
2019-01-11 23:00:53 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'bump':
|
2019-06-10 17:04:53 +00:00
|
|
|
if($canBumpTopic && forum_topic_bump($topic['topic_id'])) {
|
2019-01-22 14:24:30 +00:00
|
|
|
audit_log(MSZ_AUDIT_FORUM_TOPIC_BUMP, $topicUserId, [$topic['topic_id']]);
|
2019-01-11 23:00:53 +00:00
|
|
|
}
|
|
|
|
|
2019-06-08 21:46:24 +00:00
|
|
|
url_redirect('forum-topic', [
|
2019-01-24 20:54:24 +00:00
|
|
|
'topic' => $topic['topic_id'],
|
2019-06-08 21:46:24 +00:00
|
|
|
]);
|
2019-01-11 23:00:53 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'lock':
|
2019-06-10 17:04:53 +00:00
|
|
|
if($canLockTopic && !$topicIsLocked && forum_topic_lock($topic['topic_id'])) {
|
2019-01-22 14:24:30 +00:00
|
|
|
audit_log(MSZ_AUDIT_FORUM_TOPIC_LOCK, $topicUserId, [$topic['topic_id']]);
|
2019-01-11 23:00:53 +00:00
|
|
|
}
|
|
|
|
|
2019-06-08 21:46:24 +00:00
|
|
|
url_redirect('forum-topic', [
|
2019-01-24 20:54:24 +00:00
|
|
|
'topic' => $topic['topic_id'],
|
2019-06-08 21:46:24 +00:00
|
|
|
]);
|
2019-01-11 23:00:53 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'unlock':
|
2019-06-10 17:04:53 +00:00
|
|
|
if($canLockTopic && $topicIsLocked && forum_topic_unlock($topic['topic_id'])) {
|
2019-01-22 14:24:30 +00:00
|
|
|
audit_log(MSZ_AUDIT_FORUM_TOPIC_UNLOCK, $topicUserId, [$topic['topic_id']]);
|
2019-01-11 23:00:53 +00:00
|
|
|
}
|
|
|
|
|
2019-06-08 21:46:24 +00:00
|
|
|
url_redirect('forum-topic', [
|
2019-01-24 20:54:24 +00:00
|
|
|
'topic' => $topic['topic_id'],
|
2019-06-08 21:46:24 +00:00
|
|
|
]);
|
2019-01-11 23:00:53 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-03-03 15:26:23 +00:00
|
|
|
$topicPosts = $topic['topic_count_posts'];
|
2019-01-11 23:00:53 +00:00
|
|
|
|
2019-06-10 17:04:53 +00:00
|
|
|
if($canDeleteAny) {
|
2019-03-03 15:26:23 +00:00
|
|
|
$topicPosts += $topic['topic_count_posts_deleted'];
|
2019-01-11 23:00:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$topicPagination = pagination_create($topicPosts, MSZ_FORUM_POSTS_PER_PAGE);
|
2019-01-03 00:33:02 +00:00
|
|
|
|
2019-06-10 17:04:53 +00:00
|
|
|
if(isset($postInfo['preceeding_post_count'])) {
|
2019-04-30 20:55:12 +00:00
|
|
|
$preceedingPosts = $postInfo['preceeding_post_count'];
|
|
|
|
|
2019-06-10 17:04:53 +00:00
|
|
|
if($canDeleteAny) {
|
2019-04-30 20:55:12 +00:00
|
|
|
$preceedingPosts += $postInfo['preceeding_post_deleted_count'];
|
|
|
|
}
|
|
|
|
|
|
|
|
$postsPage = floor($preceedingPosts / $topicPagination['range']) + 1;
|
2019-01-03 00:33:02 +00:00
|
|
|
}
|
|
|
|
|
2019-01-04 00:11:31 +00:00
|
|
|
$postsOffset = pagination_offset($topicPagination, $postsPage ?? pagination_param('page'));
|
2019-01-03 00:33:02 +00:00
|
|
|
|
2019-06-10 17:04:53 +00:00
|
|
|
if(!pagination_is_valid_offset($postsOffset)) {
|
2019-01-03 00:33:02 +00:00
|
|
|
echo render_error(404);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-10-25 00:15:23 +00:00
|
|
|
tpl_var('topic_perms', $perms);
|
|
|
|
|
2018-12-22 11:02:26 +00:00
|
|
|
$posts = forum_post_listing(
|
|
|
|
$topic['topic_id'],
|
|
|
|
$postsOffset,
|
2019-01-03 00:33:02 +00:00
|
|
|
$topicPagination['range'],
|
2018-12-22 11:02:26 +00:00
|
|
|
perms_check($perms, MSZ_FORUM_PERM_DELETE_ANY_POST)
|
|
|
|
);
|
2018-05-20 20:12:45 +00:00
|
|
|
|
2019-06-10 17:04:53 +00:00
|
|
|
if(!$posts) {
|
2018-05-26 20:33:05 +00:00
|
|
|
echo render_error(404);
|
2018-05-21 23:05:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-01-11 23:00:53 +00:00
|
|
|
$canReply = !$topicIsArchived && !$topicIsLocked && !$topicIsDeleted && perms_check($perms, MSZ_FORUM_PERM_CREATE_POST);
|
2018-12-28 05:03:42 +00:00
|
|
|
|
2019-01-05 17:21:48 +00:00
|
|
|
forum_topic_mark_read($topicUserId, $topic['topic_id'], $topic['forum_id']);
|
2018-05-24 00:38:42 +00:00
|
|
|
|
2018-08-15 01:12:58 +00:00
|
|
|
echo tpl_render('forum.topic', [
|
2018-05-23 01:41:57 +00:00
|
|
|
'topic_breadcrumbs' => forum_get_breadcrumbs($topic['forum_id']),
|
2018-10-21 22:11:14 +00:00
|
|
|
'global_accent_colour' => forum_get_colour($topic['forum_id']),
|
2018-05-20 20:12:45 +00:00
|
|
|
'topic_info' => $topic,
|
|
|
|
'topic_posts' => $posts,
|
2018-12-28 05:03:42 +00:00
|
|
|
'can_reply' => $canReply,
|
2019-01-03 00:33:02 +00:00
|
|
|
'topic_pagination' => $topicPagination,
|
2019-01-11 23:00:53 +00:00
|
|
|
'topic_can_delete' => $canDelete,
|
|
|
|
'topic_can_nuke_or_restore' => $canNukeOrRestore,
|
|
|
|
'topic_can_bump' => $canBumpTopic,
|
|
|
|
'topic_can_lock' => $canLockTopic,
|
2019-04-17 23:59:33 +00:00
|
|
|
'topic_poll_options' => $pollOptions ?? [],
|
2019-05-02 21:36:57 +00:00
|
|
|
'topic_poll_user_answers' => $pollUserAnswers ?? [],
|
2019-05-07 19:43:54 +00:00
|
|
|
'topic_priority_votes' => $topicPriority ?? [],
|
2018-05-20 20:12:45 +00:00
|
|
|
]);
|