Addon 2x [OzzModz/Banxix] Bump Thread - Bump chủ đề cho XenForo 2 2.1.0

PVS

Super Moderator
Thành viên BQT
Tham gia
28/02/2015
Bài viết
16,728
Được Like
12,680
[OzzModz/Banxix] Bump Thread - Bump chủ đề cho XenForo 2 2.1.0

Cập nhật chủ đề để xuất hiện trong bài viết mới nhất mà không cần trả lời.

Tính năng:
  • Bật/Tắt addon.
  • Có thể bump chủ đề riêng
  • Có thể bump các chủ đề khác.
  • Giới hạn thời gian giữa các lần bump.
  • Tối đa số lần bump mỗi ngày.
  • Tùy chỉnh quyền cho mỗi node.
Truy vấn được thêm vào thread view: 1, với index.
Tác động hiệu suất: không đáng chú ý

bumpthreads1.pngbumpthreads2.pngbumpthreads3.png
Chúc các bạn thành công.


Nguồn: xenforo.com​
 

Đính kèm

  • Banxix-BumpThread-2.1.0.zip
    25.1 KB · Lượt xem: 33

sanhpv1

Corporal
Tham gia
15/07/2020
Bài viết
105
Được Like
2
Untitled.jpg


@PVS a ơi nếu chọn là start date thì sẽ không bump đc bài viết làm thế nào để khắc phục đây a , còn chọn Last message thì bump bình thường
 

hoangnhanpro

Private
Tham gia
16/03/2015
Bài viết
41
Được Like
41
Mấy cái addons bump thread này, theo mình nhớ nó sẽ thay đổi 2 tham số trong bài viết là:
1. last_post_date của bảng xf_thread
2. post_date của bài post cuối cùng của chủ đề nằm trong bảng xf_post
-> Để sắp xếp theo start date, theo mình bạn cần thay đổi thêm tham số post_date trong bản xf_theard.

Ví dụ:
PHP:
$db->query("
            UPDATE xf_thread
            SET post_date = ? , last_post_date = ?
            WHERE thread_id = ?
        ", [\XF::$time , \XF::$time, $thread->thread_id]);
 

sanhpv1

Corporal
Tham gia
15/07/2020
Bài viết
105
Được Like
2
Mấy cái addons bump thread này, theo mình nhớ nó sẽ thay đổi 2 tham số trong bài viết là:
1. last_post_date của bảng xf_thread
2. post_date của bài post cuối cùng của chủ đề nằm trong bảng xf_post
-> Để sắp xếp theo start date, theo mình bạn cần thay đổi thêm tham số post_date trong bản xf_theard.

Ví dụ:
PHP:
$db->query("
            UPDATE xf_thread
            SET post_date = ? , last_post_date = ?
            WHERE thread_id = ?
        ", [\XF::$time , \XF::$time, $thread->thread_id]);
pro cho hỏi đoạn code này thêm vào đâu ạ , sửa ở file nào vậy ạ
 

hoangnhanpro

Private
Tham gia
16/03/2015
Bài viết
41
Được Like
41
file Repository/BumpThread.php của addons đấy bồ.

thay đoạn code:
PHP:
        $db->query("
            UPDATE xf_thread
            SET last_post_date = ?
            WHERE thread_id = ?
        ", [\XF::$time, $thread->thread_id]);

thành đoạn mã trên.
Các thao tác chỉnh sửa Cơ sở dữ liệu nên làm cẩn thận nha. Tốt nhất nên thử test trên XAMPP trước cho chắc ăn. :))
 

sanhpv1

Corporal
Tham gia
15/07/2020
Bài viết
105
Được Like
2
file Repository/BumpThread.php của addons đấy bồ.

thay đoạn code:
PHP:
        $db->query("
            UPDATE xf_thread
            SET last_post_date = ?
            WHERE thread_id = ?
        ", [\XF::$time, $thread->thread_id]);

thành đoạn mã trên.
Các thao tác chỉnh sửa Cơ sở dữ liệu nên làm cẩn thận nha. Tốt nhất nên thử test trên XAMPP trước cho chắc ăn. :))

Mã:
<?php

namespace Banxix\BumpThread\Repository;

use XF\Mvc\Entity\Repository;
use Banxix\BumpThread\Entity\BumpLog;

