TinyPortal

General => Chit chat => Topic started by: resurgence on July 15, 2005, 02:12:55 PM

Title: max replies per topic
Post by: resurgence on July 15, 2005, 02:12:55 PM
is there anyway to add this to SMF?

i would like to restrict topic size to around 500-600 posts per topic and then it get automatically locked.

to be more specific, i would rather have it happen by board. but the above is fine.

is there a way to do this? :)

thanks in advance.

*sits waiting for neptune_tp* ;)

Title: Re: max replies per topic
Post by: IchBin on July 15, 2005, 03:27:49 PM
This is definately something you should ask at the SMF forums.
Title: Re: max replies per topic
Post by: Bjørn on July 15, 2005, 04:04:43 PM
Most likely it will be a mod.

But..maybe, if Post.php have info on how many replies the thread has, the Post.template could choose to NOT show the posting screen, just a message saying "topic is full" or something. No messing with the database.

I will check.
Title: Re: max replies per topic
Post by: Bjørn on July 15, 2005, 04:12:29 PM
In fact - it does. ;D
Title: Re: max replies per topic
Post by: resurgence on July 15, 2005, 09:41:30 PM
cool :)

how do i do that? and is there a way to make the topic auto lock?
Title: Re: max replies per topic
Post by: Bjørn on July 16, 2005, 01:41:55 AM
Locking is harder..but to do what I meant...maybe change Display.template  - and Post.template too - to NOT show reply/quote button and quick-reply when number of replies goes over a set value. (That could be in current theme settings). Instead it will show a small note above the post "This thread have over x posts, and cannot be replied too" for example. Sam thing in Post.tempalte, just in case someone tries a "action=post" link even if the thread has no button. ;) It could also be only for non-admins.
Title: Re: max replies per topic
Post by: resurgence on July 16, 2005, 03:22:56 PM
well, i guess that's perfectly fine :)

how do i do that?
Title: Re: max replies per topic
Post by: Bjørn on July 16, 2005, 11:22:18 PM
Open up Display.template first..then insert this right after the "global $context, $settings, $option..." line:
        // check if topic is over x number of replies, admin CAN reply regardless
        $max_replies=2;

        if($context['num_replies']>$max_replies && !$context['user']['is_admin']){
            $context['can_reply']=false;
        }


Then the same spot in Post.template.php, just in case someone does a manual link:
        // check if topic is over x number of replies, admin CAN reply regardless
        $max_replies=2;

        if($context['num_replies']>$max_replies && !$context['user']['is_admin']){
            fatal_error('This topic has reached its maximum number of replies.');
        }


This should take away reply,quote and quick-reply unless you are an admin, and give a error if someone does a manual link instead. That way you will have those attempts in your error log too.

I have just made number of replies a very small number - 2 - to test things. Change them to your liking in both places.
Title: Re: max replies per topic
Post by: resurgence on July 17, 2005, 01:09:46 PM
thanks bloc!!

is it right though? the global $context, $settings, $option.. line appears 2x in display.template and 3x in post.template

:)
Title: Re: max replies per topic
Post by: Bjørn on July 17, 2005, 03:04:34 PM
the top one in all of them. :)
Title: Re: max replies per topic
Post by: resurgence on July 18, 2005, 07:13:47 AM
ah only the top one xD

i did it in all of them :P
Title: Re: max replies per topic
Post by: Bjørn on July 18, 2005, 10:36:11 AM
It may not matter..but best to just put it once there..to easy find it again. ;)
Title: Re: max replies per topic
Post by: resurgence on July 18, 2005, 03:12:52 PM
k :) it seems that after i put it in all 2 or 3 of them, i got a nice flood of errors.

soimething about num_replies.

i'll remove the others. :)

thanks Bloc!