Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 07-20-2005, 05:01 AM
jsharper jsharper is offline
 
Join Date: Jun 2005
Location: Gilbert, AZ, US
Posts: 21
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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
Reply With Quote
  #2  
Old 07-20-2005, 06:09 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Based on what rules these moves should be done?
Reply With Quote
  #3  
Old 07-20-2005, 06:11 AM
jsharper jsharper is offline
 
Join Date: Jun 2005
Location: Gilbert, AZ, US
Posts: 21
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #4  
Old 07-20-2005, 06:21 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #5  
Old 07-20-2005, 06:39 AM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #6  
Old 07-23-2005, 08:06 PM
jsharper jsharper is offline
 
Join Date: Jun 2005
Location: Gilbert, AZ, US
Posts: 21
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #7  
Old 09-28-2005, 01:38 AM
aciurczak aciurczak is offline
 
Join Date: Jun 2005
Posts: 154
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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);  

?>
Reply With Quote
  #8  
Old 10-06-2005, 06:33 PM
D-Railer D-Railer is offline
 
Join Date: Aug 2005
Posts: 3
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I love you. I'm clearly going to be using this. w00t!
Reply With Quote
  #9  
Old 04-07-2006, 02:12 AM
Ambie Ambie is offline
 
Join Date: Apr 2005
Posts: 28
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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?
Reply With Quote
  #10  
Old 04-08-2006, 05:42 PM
aciurczak aciurczak is offline
 
Join Date: Jun 2005
Posts: 154
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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);  

?>
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:22 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05022 seconds
  • Memory Usage 2,252KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete