misuzu/public/forum/topic-priority.php

52 lines
1.2 KiB
PHP
Raw Normal View History

2019-05-08 15:46:03 +00:00
<?php
require_once '../../misuzu.php';
2019-06-10 17:04:53 +00:00
if(!MSZ_DEBUG) {
2019-05-09 15:55:06 +00:00
return;
}
2019-05-08 15:46:03 +00:00
$topicId = !empty($_GET['t']) && is_string($_GET['t']) ? (int)$_GET['t'] : 0;
2019-05-09 15:11:42 +00:00
$topicUserId = user_session_current('user_id', 0);
2019-05-08 15:46:03 +00:00
2019-06-10 17:04:53 +00:00
if($topicUserId < 1) {
2019-05-09 15:11:42 +00:00
echo render_error(403);
return;
}
$topic = forum_topic_get($topicId, true);
$perms = $topic
? forum_perms_get_user($topic['forum_id'], $topicUserId)[MSZ_FORUM_PERMS_GENERAL]
: 0;
2019-06-10 17:04:53 +00:00
if(user_warning_check_restriction($topicUserId)) {
2019-05-09 15:11:42 +00:00
$perms &= ~MSZ_FORUM_PERM_SET_WRITE;
}
$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)) {
2019-05-09 15:11:42 +00:00
echo render_error(404);
return;
}
2019-06-10 17:04:53 +00:00
if(!perms_check($perms, MSZ_FORUM_PERM_VIEW_FORUM, true) // | MSZ_FORUM_PERM_PRIORITY_VOTE
2019-05-09 15:11:42 +00:00
|| !$canDeleteAny
&& (
!empty($topic['topic_locked'])
|| !empty($topic['topic_archived'])
)
) {
echo render_error(403);
return;
}
2019-06-10 17:04:53 +00:00
if(!forum_has_priority_voting($topic['forum_type'])) {
2019-05-09 15:11:42 +00:00
echo render_error(400);
return;
}
forum_topic_priority_increase($topicId, user_session_current('user_id', 0));
2019-05-08 15:46:03 +00:00
url_redirect('forum-topic', ['topic' => $topicId]);