Added function to bump topic priority.
This commit is contained in:
parent
c133c7c7a3
commit
967be382f6
4 changed files with 33 additions and 2 deletions
9
public/forum/topic-priority.php
Normal file
9
public/forum/topic-priority.php
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
require_once '../../misuzu.php';
|
||||
|
||||
$topicId = !empty($_GET['t']) && is_string($_GET['t']) ? (int)$_GET['t'] : 0;
|
||||
$bump = !empty($_GET['b']) && is_string($_GET['b']) ? (int)$_GET['b'] : 1;
|
||||
|
||||
forum_topic_priority_increase($topicId, user_session_current('user_id', 0), $bump);
|
||||
|
||||
header('Location: ' . url('forum-topic', ['topic' => $topicId]));
|
|
@ -689,3 +689,24 @@ function forum_topic_priority(int $topic): array
|
|||
|
||||
return db_fetch_all($getPriority);
|
||||
}
|
||||
|
||||
function forum_topic_priority_increase(int $topic, int $user, int $bump = 1): void
|
||||
{
|
||||
if($topic < 1 || $user < 1 || $bump === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
$bumpPriority = db_prepare('
|
||||
INSERT INTO `msz_forum_topics_priority`
|
||||
(`topic_id`, `user_id`, `topic_priority`)
|
||||
VALUES
|
||||
(:topic, :user, :bump1)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
`topic_priority` = `topic_priority` + :bump2
|
||||
');
|
||||
$bumpPriority->bindValue('topic', $topic);
|
||||
$bumpPriority->bindValue('user', $user);
|
||||
$bumpPriority->bindValue('bump1', $bump);
|
||||
$bumpPriority->bindValue('bump2', $bump);
|
||||
$bumpPriority->execute();
|
||||
}
|
||||
|
|
|
@ -53,6 +53,7 @@ define('MSZ_URLS', [
|
|||
'forum-topic-delete' => ['/forum/topic.php', ['t' => '<topic>', 'm' => 'delete', 'csrf[forum_post]' => '{forum_post}']],
|
||||
'forum-topic-restore' => ['/forum/topic.php', ['t' => '<topic>', 'm' => 'restore', 'csrf[forum_post]' => '{forum_post}']],
|
||||
'forum-topic-nuke' => ['/forum/topic.php', ['t' => '<topic>', 'm' => 'nuke', 'csrf[forum_post]' => '{forum_post}']],
|
||||
'forum-topic-priority' => ['/forum/topic-priority.php', ['t' => '<topic>', 'b' => '<bump>']],
|
||||
'forum-post' => ['/forum/topic.php', ['p' => '<post>'], '<post_fragment>'],
|
||||
'forum-post-create' => ['/forum/posting.php', ['t' => '<topic>']],
|
||||
'forum-post-delete' => ['/forum/post.php', ['p' => '<post>', 'm' => 'delete']],
|
||||
|
|
|
@ -576,14 +576,14 @@
|
|||
<div class="forum__priority__votes">
|
||||
{% for vote in votes %}
|
||||
<div title="{{ vote.username }} ({{ vote.topic_priority|number_format }})" class="forum__priority__vote" style="{{ vote.user_colour|html_colour }}">
|
||||
{% for i in 0..vote.topic_priority %}
|
||||
{% for i in 1..vote.topic_priority %}
|
||||
<span class="forum__priority__star fas fa-star fa-fw"></span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="forum__priority__input">
|
||||
<button class="input__button">Vote for this feature</button>
|
||||
<a class="input__button" href="{{ url('forum-topic-priority', {'topic':topic.topic_id}) }}">Vote for this feature</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
|
Loading…
Add table
Reference in a new issue