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

PVS

Generalissimo
Thành viên BQT
[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: 30

sanhpv1

Corporal
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
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
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
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
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
 

sanhpv1

Corporal
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ỉ
 

KHUCTHUYDU

MasterCorporal
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

Hỗ trợ trực tuyến

Support Quảng cáo
Mr. San (PVS)

Skype chat, instant message

Mr. Tuấn (Blue)

Skype chat, instant message

Mr. Tuấn
0988 488 096
Mr. Trọng
0906 081 284
kinhdoanh@vnxf.vn

Nhà Tài Trợ

Mút Xốp Không Gian
pallet Thịnh Phát
Điện Lạnh Thịnh Phát
Top