Your premium source for custom modification services for phpBB

HomeForumsBlogMOD ManagerFAQSearchRegisterLogin

Comments September 13, 2006

A “quickie”

Filed under: MOD Writing, phpBB — Dave Rathbun @ 7:35 am CommentsComments (0) 

So I just started writing another MOD. It was only supposed to take 30 minutes. That was a few hours ago. ;-) Most MODs start out as very simple ideas. And if the MOD is all background code (no user interface required) then it is often simple to implement. But sometimes they just seem to grow and take on a life of their own.

For example, this MOD I am currently writing is called “Forum Auth by Post Count.” Like many MODs I produce, it’s based on a number of requests from the MOD Requests forum at phpbb.com, but also on my opinion that it would be (a) easy to support and (b) popular to a large number of board owners. I don’t generally write free MODs unless those two items are both true. But back to the MOD description.

There is an “Auto Group” MOD that will put people into / take people out of a phpBB group based on their post count. People have used this to grant access to private forums based on post count… the group is where the security access is actually granted, and people are automatically added to or removed from that group as their post count changes. This is all fine, but it puts a lot of overhead on your board. Every time a post is made, the group membership is checked. Every time a post is deleted then the group membership is again checked. And these events all cause extra queries.

My MOD will not include any extra queries, except perhaps one on the forum search page. That part hasn’t been written yet. I add a couple of fields to the forum configuration page, and that’s the only user interface changes required. Everything else is background processing that determines if the user’s post count qualifies the user to see the board.

So why does it take so long? Because I keep having good ideas, I can’t stop ‘em. :-D As I was creating the SQL code to add the “min_posts_to_view” column to the phpbb_forums table, I also thought about adding a maximum limit. Why? Because that way a board administrator can create a forum that only appears to guests, or users with a zero post count! That might be interesting, and useful as well. So I added that.

Next I had to consider what would happen if a board administrator did not want to ever set a maximum limit. I use mediumint(8) for the column definition, and that goes up over 8 million posts. I have yet to see any individual user with 8 million posts (but I haven’t checked Gaia Online lately). But even still, I didn’t want to run that risk. I therefore used a “signed” version of mediumint(8) which allows negative numbers, and a “maximum” limit of -1 means that the maximum post limit is turned off.

Once I got the admin panel work done, it was on to check the actual forum pages for required updates. So far I have needed to (obviously) update the index.php in order to keep forums from showing up if the user does not have the proper post count. I also updated viewforum.php in case a user plays around with the URL and manages to enter a forum_id for a forum that they are not authorized to view because of their post count… and made a similar change to viewtopic.php for the same reasons. In all three cases there were already queries that were designed to return all of the data from the phpbb_forums table, so no new queries were written.

Then I noticed that while I was on the viewforum page the forum “jumpbox” still listed all of the forums, even those I was not supposed to see. So I edited includes/functions.php to fix that.

At this point I realized that I had replicated code in quite a few places, mainly because I didn’t do my usual job of analyzing which files I was going to need to update. :-? So instead of doing that, I once again opened includes/functions.php and this time I added a new function that I could call. The arguments to the function were the min and max levels retrieved from the phpbb_forums table, and the return value is a TRUE / FALSE based on the logic contained in the function. Once I finished the function, I went back to index, viewforum, viewtopic, and the jumpbox code to remove all of the existing code and replace it with a function call.

All along the way, I’m copying / updating the steps that I’m doing in order to be able to fill out the MOD Template. I have written some very cool (in my opinion :lol: ) tools for the phpBBDoctor site that make this a much easier process, more on those when I’m ready to talk about them. But it does take time.

Thus, 2.5 hours later I am still not finished with the MOD. But it’s looking good, and should be finished in, say, another 2.5 hours or so. :-P

Development Topic at phpBB.com

No Comments »

No comments yet.

RSS feed for comments on this post.

Leave a comment

Tags allowed in comments:
<a href="" title=""> <acronym title=""> <blockquote cite=""> <code> <strong> <em> <u> <sup> <sub> <strike>

Confirm submission by clicking only the marked checkbox:


Powered by WordPress