Hi there. We need to limit our users to posting only once every week in a certain forum on our site. I wrote an addon to do this in vBulletin, but I was hoping something already existed for Xen. I found http://xenforo.com/community/resources/daily-post-limit-by-waindigo.1919/ which is pretty close to what we need, but doesn't let us define a time limit other than daily, which is a deal breaker unfortunately.
I've started work on this addon but would like to know about some best practices (Apologies for the newbie questions - I am still fresh to XF):
1. I've got my class/method set up and an event listener set up to fire that method on the controller_pre_dispatch event with a XenForo_ControllerPublic_Forum hint so that the method is only firing when absolutely necessary. Does this look correct for catching a new thread before it happens?
2. So I've got my method firing on every new thread request (<?php if($action === 'CreateThread')..... ?>) but I only need to continue if the node ID is 7. What is the best way to go about this? I see that I can dig down into the controller variables to get to the node ID, but I wasn't sure if there was a proper API request to get this.
3. OK, so now my method knows that a new thread is being posted to Node ID 7 and I need to see if the user has made any new threads in this node in the last 10 days. What is the proper way of querying the database for this information? The date calculation is easy, but I want to make sure we're going about all of this the right way in terms of API calls and whatnot.
4. How do we show an error to the user and stop execution of the page? In VB it was just a standard_error() call but I haven't yet discovered the right way of doing this in XF.
5. For future expansion on this, I see that I can create new option groups/options while in dev mode and assign these to my addon. Now, from my addon method, is there an options API that I would use to retrieve these settings?