1 (edited by Runar 2007-01-12 23:08)

Topic: Hide threads older than X days

A function which makes it possible to hide threads older than X days from a forum I decide, is something I would find very useful.
Like when a thread is 2 days old, normal members can no longer view it. It's not displayed in the forum anymore.

Is this possible? And if yes, how hard? And can it be done before the 1.3 version comes out?


Runar

2

Re: Hide threads older than X days

i dont know about hiding them........but i believe that punbb has a function to prune topics/posts older than a certain date set.

3

Re: Hide threads older than X days

I want them to still be readable for moderators and administrators, just not members smile

Re: Hide threads older than X days

Give this a shot? (You'll still see page number links.)


Open: viewtopic.php

Find:

// Fetch some info about the topic
if (!$pun_user['is_guest'])
    $result = $db->query('SELECT t.subject, t.closed, t.num_replies, t.sticky, f.id AS forum_id, f.forum_name, f.moderators, fp.post_replies, s.user_id AS is_subscribed FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'subscriptions AS s ON (t.id=s.topic_id AND s.user_id='.$pun_user['id'].') LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.id='.$id.' AND t.moved_to IS NULL') or error('Unable to fetch topic info', __FILE__, __LINE__, $db->error());
else
    $result = $db->query('SELECT t.subject, t.closed, t.num_replies, t.sticky, f.id AS forum_id, f.forum_name, f.moderators, fp.post_replies, 0 FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.id='.$id.' AND t.moved_to IS NULL') or error('Unable to fetch topic info', __FILE__, __LINE__, $db->error());

Replace with:

// Fetch some info about the topic
// mod: Hide posts after X days
if (!$pun_user['is_guest'])
    $result = $db->query('SELECT t.subject, t.closed, t.num_replies, t.sticky, t.posted, f.id AS forum_id, f.forum_name, f.moderators, fp.post_replies, s.user_id AS is_subscribed FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'subscriptions AS s ON (t.id=s.topic_id AND s.user_id='.$pun_user['id'].') LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.id='.$id.' AND t.moved_to IS NULL') or error('Unable to fetch topic info', __FILE__, __LINE__, $db->error());
else
    $result = $db->query('SELECT t.subject, t.closed, t.num_replies, t.sticky, t.posted, f.id AS forum_id, f.forum_name, f.moderators, fp.post_replies, 0 FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.id='.$id.' AND t.moved_to IS NULL') or error('Unable to fetch topic info', __FILE__, __LINE__, $db->error());

Find:

// Can we or can we not post replies?

Before, add:

// mod: Hide posts after X days
// Default: 172800 seconds (2 days)
if (!$is_admmod && time() > ($cur_topic['posted'] + 172800))
    message($lang_common['Bad request']);

Open: viewforum.php

Find:

    while ($cur_topic = $db->fetch_assoc($result))
    {

Replace with:

    while ($cur_topic = $db->fetch_assoc($result))
    {
        // mod: Hide posts after X days
        // Default: 172800 seconds (2 days)
        if (!$is_admmod && time() > ($cur_topic['posted'] + 172800))
            continue;

Find:

}
else
{

?>
                <tr>

Replace with:

}

// mod: Hide posts after X days
// No topics exist or they are too old to view
if (!isset($item_status))
{

?>
                <tr>

5

Re: Hide threads older than X days

Thank you! It works perfect smile

Except that the last post is still shown on the index page, but that doesn't matter. They are still there, just hidden .