Create a plugin hooked at "cron_script_cleanup_daily" with the code:
PHP Code:
global $vbulletin, $db;
require_once(DIR . '/includes/functions_databuild.php');
$deleted = false;
$curtime = TIMENOW;
$physicaldel = false;
$del_user = $fetch_userinfo(1);
$delinfo = array(
'userid' => $del_user['userid'],
'username' => $del_user['username'],
'reason' => 'Thread auto-deleted via cron.',
'keepattachments' => true
);
$countposts = $vbulletin->forumcache[88]['options'] & $vbulletin->bf_misc_forumoptions['countposts'];
$query = "SELECT thread.* FROM " . TABLE_PREFIX . "thread AS thread WHERE lastpost <= " . $curtime - 365*86400 . " AND forumid = 88";
$threads_delete = $vbulletin->db->query_read($query);
$mthread =& datamanager_init('Thread', $vbulletin, ERRTYPE_SILENT, 'threadpost');
while ($thread_delete = $vbulletin->db->fetch_array($threads_delete))
{
if (!$deleted)
{
$deleted = true;
}
$mthread->set_existing($thread_delete);
$mthread->delete($countposts, $physicaldel, $delinfo, false);
}
unset($mthread);
if ($deleted)
{
build_forum_counters(88);
}
$vbulletin->db->query_write("
UPDATE " . TABLE_PREFIX . "thread
SET forumid = 12
WHERE forumid = 10
AND lastpost <= " . $curtime - 100*86400 . "
AND prefixid = 'done'
");
build_forum_counters(10);
build_forum_counters(12);
Note: I have not tested this code. Please test this first on your test installation, and then make a backup of your database before running this code the first time on your live site.
I cannot emphasize enough how important this is!
As the code is written, the thread deletion is soft-delete. To use a hard-delete, change the line:
PHP Code:
$physicaldel = false;
to:
PHP Code:
$physicaldel = true;