Version: 1.0.0, by Andreas
Developer Last Online: Jan 2023
Version: 3.5.0
Rating:
Released: 11-01-2005
Last Update: Never
Installs: 175
DB Changes Uses Plugins
No support by the author.
<font size="3">Auto Prune Threads</font>
Description
This hack gives you the ability to specify if you want to have
threads pruned from a forum after x days.
The amount of days can be set separately for each forum in forum manager.
Details
1 Product XML (3 Plugins, 1 Phrase)
Compatibility Note vBulletin 3.7
As of vBulletin 3.7 Beta 4, the hook used for this Mod does not exist any longer.
After installting this Mod, please change the Hook location to cron_script_cleanup_hourly
Show Your Support
This modification may not be copied, reproduced or published elsewhere without author's permission.
Does this physically remove the old threads from the database? Does the line of code that says "delete_thread($thread['threadid'], false, true, NULL, false, $thread);" use the built in vBulletin functions to remove the thread and posts?
Can someone help me find the "delete_thread" function?
Please confirm just what this script does...
Thanks!
EDIT:
OK, I think I figured out what this calls but it will take me some time to figure the code out.. I assume this is using the class_dm_threadpost.php file to handle the removal of the thread and that it will also remove the posts and that these removals are by removal or the rows of data from the database...
tried this hack - and nothing happened
Ok, read the small text in the forum manager again, and it says:
"will automatically prune all Threads from this Forum where the last reply is older then the set amount of days"
A-HA! So, if I have threads WITHOUT any replies they won't be deleted. Is that right?
How can the code be changed to enable the pruning of threads without replies older than x days??? Possible?
Does anyone know the function to move a thread? I rather have it move all the threads to a dedicated forum, then I can manually prune that single forum when my server is offline, since pruning is extremly CPU intensive when pruning thousands of threads.
Anyone willing to hold a n00bs hand? I would love to use this to delete all threads in one forum at midnight each night. I need explicit instructions though, not just a bunch of code. Tell me where to put it, copy this, paste here, change this....and I can fly with it. But just giving me code...I'm lost.
Yes - over night (once a day) seems like a better idea than runing an intensive script like this each hour. How please? Thanks.
- Disable or remove "Auto-Prune Threads" plugin in the plugin section
- Upload in your cron dir (includes/cron/) a php file (e.g. autoprune.php) with this code:
Code:
<?php
error_reporting(E_ALL & ~E_NOTICE);
if (!is_object($vbulletin->db))
{
exit;
}
require_once(DIR . '/includes/functions_databuild.php');
$forums = $vbulletin->db->query_read("SELECT forumid, pruneafter FROM " . TABLE_PREFIX . "forum WHERE pruneafter > 0");
while ($forum = $vbulletin->db->fetch_array($forums))
{
$threads = $vbulletin->db->query_read("SELECT threadid, forumid, visible, open, pollid, title FROM " . TABLE_PREFIX . "thread WHERE forumid=$forum[forumid] AND visible IN (0,1,2) AND sticky != 1 AND lastpost <= " . (TIMENOW - ($forum['pruneafter'] * 86400)));
while ($thread = $vbulletin->db->fetch_array($threads))
{
delete_thread($thread['threadid'], false, true, NULL, false, $thread);
}
build_forum_counters($forum['forumid']);
}
log_cron_action('Forums pruned', $nextitem);
?>
- Create a new cronjob that runs autoprune.php whenever you want