class BumpThread extends Repository
{
    public function bump($thread)
    {
        $db = $this->db();

        $db->query("
            UPDATE xf_thread
            SET last_post_date = ?
            WHERE thread_id = ?
        ", [\XF::$time, $thread->thread_id]);

        $db->query("
            UPDATE xf_post
            SET post_date = ?
            WHERE post_id = ?
        ", [\XF::$time, $thread->last_post_id]);
    }

    public function log($threadId, $userId)
    {
        $this->db()->query("
            INSERT INTO xf_bump_thread_log
                (thread_id, user_id, bump_date)
            VALUES
                (?, ?, ?)
            ",
            [$threadId, $userId, \XF::$time]
        );
    }

    public function userLastBump($threadId, $userId)
    {
        return $this->db()->fetchOne("
            SELECT bump_date FROM xf_bump_thread_log
            WHERE thread_id = ? AND user_id = ?
            ORDER BY id DESC LIMIT 1
        ", [$threadId, $userId]);
    }

    public function userTodayBumpCount($userId)
    {
        return $this->db()->fetchOne("
            SELECT COUNT(*)
            FROM xf_bump_thread_log
            WHERE user_id = ?
            AND FROM_UNIXTIME(bump_date, '%Y-%m-%d') = ?
        ", [$userId, date('Y-m-d', \XF::$time)]);
    }

    public function bumpedThreadsInForum(\XF\Finder\Thread $finder)
    {
        $finder->sqlJoin("(
                SELECT thread_id, max(bump_date) as bump_date
                FROM xf_bump_thread_log
                GROUP BY thread_id
            )", 'bump_log', ['thread_id', 'bump_date'], false, true);

        $finder->sqlJoinConditions('bump_log', ['thread_id']);
    }

    public function hasNodePermission($user, $nodeId)
    {
        if (\XF::options()->bump_thread_reverse_time_limit)
        {
            $permissions = $this->fetchFloodRatePermissions(
                'XF:PermissionEntryContent', $user, 'node', $nodeId
            );

            if (empty($permissions))
            {
                $permissions = $this->fetchFloodRatePermissions('XF::PermissionEntry', $user);
            }

            return empty($permissions) ? 0 : max(min($permissions), 0);
        }
        else
        {
            return max($user->hasNodePermission($nodeId, 'bumpFloodRate'), 0);
        }
    }

    private function fetchFloodRatePermissions($name, $user, $contentType = null, $contentId = null)
    {
        $userGroups = array_merge($user->secondary_group_ids, [$user->user_group_id]);

        $finder = \XF::finder($name)
            ->where('permission_group_id', 'forum')
            ->where('permission_id', 'bumpFloodRate')
            ->whereOr([
                ['user_group_id', $userGroups],
                ['user_id', $user->user_id]
            ]);

        if ($contentType)
        {
            $finder->where('content_type', 'node');

            if ($contentId)
            {
                $finder->where('content_id', $contentId);
            }
        }

        $results = [];
        $permissions = $finder->fetchColumns('permission_value_int');

        foreach ($permissions as $permission)
        {
            $results[] = $permission['permission_value_int'];
        }

        return $results;
    }
}
đây là đoạn code trong bumpthread mong bạn sửa giúp mình với @hoangnhanpro
 

hoangnhanpro

Private
Tham gia
16/03/2015
Bài viết
41
Được Like
41
Screenshot_20201124-214227_Chrome.jpg

Bạn thay đoạn code khoanh tròn. Bằng đoạn code mình nói ở trên đầu là được.
 

sanhpv1

Corporal
Tham gia
15/07/2020
Bài viết
105
Được Like
2
View attachment 39184
Bạn thay đoạn code khoanh tròn. Bằng đoạn code mình nói ở trên đầu là được.
Mã:
   $db->query("
            UPDATE xf_thread
            SET last_post_date = ?
            WHERE thread_id = ?
        ", [\XF::$time, $thread->thread_id]);
đây là đoạn code của bạn , mình thay las post date , thành post_date thì đã bump đc , thanks bạn không biết như thế đúng chưa có lỗi gì k bạn nhỉ
 

susl16c

Gefreiter
Tham gia
19/05/2016
Bài viết
73
Được Like
23
Brother, you can download plugins from this source for free, but only 1 plugin per day, you need to find 10 different people so that you can download 10 plugins per day.
Resources | XenForo.pk
 

KHUCTHUYDU

MasterCorporal
Tham gia
24/06/2015
Bài viết
321
Được Like
225
Addon này cần chỉnh lại cùng lúc chỉ bump đc 1 thread thôi, chứ thời gian bump tính trên một người đâu có hay
 

Hướng dẫn sử dụng

XenForo 1 XenForo 2
Translate by PVS

Dịch vụ XenForo của VNXF

Mr. Tuấn

Mobile/Zalo: 0988 488 096

Telegram: bluekpro

Email: [email protected]

Nhà Tài Trợ

Mút Xốp Không Gian
pallet Thịnh Phát
Top Bottom