[29/11/06] Forum Auth by Post Count

All new MODs released in our MOD Database will be announced in here. All support for released MODs needs to take place in here. No new MODs will be accepted into the MOD Database for phpBB2
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.
Post Reply

Rating:

Excellent!
15
56%
Very Good
7
26%
Good
1
4%
Fair
1
4%
Poor
3
11%
 
Total votes: 27

Extensions Robot
Extensions Robot
Extensions Robot
Posts: 27930
Joined: Sat Aug 16, 2003 7:36 am

[29/11/06] Forum Auth by Post Count

Post by Extensions Robot » Tue Nov 14, 2006 4:25 am

MOD Name: Forum Auth by Post Count
Author: drathbun
MOD Description: Control access to view / post in forums based on a user's post count.

MOD Version: 1.0.0
Tested on phpBB Version: 2.0.21

Download File: forum_auth_by_post_count.1.0.0.zip
mods overview page: View
File Size: 5281 Bytes



Support for this MOD needs to be asked within this topic. The phpBB Teams are not responsible or required to give anyone support for this MOD. By installing this MOD, the phpBB Support Team or phpBB MODifications Team may not be able to provide support.

This MOD has only been tested by the phpBB MOD Team with the phpBB version listed in the topic. It may not work in any other versions of phpBB.
Last edited by Extensions Robot on Mon Apr 30, 2007 12:31 am, edited 1 time in total.
(this is a non-active account manager for the phpBB Extension Customisations Team)

MarkTheDaemon
Former Team Member
Posts: 2770
Joined: Thu Oct 20, 2005 2:42 am
Location: United Kingdom
Name: Mark Barnes

Post by MarkTheDaemon » Wed Nov 29, 2006 7:23 pm

MOD Validated/Released

Notes:
This MOD allows administrators to control the amount of posts a user needs to view & post in a certain forum

User avatar
drathbun
Former Team Member
Posts: 12204
Joined: Thu Jun 06, 2002 3:51 pm
Location: TOPICS_TABLE
Contact:

Post by drathbun » Wed Nov 29, 2006 7:58 pm

Another MOD released! Nice to see the queue clearing out, thanks to the MOD Validator team. 8)

As part of the review process the MOD Validator noted this:
WHERE 1 = 1?

Code: Select all

         $sql = 'SELECT  forum_id
            ,       min_posts_to_view
            ,       max_posts_to_view
            FROM    ' . FORUMS_TABLE . ' f
            WHERE   1 = 1 ' .
               $extra_sql; 

The "1 = 1" portion of the query panel is there so that I always know that there is a where clause, and the $extra_sql variable can then automatically start with AND. If not, then I have to do a bunch of extra checking. So this is a simple shortcut that allows me to generate extra sql (thus the name $extra_sql) on the fly without worrying about whether it is the first line of extra sql (thus requiring a "where") or a subsequent line (requiring an AND instead).

It should perform fine on all databases supported by phpBB.

Another MOD comment was regarding one of the debug messages, where the $sql variable was not echoed. That point is well taken, and I will post an update to fix that shortly. It does not impact the function or security aspects of this MOD.

Screen Shot of Admin Panel
To invoke this MOD, open your admin control panel (ACP) and select Management in the Forum Admin section. Click the Edit link on any forum you wish to protect with this MOD, and set the values as desired. Note that the minimum post count defaults to zero and the maximum post count defaults to minus one. A value of minus one for the maximum value says "no limit has been set".

Image

FAQ
How can I use the "Visible on Index" feature shown in the screenshot? When I install the MOD I don't seem to get that option...
The "Visible on Index" option displayed in the screenshot above is not a part of this MOD but something different altogether. This MOD - as written - will hide the forum on the index page and prevent someone from viewing it unless they have the required number of posts. Only the items outlined in red are actually from this MOD. The Visible on Index is from an unreleased MOD, and the Enable Topic Points is from another MOD currently in development.

Oh, rats. I want to show the forum on the index, but still prevent people from reading it until they have the required number of posts.
If you want to show the forums on your index but still want to prevent people from reading topics within the forum until they have the correct number of posts, then simply skip the application of the MOD steps pertaining to index.php. You need to apply every other step except those related to that file.

Will this work for Simple Subforums?
Not as written in the download package, no. There should be a fairly simple change in order to make that work, but I have not had time to review it or post it yet.

