MyBB Community Forums

Full Version: Close old threads
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Currently having an issue where users are bringing back posts from several months, and even over a year.

I would like that all topics would automatically lock after x amount of months. I know about several plugins that do this, but they all are from 1.6 and lower and do not work on 1.8.
(2015-03-20, 11:01 PM)Supryk Wrote: [ -> ]http://mods.mybb.com/view/lockoldthreads

That is for 1.6 he would have to edit and modify it to work for 1.8 I believe. Not sure if you can just edit the compatibility or not in the php file, but he can try that I suppose.
Although it'd be extremely tedious, until someone releases a plugin that allows you to do this, I'd put it into an Archive section, and just lock it. If you don't want anyone to see it, just make it unviewable to other users.
Unfortunately my forum has way to many threads to manually archive each post, and it would be difficult to track the old threads because they would get buried by new ones.

Also the plugin above does not work on 1.8
You'll have to manually create the task.  You will need to edit the settings to be how you like.
Instead of moving the thread to archive section, is it possible to just lock them?
In the /inc/tasks/oldpost.php file find:
    if($mybb->settings['oldpost_days'])
    {
        $cutoff = TIME_NOW - ( 86400 * intval($mybb->settings['oldpost_days']) );
        $cutoffsql = " AND lastpost < $cutoff ";
    }
    else
    {
        return;
    }

After that put this:
$db->write_query("UPDATE " . TABLE_PREFIX . "threads SET closed=1 WHERE lastpost < $cutoff");
return;

That is assuming you are having it active in all forums.
... sorry ....
(2015-03-21, 12:46 PM)dragonexpert Wrote: [ -> ]You'll have to manually create the task.  You will need to edit the settings to be how you like.

Thanks for providing this as a starting point. One notable edit I made was with regard to updating "last post" after moving/archiving old threads:

Find:
$query = $db->simple_select("threads", "tid, uid, subject, username, dateline", "fid=$fid AND visible=1", array("order_by" => "dateline", "order_dir" => "DESC", "limit" => 1));
Replace:
$query = $db->simple_select("threads", "tid, uid, subject, username, lastpost", "fid=$fid AND visible=1", array("order_by" => "lastpost", "order_dir" => "DESC", "limit" => 1));
Find:
"lastpost" => $lastpost['dateline'],
Replace:
"lastpost" => $lastpost['lastpost'],

"dateline" is the timestamp of the first post of the thread, but obviously we don't want the first post, but the last post.
Pages: 1 2