PDA

View Full Version : Need something that locks threads after 35 posts Any Help?


RamdonGhai
04-29-2009, 06:47 PM
Anyone have any idea? I basically want something that'll lock each thread in a certain board that will lock a thread after it reaches 35 replies

Lynne
04-29-2009, 08:11 PM
write a cron job/scheduled task to check all open threads (thread.open = '1') with a post count over 35 (thread.replycount >= 35) and close them (thread.open = '0'). Or, if may be easier to write a plugin that hooks into where the replycount is increased after a thread is made and if you hit 35, also close the thread. Either would work.

RamdonGhai
05-13-2009, 08:32 PM
Thanks alot Lynne,

I've been working on this and can not figure out the syntax

If you (or anyone else) don't midn can you write up an example cron file...

i'm assuming its written in PHP ... but I just want to see an example, once I get the catch of writing those whoooa its going to be awesome.

Cryo
05-13-2009, 08:43 PM
This should work for the CRON method...

$cthreads_SQL = "UPDATE
". TABLE_PREFIX ."thread
SET
open = 0
WHERE
replycount > 34
AND open = 1";

$cthreads = mysql_query($cthreads_SQL);

If you're not including the global file you'll need to replace "TABLE_PREFIX" with your table prefix.

RamdonGhai
05-13-2009, 08:49 PM
This should work for the CRON method...

$cthreads_SQL = "UPDATE
". TABLE_PREFIX ."thread
SET
open = 0
WHERE
replycount > 34
AND open = 1";

$cthreads = mysql_query($cthreads_SQL);

If you're not including the global file you'll need to replace "TABLE_PREFIX" with your table prefix.
This is my first time implementing a cron

so basically i create a new php file with the above code in it... then go to scheduled tasks in adminCP and link to it?

Cryo
05-13-2009, 08:58 PM
Yep, that should work just fine.

RamdonGhai
05-13-2009, 09:33 PM
awesome ...i think this is going to work... but looking at the code, what statement can I add that will delete all posts after post number 35 (when its locked)

Cryo
05-13-2009, 09:48 PM
That gets a bit more complicated and involves code that checks each thread. Probably not worth the resources to be honest.

RamdonGhai
05-13-2009, 10:08 PM
That gets a bit more complicated and involves code that checks each thread. Probably not worth the resources to be honest.

if i were to edit the procedure (or function) that is called when making a post to make it impossible to make a reply in a thread already with 35 posts... wouldn't that be more feasible?

A 1-liner would do it, right? (in theory)

That in conjunction with this cron job should do the trick