Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Aiheen aloitti: thernlund - huhtikuu 19, 2014, 11:53:38 IP

Otsikko: Average post count over X time frame required to post
Kirjoitti: thernlund - huhtikuu 19, 2014, 11:53:38 IP
Using SMF 2.0.7

I'm interested in modifying the board to prevent posts to certain boards based on a user maintaining an average number of posts over the past X amount of time.  For example, a user must have an average of 20 posts or more per month for the past 3 months (rolling) in order to create a new thread on a given specific board.  If at any time their posting average falls below the 20/month threshold, posting to the specific given board will be denied until said average rises above the threshold (via posting to non-restricted boards).

This would be for creating new threads only.  Replies should not be restricted.

I have created such a system before on an add-on page using the SMF SSI functions.  That was simple enough to query for what data I needed, do the calculations, and grant or deny access as needed.  However in this case to do what I want I must modify the SMF software sources I think, and I'm not entirely sure where in the SMF software to insert such a modification.  I am also unaware of any caveats to doing such a thing as I describe.

My searching hasn't turned up any existing mods or tips.  I am somewhat familiar with the general SMF structure, as well as well-versed in PHP and MySQL.  Any help would be appreciated.
Otsikko: Re: Average post count over X time frame required to post
Kirjoitti: margarett - huhtikuu 20, 2014, 04:18:13 AP
The normal allowedTo() is probably not adequate.

You can add your query and the maths in Load.php (this probably adds another query per user so you might want to use it carefully (eg, not fetching this when displaying a message...)) then expand the user structure with a true/false field and finally use this for allowing or not the new topic and the respective button