I would like the permissions message to state how many posts are required to enter the forum.
Sorry, I don't. :-) The idea is that the forum doesn't even exist anywhere until the required number of posts have been obtained. In other words, unless a user simply goes through all of the possible forum_id values they should not even know that it's there. In that case, there's no point in telling them how many spam posts they have to enter before gaining access to the forum.

I installed with EasyMOD and now I get a SQL error on viewtopic.php, what can I do?
EasyMOD does not find spaces at the end of a line. There is one edit where the space is quite important. To fix this, please open viewtopic.php and find the following

Code: Select all

f.max_posts_to_viewORDER BY p.post_id ASC
and replace it with this:

Code: Select all

f.max_posts_to_view ORDER BY p.post_id ASC
Do you have translations?
Here are some links to posts within this topic where folks have posted translations, listed in alphabetical order:

Dutch
German
Korean

Post Edit History
Edited to add language links
Edited to add FAQ questions
Edited to add FAQ about SQL error due to missing space
Last edited by drathbun on Wed Feb 21, 2007 8:36 pm, edited 3 times in total.
I blog about phpBB: phpBBDoctor blog
Still using phpbb2? So am I! Click below for details
Image

User avatar
Brf
Support Team Member
Support Team Member
Posts: 51785
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Post by Brf » Wed Nov 29, 2006 8:05 pm

Good job, Drathbun. There have been several new users asking for this today.

User avatar
drathbun
Former Team Member
Posts: 12204
Joined: Thu Jun 06, 2002 3:51 pm
Location: TOPICS_TABLE
Contact:

Post by drathbun » Wed Nov 29, 2006 8:06 pm

phpBBDoctor MOD Manager wrote: Files To Edit: (10) index.php, posting.php, search.php, viewforum.php, viewtopic.php, admin/admin_forums.php, includes/constants.php, includes/functions.php, language/lang_english/lang_admin.php, templates/subSilver/admin/forum_edit_body.tpl
Included Files: None

This MOD has 61 install instructions.


This MOD was written in response to a number of MOD Requests that I have seen over the years, some of them recent. It allows the Board Admin to enter a minimum and maximum post count required (allowed) to view a forum. This is much simpler than the "auto-group" MODs which place quite a bit of overhead on your system... every time a user posts the auto-group MOD has to check to see if they have increased their post count to a level where they should be added to a group, or during deletes the reverse check is required. This MOD does not add any new queries to the index, viewforum, viewtopic, or function code.

I can see several uses for this.

First, you can set a minimum post count for "special" forums. When a user reaches that post count, the forum will become visible on the index. Until that point, the forum is never seen.

Next, you can set a maximum post count for "special" forums as well. For example, if you set a maximum post count of zero then only guests or users that have never posted will see that forum. This could be useful to present a group of "welcome" topics. If the maximum post count allowed is set to zero then this forum will become invisible as soon as the user makes their very first post. Or you could set to to 10 (or 50 or any other number) in order to have the forum stay visible for a while before it goes away.

A minimum post to view value of zero is default, meaning all forums are visible. A maximum post to view value of -1 is default. This value essentially turns off the maximum post limit, so the forum remains visible no matter how many posts a user has.

ADMIN users are immune to these limits, and will always see all forums. I make no special plans for moderators, and don't plan to in order to keep this MOD as simple as possible. If a user plays around with the URL and tries to enter a forum_id that they are not authorized to see then they will get a "not authorized" message. This message does not state how many posts are required, it simply states they are not authorized. This extra "auth" check is performed in both viewforum.php and viewtopic.php. The forum list for the forum "jumpbox" is also based on this restriction.

The MOD also offers the ability to say how many posts are required (allowed) before posting in a particular forum. So if you want to require everyone to post at least once in the "Introductions" forum, set the min post count to post in that forum to zero, and set it to one for every other forum on your board. That means that the first post the user makes has to be in the intro forum, as required.

You can also set a max limit, so people with high post counts can't spam the board by "welcoming" every new user in the intro forum once they reach a certain post count. :-P
I blog about phpBB: phpBBDoctor blog
Still using phpbb2? So am I! Click below for details
Image

MonkeyManx
Registered User
Posts: 38
Joined: Sat Oct 07, 2006 8:59 pm

Post by MonkeyManx » Fri Dec 01, 2006 3:00 am

Mod fails with EasyMod .30 install on phpbb 2.0.2.1 board:

Code: Select all

Critical Error

