vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   automating thread moves between forums (https://vborg.vbsupport.ru/showthread.php?t=92542)

jsharper 07-20-2005 05:01 AM

automating thread moves between forums
 
I need to create some sort of scheduled task or cron job to move all of the threads from one forum to another forum on a daily basis... any suggestions on the best way to approach it? custom sql queries? custom php code that uses vB functions?

vB 3.0.7

Thanks
Jason

Marco van Herwaarden 07-20-2005 06:09 AM

Based on what rules these moves should be done?

jsharper 07-20-2005 06:11 AM

I have forum A that is publically viewable. I have forum B that is only viewable by admins. at midnight every night, I need to move ALL threads in forum A to forum B. So, the only rule to identify threads to be moved is that forum=A

Marco van Herwaarden 07-20-2005 06:21 AM

A relative easy cronjob should be able to do that. So you will have to write a short php-script that can perform the task.

Andreas 07-20-2005 06:39 AM

PHP Code:

<?php

error_reporting
(E_ALL & ~E_NOTICE);

if (!
is_object($DB_site))
{
    exit;
}

$DB_site->query("UPDATE " TABLE_PREFIX "thread SET forumid = B WHERE forumid = A");

require_once(
'./includes/functions_databuild.php');
build_forum_counters(A);
build_forum_counters(B);

log_cron_action('Threads moved from Forum A to Forum B'$nextitem); 

?>

Please note that this (very easy) Script will not bother updating users postcounts/titles.

jsharper 07-23-2005 08:06 PM

Kirby, that was perfect -- Thanks! It worked great in my test site and will hopefully run on my prod site at midnight tonight.

Fortunately, Forum A has "Count Posts Made in this Forum Towards User Post Counts" set to No, so that works out well. This is basically our venting forum.. it allows users to say things they might not otherwise say, knowing that everything will get "purged" daily.

Thanks again.

aciurczak 09-28-2005 01:38 AM

I think I'm looking for the same thing; the only difference is adding 1 parameter to see if the thread should be moved.

I'd like to move all threads in one forum with at least 1 reply (2 posts within thread) to be auto-moved to another forum.

Do I just need to add an "AND replycount >=1" clause?

UPDATE:

Working like a charm. If anyone needs the code, the bottom snippet moves all threads with replies from forum id #17 over to forum id #2. I have it running as a cron job once an hour.

Code:

<?php

error_reporting(E_ALL & ~E_NOTICE);

if (!is_object($DB_site))
{
    exit;
}

$DB_site->query("UPDATE " . TABLE_PREFIX . "thread SET forumid = 2 WHERE forumid = 17 AND replycount >= 1");

require_once('./includes/functions_databuild.php');
build_forum_counters(2);
build_forum_counters(17);

log_cron_action('Threads with replies moved from Forum 17 to Forum 2', $nextitem); 

?>


D-Railer 10-06-2005 06:33 PM

I love you. I'm clearly going to be using this. w00t!

Ambie 04-07-2006 02:12 AM

I used this code and a cron job to auto move threads from my news forum in 3.09. Since I upgraded to 3.5.4, it no longer works. Anyone know why?

aciurczak 04-08-2006 05:42 PM

Minor change in the function names for accessing the db in 3.5.X:

Code:

<?php

error_reporting(E_ALL & ~E_NOTICE);
if (!is_object($vbulletin->db))
{
        exit;
}

$vbulletin->db->query("UPDATE " . TABLE_PREFIX . "thread SET forumid = 2 WHERE forumid = 17 AND replycount >= 1");
require_once(DIR . '/includes/functions_databuild.php');
build_forum_counters(2);
build_forum_counters(17);

log_cron_action('Threads with replies moved from 17 to 2', $nextitem); 

?>



All times are GMT. The time now is 11:07 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01102 seconds
  • Memory Usage 1,736KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete