From 967be382f6db9a7976fceab61339466e2a98b2ba Mon Sep 17 00:00:00 2001 From: flashwave Date: Wed, 8 May 2019 17:46:03 +0200 Subject: [PATCH] Added function to bump topic priority. --- public/forum/topic-priority.php | 9 +++++++++ src/Forum/topic.php | 21 +++++++++++++++++++++ src/url.php | 1 + templates/forum/macros.twig | 4 ++-- 4 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 public/forum/topic-priority.php diff --git a/public/forum/topic-priority.php b/public/forum/topic-priority.php new file mode 100644 index 00000000..97b3e536 --- /dev/null +++ b/public/forum/topic-priority.php @@ -0,0 +1,9 @@ + $topicId])); diff --git a/src/Forum/topic.php b/src/Forum/topic.php index b108f481..897d9be3 100644 --- a/src/Forum/topic.php +++ b/src/Forum/topic.php @@ -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(); +} diff --git a/src/url.php b/src/url.php index 801eef14..4d097cf0 100644 --- a/src/url.php +++ b/src/url.php @@ -53,6 +53,7 @@ define('MSZ_URLS', [ 'forum-topic-delete' => ['/forum/topic.php', ['t' => '', 'm' => 'delete', 'csrf[forum_post]' => '{forum_post}']], 'forum-topic-restore' => ['/forum/topic.php', ['t' => '', 'm' => 'restore', 'csrf[forum_post]' => '{forum_post}']], 'forum-topic-nuke' => ['/forum/topic.php', ['t' => '', 'm' => 'nuke', 'csrf[forum_post]' => '{forum_post}']], + 'forum-topic-priority' => ['/forum/topic-priority.php', ['t' => '', 'b' => '']], 'forum-post' => ['/forum/topic.php', ['p' => ''], ''], 'forum-post-create' => ['/forum/posting.php', ['t' => '']], 'forum-post-delete' => ['/forum/post.php', ['p' => '', 'm' => 'delete']], diff --git a/templates/forum/macros.twig b/templates/forum/macros.twig index afb2b0f0..fdb41f34 100644 --- a/templates/forum/macros.twig +++ b/templates/forum/macros.twig @@ -576,14 +576,14 @@
{% for vote in votes %}
- {% for i in 0..vote.topic_priority %} + {% for i in 1..vote.topic_priority %} {% endfor %}
{% endfor %}
- + Vote for this feature
{% endmacro %}