FIND FAILED: In file [admin/admin_forums.php] could not find:

intval($HTTP_POST_VARS['forumstatus']) . ", "

MOD script line #464 :: FAQ :: Report
Mod instruction being performed was:

Code: Select all

#-----[ FIND ]-------------------------------------
# On or about line 396; find text might not be a complete line
#
intval($HTTP_POST_VARS['forumstatus']) . ", "

#
#-----[ IN-LINE FIND ]-------------------------------------
#
intval($HTTP_POST_VARS['forumstatus']) . ", "

#
#-----[ IN-LINE AFTER, ADD ]-------------------------------------
#
. intval($HTTP_POST_VARS['min_posts_to_view']) . ", " . intval($HTTP_POST_VARS['max_posts_to_view']) . ", " . intval($HTTP_POST_VARS['min_posts_to_post']) . ", " . intval($HTTP_POST_VARS['max_posts_to_post']) . ", "
Closest match is on line 446 of my admin_forums.php, full line reads as follows:

Code: Select all

intval($HTTP_POST_VARS['forumstatus']) . ", '" . str_replace("\'", "''", $HTTP_POST_VARS['forumicon']) . "', " . 
Your mod is looking for this:

Code: Select all

intval($HTTP_POST_VARS['forumstatus']) . ", "
but the actual line in my file is:

Code: Select all

intval($HTTP_POST_VARS['forumstatus']) . ", '"
Notice the extra single quote at the end. Mods that have caveats about "find text might not be a complete line" always make me nervous. Looking at this closer I realize that this extra ' is due to another mod being applied and not the fault of your mod. However the line of code that your mod is finding isn't unique and is referenced twice in the file. You mentioned altering the first line found, so I'll try this and let you know how it goes. :)

User avatar
drathbun
Former Team Member
Posts: 12204
Joined: Thu Jun 06, 2002 3:51 pm
Location: TOPICS_TABLE
Contact:

Post by drathbun » Fri Dec 01, 2006 3:31 am

MonkeyManx wrote: Mod fails with EasyMod .30 install on phpbb 2.0.2.1 board:

... {snip} ...

Your mod is looking for this:

Code: Select all

intval($HTTP_POST_VARS['forumstatus']) . ", "
but the actual line in my file is:

Code: Select all

intval($HTTP_POST_VARS['forumstatus']) . ", '"

What you provided as the code snippet is not a standard phpBB board, as the FIND match does work on an un-modded board. And as you noted further on in your post, you are working on an altered file.
Mods that have caveats about "find text might not be a complete line" always make me nervous.

I understand your concerns! :-) However, the reason for that disclaimer is based on a number of MODs that I have had submitted to the MOD Team for validation. On more than one occasion I have been advised to make my FIND targets as small as possible to allow compatibility with boards that have already been altered. Which brings me to...
Looking at this closer I realize that this extra ' is due to another mod being applied and not the fault of your mod.

And in your case, it seems even my trimmed down FIND target was too long. :lol: I can say with certainty that the FIND targets work on an unMODded board; it's tough to know what else it out there. Do you remember which other MOD you have installed that added the extra quote? Obviously it's something that alters the phpbb_forums table... just asking for curiousity more than anything else.
However the line of code that your mod is finding isn't unique and is referenced twice in the file. You mentioned altering the first line found, ...

Yup, that's the process to use. EasyMOD works that way (I am told) and so should a manual installer. Basically you start at the top of a file and work your way through, applying each FIND and then the other actions based on the first match found, then starting further actions from that point in the file. If you review the results after the MOD has been installed you will find that there is, in fact, another FIND with a target for the second line that includes the same code, which is line 435 in an un-modded 2.0.21 board. The two finds are very similar because one alters the "insert" statement for new forums, and the other alters "update" instructions for existing forums.
so I'll try this and let you know how it goes. :)

Thanks for taking the time to provide feedback. If there is anything else I can do to help clarify the installation notes, please let me know.
I blog about phpBB: phpBBDoctor blog
Still using phpbb2? So am I! Click below for details
Image

Apoxol
I've Been Banned!
Posts: 35
Joined: Thu Nov 30, 2006 1:42 pm

Post by Apoxol » Fri Dec 01, 2006 3:33 am

Nice MOD.

limekat
Registered User
Posts: 8
Joined: Sun Dec 03, 2006 5:07 am

Post by limekat » Tue Dec 05, 2006 7:30 am

