View Full Version : Auto move threads to archive forum after x days
trafix
01-20-2005, 10:00 PM
Requested by Floris
This is another simple script based on the Close thread after 30 days .... BUT ...
This one will auto move all threads to an archive forum where the last post is 365 days or older
There is 2 variables for you to edit
1)
Defult is set to "1"
$newforum = the forum number that these threads are to be moved to
2)
Defult is set to 365
this means that threads that havnt been replied to in the last 365 days will be moved to the nominated archive forum
you can change 365 to whatever days you like :)
Trafix
Please click Install
Update
Found an error in the code please download new zip and replace the file on your forum
Added file ...
This file will move threads from a specific forum to another spacific forum, edit as instructed :)
trafix
01-21-2005, 07:12 AM
Update
Found an error in the code please download new zip and replace the file on your forum
Floris
01-21-2005, 07:15 AM
Way cool!
I asked you less then a few hours ago to give me a birthday present hack. And here it is, exactly what I asked. As always - very pleased with your professional services trafix.
TCattitude
01-21-2005, 09:21 AM
This likes me a lot more than the close after X days.
** Install
Thanks trafix ;)
Nice one, sure could use this !
Possible to also do one "Auto Close thread after 100 posts and create a new one with the same title" ( but append a part X to it where X is 2 if the new post created has been branched once, 3 if branched twice and so on .. ) and with the first post of this new thread to have the content : " In continuation of this previous thread here: XX )" where XX is the link to the previous closed thread ?
Have always been meaning to try something like this for my forums but never got round to doing it.
Hope you can release something like this, since you seem to be on a roll with these cron jobs trafix :D
trafix
01-21-2005, 09:41 AM
yep ok ill try to do it for you :)
just call me the King of Cron ;)
trafix
01-21-2005, 10:09 AM
Nice one, sure could use this !
Possible to also do one "Auto Close thread after 100 posts and create a new one with the same title" ( but append a part X to it where X is 2 if the new post created has been branched once, 3 if branched twice and so on .. ) and with the first post of this new thread to have the content : " In continuation of this previous thread here: XX )" where XX is the link to the previous closed thread ?
Have always been meaning to try something like this for my forums but never got round to doing it.
Hope you can release something like this, since you seem to be on a roll with these cron jobs trafix :D
ive had a think about it ... and ive worked out how to code it ... i will start on it in the morming :)
trafix
01-21-2005, 10:33 AM
This likes me a lot more than the close after X days.
** Install
Thanks trafix ;)
Im glad it like you ;)
trafix
01-21-2005, 06:41 PM
Way cool!
I asked you less then a few hours ago to give me a birthday present hack. And here it is, exactly what I asked. As always - very pleased with your professional services trafix.
after i went to bed i started thinking about this one ...... careful where you archives are and who has access to it ..... remember that it will move ALL threads to the archive forum .... even from you pvt forums ... eg your mod or admin forums.
The hint here is to keep them bumped before the move time has expired
funkmeister
01-21-2005, 07:40 PM
How hard would it be to amend the script to move the messages from a live forum inside a sub-category to an archived forum within a designated "Archives" category?
For example:
LIVE CATEGORY
All The Latest (sub-category)
|---> News (forum)
ARCHIVES CATEGORY
---> News (archived forum)
What I'm trying to achieve is not to place "all" messages from all forums into a single forum....rather....place messages from a single forum into a designated archived forum of the same name but within a category called "Archives".
Hope that makes sense!?!?
Thanks.
trafix
01-21-2005, 07:43 PM
How hard would it be to amend the script to move the messages from a live forum inside a sub-category to an archived sub-forum within a designated "Archive" category.
For example:
LIVE CATEGORY
Forum A (sub-category)
|---> News (forum)
ARCHIVES CATEGORY
---> News (archived sub-forum)
Hope that makes sense!?!?
Thanks.
should be quite easy
funkmeister
01-21-2005, 07:51 PM
So it's something you would consider to incorporate into this hack or something I would need to request of you off the forum?
trafix
01-21-2005, 08:12 PM
i have added the script for this to the first post :)
funkmeister
01-21-2005, 11:07 PM
Many thanks trafix - excellent work, thank you.
Just to push the envelope a little further ;) How might I be able to include a start & end time? In other words, let's say I wanted to move all messages from a specific year, so for example....January 1st, 2002 to December 31st, 2002....into an archive sub-forum called 2002 Archives?
That way, at the end of each year, I'd be able to archive it's messages and start over from scratch with a 'clean' set of live forums for the new year.
Just an idea. Thanks.
trafix
01-21-2005, 11:34 PM
ill look at it for you ... again it should be easy
The Realist
01-22-2005, 09:49 AM
What about a script that follows on from your close posts after 30 days. I need one that automatically moved these closed threads/posts to a section called cemetary IE posts/threads that are no longer active.
Laters
trafix
01-22-2005, 10:00 AM
yep run the cron scripts back to back :) ... the otherone closes the thread then this one come in and moves them :)
funkmeister
01-22-2005, 07:21 PM
ill look at it for you ... again it should be easy
Many thanks, look forward to it.
The Realist
01-22-2005, 10:01 PM
Ahhhh nice one :)
yep run the cron scripts back to back :) ... the otherone closes the thread then this one come in and moves them :)
The Realist
01-22-2005, 10:26 PM
One thing I've noticed is this.
It moves the closed stickies as well?
Can it have options in the code so we can specify what sections not to move closed posts from. We dont want staff or stickies moving to an open forum do we.
Laters
Bison
01-23-2005, 12:44 AM
One thing I've noticed is this.
It moves the closed stickies as well?
Can it have options in the code so we can specify what sections not to move closed posts from. We dont want staff or stickies moving to an open forum do we.
Laters
$DB_site->query("
UPDATE " . TABLE_PREFIX . "thread
SET forumid = $newforum
Where lastpost <= $movedate
AND forumid != $newforum
AND sticky != 1
");
The Realist
01-23-2005, 10:17 AM
This would stop the stickies being moved yes?
$DB_site->query("
UPDATE " . TABLE_PREFIX . "thread
SET forumid = $newforum
Where lastpost <= $movedate
AND forumid != $newforum
AND sticky != 1
");
trafix
01-23-2005, 10:19 AM
yep i didnt take stickies into concideration ... good job :)
The Realist
01-23-2005, 10:28 AM
There seems to be an error in your SQL query. The MySQL server error output below, if there is any, may also help you in diagnosing the problem
ERROR: Unknown Punctuation String @ 10
STR: ->
SQL: $DB_site->query("
UPDATE " . TABLE_PREFIX . "thread
SET forumid = $newforum
Where lastpost <= $movedate
AND forumid != $newforum
AND sticky != 1
")
trafix
01-23-2005, 10:30 AM
ahhh ... ooops
should be
$DB_site->query("
UPDATE " . TABLE_PREFIX . "thread
SET forumid = $newforum
Where lastpost <= $movedate
AND forumid != $newforum
OR sticky != 1
");
The Realist
01-23-2005, 10:32 AM
Still the same M8 :)
There seems to be an error in your SQL query. The MySQL server error output below, if there is any, may also help you in diagnosing the problem
ERROR: Unknown Punctuation String @ 10
STR: ->
SQL: $DB_site->query("
UPDATE " . TABLE_PREFIX . "thread
SET forumid = $newforum
Where lastpost <= $movedate
AND forumid != $newforum
OR sticky != 1
")
trafix
01-23-2005, 10:44 AM
Ummm i just tested that code on my dev forum and it ran without an error ..... im confused
The Realist
01-23-2005, 10:49 AM
I'll run it again.
The Realist
01-23-2005, 10:51 AM
Same error.
Im using phpmyadmin to run the query.
trafix
01-23-2005, 11:02 AM
thats where you are going wrong ..... your phpmyadmin wont understand $DB_site
if you put the script in the cron folder you can use the task manager to "run now"
The Realist
01-23-2005, 11:13 AM
Lost on this one M8.
Bison
01-23-2005, 11:35 AM
Same error.
Im using phpmyadmin to run the query.
Sorry for intruding, but this query is a PHP code dependant query and you cannot run it in phpMyadmin, or in the admin cp query. That's why you are getting errors. MySQL doesn't know what a "$db_site->(query" is! LOL!
If you want to test the query (the MySQL way), just type this (and fill in the blanks):
UPDATE thread
SET forumid = [forumid number where all the threads will be moved ]
Where lastpost <= [what move date value]
AND forumid != [forumid number where all the threads will be moved]
OR sticky != 1
BTW, this won't be a test on your forums ... it going to do the deed!
trafix
01-23-2005, 12:00 PM
Sorry for intruding, but this query is a PHP code dependant query and you cannot run it in phpMyadmin, or in the admin cp query. That's why you are getting errors. MySQL doesn't know what a "$db_site->(query" is! LOL!
If you want to test the query (the MySQL way), just type this (and fill in the blanks):
UPDATE thread
SET forumid = [forumid number where all the threads will be moved ]
Where lastpost <= [what move date value]
AND forumid != [forumid number where all the threads will be moved]
OR sticky != 1
BTW, this won't be a test on your forums ... it going to do the deed!
Tnanks for explaining that Bison :)
catocom2
01-29-2005, 02:45 PM
This is the closest hack to what I'm looking for that I've found.
Except...
Instead of moving, closing, or what not, I'd just like it to add a little
clock icon in the left column if the thread is older than xx, when someone
replies to it.
Is there an easy way to mod this mod to do that?
Thanks. This cron stuff is just a little beyond my programming skills ATM.
This is a great looking hack.
trafix
01-29-2005, 04:06 PM
This is the closest hack to what I'm looking for that I've found.
Except...
Instead of moving, closing, or what not, I'd just like it to add a little
clock icon in the left column if the thread is older than xx, when someone
replies to it.
Is there an easy way to mod this mod to do that?
Thanks. This cron stuff is just a little beyond my programming skills ATM.
This is a great looking hack.
so ... the clock replaces the original icon selected? ... or appears under it?
catocom2
01-29-2005, 06:40 PM
so ... the clock replaces the original icon selected? ... or appears under it?
exactly :)
I'm not really sure it's a cron job thing though..?
Maybe just a conditional.
trafix
01-29-2005, 07:19 PM
exactly :)
I'm not really sure it's a cron job thing though..?
Maybe just a conditional.
yep ist php/template coding i can look at it
catocom2
01-30-2005, 10:50 PM
Thanks man, but I got it now. :smoke:
fury@otcentral replied and told me how he did it.
http://otcentral.com/forum/showthread.php?t=17762
catocom2
01-31-2005, 02:16 AM
here's the code I did:
place it the "threadbit" template where you want it...
<!-- ---------------------- clock ------------------------------- -->
<if condition="$thread['dateline'] <(TIMENOW-86400*180)"><img src="http://catocom.com/forum/images/smilies/clock.gif" alt="This thread was started more than 6 months ago"></if>
<!-- ---------------------- /clock ------------------------------- -->
and an icon I altered
http://catocom.com/forum/images/smilies/clock.gif
trafix
01-31-2005, 09:08 AM
nice work :)
catocom2
01-31-2005, 08:54 PM
nice work :)
well not quite. :surprised:
It seems when I search, or goto 'new posts' it shows on all the threads.
Moncha
03-04-2005, 09:00 PM
With this cron, it runs without error but nothing get moved. I do have it set for 2 different forums to move into one. Here's a peek:
error_reporting(E_ALL & ~E_NOTICE);
if ($DB_site == NULL)
{
exit;
}
global $DB_site;
// you only need to edit the number of days only
$movedate = strtotime("now -365 days");
//##############################################
// edit the forum id number where the threads have to be moved FROM
$fromforuma="10";
// edit the forum id number where the threads have to be moved TO
$toforuma="60";
// do not edit below
$DB_site->query("
UPDATE " . TABLE_PREFIX . "thread
SET forumid = $toforuma
Where lastpost <= $movedate
AND forumid = $fromforuma
");
// do not edit above
//##############################################
// edit the forum id number where the threads have to be moved FROM
$fromforumb="17";
// edit the forum id number where the threads have to be moved TO
$toforumb="60";
$DB_site->query("
UPDATE " . TABLE_PREFIX . "thread
SET forumid = $fromforumb
Where lastpost <= $movedate
AND forumid = $toforumb
");
// do not edit above
Any ideas?
Kruppa
04-15-2005, 01:45 PM
I get this error when I try to run it:
Database error in vBulletin 3.0.6:
Invalid SQL:
UPDATE thread
SET forumid =
Where lastpost <= 1110979914
AND forumid =
mysql error: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'Where lastpost <= 1110979914
AND forumid =' at line 3
mysql error number: 1064
Any ideas?
Here's a sample of the php file I've edited:
// edit the forum id number where the threads have to be moved FROM
$fromforuma="153";
// edit the forum id number where the threads have to be moved TO
$toforuma="63";
$DB_site->query("
UPDATE " . TABLE_PREFIX . "thread
SET forumid = $toforuma
Where lastpost <= $movedate
AND forumid = $fromforuma
");
// edit the forum id number where the threads have to be moved FROM
$fromforumb="4";
// edit the forum id number where the threads have to be moved TO
$toforumb="63";
$DB_site->query("
UPDATE " . TABLE_PREFIX . "thread
SET forumid = $toforumb
Where lastpost <= $movedate
AND forumid = $fromforumb
");
.
.
.
.
.
.
Kruppa
04-26-2005, 04:36 PM
Nobody? :(
KevinL
05-05-2005, 05:06 PM
This is almost what I have looking for!
Is it possible for this to move a thread once some one posts in it?
Like..a thread is started in one forum (news forum) and once someone replies it then moves to a discussion forum so others can reply?
Kruppa
05-23-2005, 01:31 AM
I get this error when I try to run it:
Database error in vBulletin 3.0.6:
Invalid SQL:
UPDATE thread
SET forumid =
Where lastpost <= 1110979914
AND forumid =
mysql error: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'Where lastpost <= 1110979914
AND forumid =' at line 3
mysql error number: 1064
Any ideas?
Here's a sample of the php file I've edited:
// edit the forum id number where the threads have to be moved FROM
$fromforuma="153";
// edit the forum id number where the threads have to be moved TO
$toforuma="63";
$DB_site->query("
UPDATE " . TABLE_PREFIX . "thread
SET forumid = $toforuma
Where lastpost <= $movedate
AND forumid = $fromforuma
");
// edit the forum id number where the threads have to be moved FROM
$fromforumb="4";
// edit the forum id number where the threads have to be moved TO
$toforumb="63";
$DB_site->query("
UPDATE " . TABLE_PREFIX . "thread
SET forumid = $toforumb
Where lastpost <= $movedate
AND forumid = $fromforumb
");
.
.
.
.
.
.
Imagine a world where my mods would get off my back to make this hack work....please help if you can. I only install hacks that are supposed to be supported, as this one is advertised.
Marco van Herwaarden
05-23-2005, 10:07 AM
Imagine a world where my mods would get off my back to make this hack work....please help if you can. I only install hacks that are supposed to be supported, as this one is advertised.This all code you edited?
Kruppa
05-24-2005, 01:40 PM
This all code you edited?
No it was only a sample. Here's the full file I uploaded:
Marco van Herwaarden
05-24-2005, 08:06 PM
// edit the forum id number where the threads have to be moved TO
$toforumi="161";
$DB_site->query("
UPDATE " . TABLE_PREFIX . "thread
SET forumid = $toforumai
Where lastpost <= $movedate
AND forumid = $fromforumai
");
$toforumai is not defined.
PS:
OMG This is the worst script i have ever seen. Do you realize you could also have done this in a 6-line loop?
No offence ment, not trying to put you down, but this really brought a smile on my face. (and a headache looking for the wrong spelled var)
Kruppa
05-24-2005, 08:56 PM
No problem! :)
I'm not sure how you do this loop thing but if you could show me how to get rid of this monster of a script it might solve all my problems.
Are sure you I can do it in my situation? Each section I'm moving threads from has its own dead threads section. That's why I thought I had to list them all.
Btw, it worked, only there was another mistake like you pointed out a little lower. Works now! :)
KevinL
05-25-2005, 05:34 PM
This is almost what I have looking for!
Is it possible for this to move a thread once some one posts in it?
Like..a thread is started in one forum (news forum) and once someone replies it then moves to a discussion forum so others can reply?
Im guessing no one knows how to do this then with this? :disappointed:
Rukas
05-30-2005, 02:09 AM
Is there a way to make this work so that after 24 hours of a thread being posted it is moved, regardless of when the last post in the thread was. So basically it only works off when the thread was started, not replied to, and moves aver 24 hours (I assume setting days to 1 would work ;)).
HeloHi
06-10-2005, 10:26 PM
How do you make this move only threads with no replies?
lifesbattles
06-11-2005, 10:59 AM
ahhh ... ooops
should be
$DB_site->query("
UPDATE " . TABLE_PREFIX . "thread
SET forumid = $newforum
Where lastpost <= $movedate
AND forumid != $newforum
OR sticky != 1
");
ugh o, every post went to my garbage folder
Kruppa
06-17-2005, 06:17 PM
ugh o, every post went to my garbage folder
Yeah that happened to me as well. Thank goodness I had a backup from about a week ago because I was in for some serious thread moving.
This hack was a good idea, but it's very annoying to have to move back the stickies every day this script runs. It works great without the stickies bit.
Sinistra
06-24-2005, 04:10 PM
OK I am running 3.0.7 The sticky thing dosen't work any suggestions on how to fix it?
error_reporting(E_ALL & ~E_NOTICE);
if ($DB_site == NULL)
{
exit;
}
global $DB_site;
// edit the forum id number
$newforum="25";
// you only need to edit the number of days only
$movedate = strtotime("now -14 days");
// do not edit below
$DB_site->query("
UPDATE " . TABLE_PREFIX . "thread
SET forumid = $newforum
Where lastpost <= $movedate
AND forumid != $newforum
OR sticky != 1
");
log_cron_action('Auto Move Threads To Archive', $nextitem);
debear
11-06-2005, 03:42 PM
Great! This looks like what I need to archive my 2004 posts to a 2004 Archive forum. I want it to maintain the forum structure and be readable, but not postable. I want them to also be searchable.
This looks like the 2 version is for annual moves which is what I need. But it looks like it is for older versions.
Has anyone tried this on version 3.5 yet? And did it leave the stickies?
Thanks for your work on this guys. :)
Julie
12-16-2005, 11:58 AM
Nice one, sure could use this !
Possible to also do one "Auto Close thread after 100 posts and create a new one with the same title" ( but append a part X to it where X is 2 if the new post created has been branched once, 3 if branched twice and so on .. ) and with the first post of this new thread to have the content : " In continuation of this previous thread here: XX )" where XX is the link to the previous closed thread ?
Have always been meaning to try something like this for my forums but never got round to doing it.
Hope you can release something like this, since you seem to be on a roll with these cron jobs trafix :D
I too would like something like that. As I have this "Band/Movie/Song/Etc Games".... And those topics should stop at 250 replies, and then a person starts a new one with the last band/movie/song/etc posted... The above request would be wicked :D Hehe...
I know it's a long while since this was posted, but... *poke* You alive?
Dactyld
01-03-2006, 05:30 PM
Crap how do you undo this? I want to put the posts back and can't figure out how.
RedWingFan
03-16-2006, 11:20 AM
Is there a way to make this work so that after 24 hours of a thread being posted it is moved, regardless of when the last post in the thread was. So basically it only works off when the thread was started, not replied to, and moves aver 24 hours (I assume setting days to 1 would work ;)).
I believe the "dateline" field is the date the thread was created. If so, replace "lastpost" with "dateline" as I've done below:
$DB_site->query("
UPDATE " . TABLE_PREFIX . "thread
SET forumid = $toforuma
Where dateline <= $movedate
AND forumid = $fromforuma
");
DrainBamaged
04-15-2006, 04:45 AM
3.5.x?
SCRIPT3R
02-01-2007, 05:22 PM
would love a port for this into 3.6.4
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.