I can't seem to find the settings for this in the ACP. It should be under 'Forum Admin' right? I can't see any extra links under there. If I, by any chance installed the mod wrong, what files will I need to re-edit to make it right? I'm not sure which files are associated with my problem ><"

User avatar
drathbun
Former Team Member
Posts: 12204
Joined: Thu Jun 06, 2002 3:51 pm
Location: TOPICS_TABLE
Contact:

Post by drathbun » Tue Dec 05, 2006 2:17 pm

It doesn't create a new menu link, it creates new options on the "Edit Forum" page. So you will need to open each forum and set up your controls. Hopefully that makes sense; I will post a screenshot when I get a chance.
I blog about phpBB: phpBBDoctor blog
Still using phpbb2? So am I! Click below for details
Image

limekat
Registered User
Posts: 8
Joined: Sun Dec 03, 2006 5:07 am

Post by limekat » Tue Dec 05, 2006 8:55 pm

Oh, yup that makes sense. Sorry; I didn't know. Is it on the install file ? x: I think you should include that info as I was totally helpless as to where to go D:

Thanks ^^ HOWEVER; in the ACP when editing the forum, i have 4 inputs that come up "Posts that are required to view this forum" x2 and "Posts that are required to post in this forum" x 2. I think this is due to my confusion and maybe I added an extra tag. But I can't see any... T_T" I looked in the RC thread and it showed a screenie of the admin panel, it has only 2 inputs.

User avatar
drathbun
Former Team Member
Posts: 12204
Joined: Thu Jun 06, 2002 3:51 pm
Location: TOPICS_TABLE
Contact:

Post by drathbun » Wed Dec 06, 2006 12:41 am

One is the min, one is the max. The original screen shot was built before the final version. They should be labeled properly... I think. I removed my demo board, so I don't have this installed anywhere right now. I'll have to fix that.
I blog about phpBB: phpBBDoctor blog
Still using phpbb2? So am I! Click below for details
Image

User avatar
drathbun
Former Team Member
Posts: 12204
Joined: Thu Jun 06, 2002 3:51 pm
Location: TOPICS_TABLE
Contact:

Post by drathbun » Wed Dec 06, 2006 1:11 am

Updated this post with screen shot of admin control panel.
I blog about phpBB: phpBBDoctor blog
Still using phpbb2? So am I! Click below for details
Image

limekat
Registered User
Posts: 8
Joined: Sun Dec 03, 2006 5:07 am

Post by limekat » Wed Dec 06, 2006 6:48 am

Sorry; I'm saying that there is double of what was in your admin screenshot.. there are 8 inputs, 4 rows in my General Forum Settings, ACP. >_>"

acharabia
Registered User
Posts: 139
Joined: Fri Sep 27, 2002 4:41 pm
Location: SEOUL/KOREA
Contact:

Post by acharabia » Wed Dec 06, 2006 10:25 am

This MOD is goooooodda~ :wink:
I said gooooodda, that MOD is really goooodda~
Why? There are several kinds of measure for
grade to MOD relase here by acharabia rule.
  • 1st: He show screenshot.
    This is really important to act for phpbb user before installing.
  • 2nd: His indication is perfect on the mannual!!!
    This mean... He not delete old cold on [replace to] This is a little bit important for next installing on other kinds of MOD. If there is no old code, we confusing to find a code on next step to install.
  • And he going to process althoxocical in the mannual.
    e.g. posting.php... viewforum... viewtopic... and admin/admin_forums.php... includes/constants.php... langadmin...
    and then templates/subSilver/admin/forum_edit_body.tpl Some ppl say that's not big issue but this ordering is very important!!! to avoid confusing.
So I give foerign langpak here for thanksgiving~ :wink:

Code: Select all

// BEGIN Forum Auth by Post Count 1.0.0 (www.phpBBDoctor.com)
$lang['Posts_to_view'] 		= '게시물 등록 요구량 (보기)';
$lang['Posts_to_post'] 		= '게시물 등록 요구량 (쓰기)';
$lang['Min_post_limit'] 	= '최소한의 등록 글 수';
$lang['Max_post_limit'] 	= '최대한의 등록 글 수, <i>[-1] 설정시 무한대</i>';
// END Forum Auth by Post Count 1.0.0 (www.phpBBDoctor.com)
Image

Post Reply

Return to “[2.0.x] MOD Database Releases”