[BETA] Post Count Access Control

A place for MOD Authors to post and receive feedback on MODs still in development. No MODs within this forum should be used within a live environment! No new topics are allowed in this forum.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

IMPORTANT: MOD Development Forum rules

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.
wulff
Registered User
Posts: 20
Joined: Mon Feb 10, 2003 12:22 pm
Location: Denmark
Contact:

[BETA] Post Count Access Control

Post by wulff »

A simple mod that lets you control access to a forum based on the user's post count.

Using the ACP, you can set a minimum post count for a forum. If the user trying to access a forum hasn't made the requisite amount of posts in the other forums on your site, he/she will be denied access.

I'm posting this as [BETA] since I'm not sure whether the added code in veiwtopic/viewforum could be placed earlier in the file.

Kind regards,

Morten Wulff

Code: Select all

##############################################################
## MOD Title: Post Count Access Control
## MOD Author: wulff < wulff@psyke.org > (Morten Wulff) http://www.psyke.org
## MOD Description: This mod lets you restrict access to forums based on user post count
## MOD Version: 1.0.0
##
## Installation Level: (Easy)
## Installation Time: 10 Minutes
## Files To Edit: viewforum.php
##                viewtopic.php
##                admin/admin_forums.php
##                language/lang_english/lang_admin.php
##                language/lang_english/lang_main.php
##                templates/subSilver/admin/forum_edit_body.tpl
## Included Files: (n/a)
##############################################################
## For Security Purposes, Please Check: http://www.phpbb.com/mods/ for the
## latest version of this MOD. Downloading this MOD from other sites could cause malicious code
## to enter into your phpBB Forum. As such, phpBB will not offer support for MOD's not offered
## in our MOD-Database, located at: http://www.phpbb.com/mods/
##############################################################
## Author Notes:
##
##############################################################
## MOD History:
##
##   2004-01-11 - Version 1.0.0
##      - Initial release
##
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################

#
#-----[ SQL ]------------------------------------------
# Change the prefix 'phpbb_' accordingly. 'phpbb_' is the default prefix
#
ALTER TABLE phpbb_forums ADD access_posts MEDIUMINT(8) UNSIGNED DEFAULT '0' NOT NULL;
#
#-----[ OPEN ]------------------------------------------
#
viewforum.php
#
#-----[ FIND ]------------------------------------------
#
//
// End of auth check
//
#
#-----[ AFTER, ADD ]------------------------------------------
#
if ( !( $userdata['user_posts'] >= $forum_row['access_posts'] ) && !$is_auth['auth_mod'] && !($userdata['user_level'] == ADMIN))
{
	$message = $lang['pcac_msg_1'] . $forum_row['access_posts'] . $lang['pcac_msg_2'];
	message_die(GENERAL_MESSAGE, $message);
}

#
#-----[ OPEN ]------------------------------------------
#
viewtopic.php
#
#-----[ FIND ]------------------------------------------
#
$sql = "SELECT t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, t.topic_type, t.topic_vote, t.topic_last_post_id, f.forum_name, f.forum_status, f.forum_id, f.auth_view, f.auth_read, f.auth_post, f.auth_reply, f.auth_edit, f.auth_delete, f.auth_sticky, f.auth_announce, f.auth_pollcreate, f.auth_vote, f.auth_attachments" . $count_sql . "
#
#-----[ IN-LINE FIND  ]------------------------------------------
#
f.auth_attachments
#
#-----[ IN-LINE AFTER, ADD ]------------------------------------------
# (before the " )
#
, access_posts
#
#-----[ FIND ]------------------------------------------
#
//
// End auth check
//
#
#-----[ AFTER, ADD ]------------------------------------------
#
if ( !( $userdata['user_posts'] >= $forum_topic_data['access_posts'] ) && !$is_auth['auth_mod'] && !($userdata['user_level'] == ADMIN))
{
	$message = $lang['pcac_msg_1'] . $forum_topic_data['access_posts'] . $lang['pcac_msg_2'];
	message_die(GENERAL_MESSAGE, $message);
}
#
#-----[ OPEN ]------------------------------------------
#
admin/admin_forums.php
#
#-----[ FIND ]------------------------------------------
#
				'L_DAYS' => $lang['Days'],
#
#-----[ AFTER, ADD ]------------------------------------------
#
				'L_ACCESS_POSTS' => $lang['Access_posts'],
#
#-----[ FIND ]------------------------------------------
#
				'PRUNE_FREQ' => ( isset($pr_row['prune_freq']) ) ? $pr_row['prune_freq'] : 1,
#
#-----[ AFTER, ADD ]------------------------------------------
#
				'ACCESS_POSTS' => ( isset($pr_row['access_posts']) ) ? $pr_row['access_posts'] : 0,
#
#-----[ FIND ]------------------------------------------
#
prune_enable" . $field_sql
#
#-----[ IN-LINE FIND  ]------------------------------------------
#
prune_enable
#
#-----[ IN-LINE AFTER, ADD ]------------------------------------------
# (before the " )
#
, access_posts
#
#-----[ FIND ]------------------------------------------
#
intval($HTTP_POST_VARS['prune_enable']) . $value_sql
#
#-----[ IN-LINE FIND  ]------------------------------------------
#
intval($HTTP_POST_VARS['prune_enable'])
#
#-----[ IN-LINE AFTER, ADD ]------------------------------------------
# (before the . )
#
 . ", " . intval($HTTP_POST_VARS['access_posts'])
#
#-----[ FIND ]------------------------------------------
#
prune_enable = " . intval($HTTP_POST_VARS['prune_enable']) . "
#
#-----[ AFTER, ADD ]------------------------------------------
#
, access_posts = " . intval($HTTP_POST_VARS['access_posts']) . "
#
#-----[ OPEN ]------------------------------------------
#
language/lang_english/lang_admin.php
#
#-----[ FIND ]------------------------------------------
#
$lang['Move_and_Delete'] = 'Move and Delete';
#
#-----[ BEFORE, ADD ]------------------------------------------
#
$lang['Access_posts'] = 'Posts for access';

#
#-----[ OPEN ]------------------------------------------
#
language/lang_english/lang_main.php
#
#-----[ FIND ]------------------------------------------
#
//
// That's all, Folks!
#
#-----[ BEFORE, ADD ]------------------------------------------
#
$lang['pcac_msg_1'] = 'You must have made at least ';
$lang['pcac_msg_2'] = ' posts to access this forum.';
#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/admin/forum_edit_body.tpl
#
#-----[ FIND ]------------------------------------------
#
	<tr> 
	  <td class="catBottom" colspan="2" align="center">{S_HIDDEN_FIELDS}<input type="submit" name="submit" value="{S_SUBMIT_VALUE}" class="mainoption" /></td>
#
#-----[ BEFORE, ADD ]------------------------------------------
#
	<tr>
	  <td class="row1">{L_ACCESS_POSTS}</td>
	  <td class="row2"><input type="text" size="5" name="access_posts" value="{ACCESS_POSTS}" class="post" /></td>
	</tr>
#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM

octoberthehottie
Registered User
Posts: 35
Joined: Fri Sep 19, 2003 7:25 pm
Contact:

Post by octoberthehottie »

OMG, I can't believe after searching in here for hours that I have actually found what I didn't believe would exist!!! I am so glad that you made this, and someone else has had this need as well, I am going to add this shortly, but I can say as of now the only other thing I was thinking was that it might work better for me if the new users couldn't even see the forums I am going to block, seeing them but not being able to access them might tick people off, but now that I think of it, on my site they are going to be expecting to see those topics there and if they don't they might repeatedly ask where they are or give up and move on, so your way might actually be better, as I said I am going to install, and I will let you know how it goes and what I think...... Thanx a bunch!!!!!


*edit.... Ok, nix that, I don't have access to my SQL, so I am going to have to contact my host to do it, sooooo, creating an installer for it wouldn't be a bad idea.... lol...
OctoberTheHottie
www.aimxpress.net/

Rapid Dr3am
Registered User
Posts: 198
Joined: Sun Jul 13, 2003 4:14 pm
Location: Incommunicado
Contact:

Post by Rapid Dr3am »

http://www.phpbbsupport.co.uk/db_generator.php
Create a db_update.php yourself. :)

User avatar
transwarp™
Registered User
Posts: 92
Joined: Fri Jul 19, 2002 11:34 pm

Post by transwarp™ »

Would be interesting ! - Before we always needed to Usergroups to do such things -
- TERRA OCEANICA -

octoberthehottie
Registered User
Posts: 35
Joined: Fri Sep 19, 2003 7:25 pm
Contact:

Post by octoberthehottie »

Ok, I got it all worked out and set up on my forum, and everything seems to be working ok, I am going to make a user name and test it out now, and I will keep you posted... :) Ok, all tested, seems to work, I won't be fully implementing for a couple of months, but I am sure glad I found this!!!
OctoberTheHottie
www.aimxpress.net/

dennistt
Registered User
Posts: 271
Joined: Sat May 10, 2003 12:06 am
Location: DennisTT.Net
Contact:

Post by dennistt »

Rapid Dr3am wrote: http://www.phpbbsupport.co.uk/db_generator.php
Create a db_update.php yourself. :)


Whoa that's cool :P

octoberthehottie
Registered User
Posts: 35
Joined: Fri Sep 19, 2003 7:25 pm
Contact:

Post by octoberthehottie »

yeah, I think that is cool too, but.... I am not too familiar with databases or how to use them, so i was afraid I would do it wrong, maybe it just looks soo simple that I think that it is hard. I know this is lame, but tell me, all I have to do is copy the SQL command for the MOD I need adjusting for in the box on that page, and just do what the instructions say and click the button, it seems easy, so is it?? Sorry, lol..... noob... :oops:
OctoberTheHottie
www.aimxpress.net/

User avatar
vze3k59w
Registered User
Posts: 485
Joined: Fri May 09, 2003 1:09 am

Post by vze3k59w »

dont use

Code: Select all

f.auth_attachments
as a find because not everyone has the attachment mod...
Wanna join a very advanced OO based modular port of phpBB? PM me :)

User avatar
morpheus2matrix
Former Team Member
Posts: 9171
Joined: Wed Apr 10, 2002 7:31 pm
Location: France
Contact:

Post by morpheus2matrix »

vze3k59w wrote: dont use

Code: Select all

f.auth_attachments
as a find because not everyone has the attachment mod...


it's not used by the Attachment MOD but by phpBB : check the fields of the table phpbb_auth :wink:
Former phpBB MOD-Team Member -

Forgive my bad English :(

No support by PM/Email - Thanks - You can thanks me here :) - Pay me for installing MOD's :lol:

User avatar
Xxh2kxX
Registered User
Posts: 149
Joined: Fri Aug 22, 2003 6:03 pm
Contact:

hello

Post by Xxh2kxX »

Hello.

ok i install this mod .. there is no Error come to me .. when i try to go to the CP and i try to test it .. its not working .. i dont no if there is anything wrong .. may u pls tell me how this mod work ...

thankyou .. its already install and there is no error .. so let me know how it work .. thankyou agian :D

octoberthehottie
Registered User
Posts: 35
Joined: Fri Sep 19, 2003 7:25 pm
Contact:

Post by octoberthehottie »

To configure this MOD, in the ACP go to Forum Management, then choose the forum you would like to add the restriction to and choose to edit that forum from that screen, then on the General Forum Settings screen where you set if the forum is locked or unlocked, and the pruning settings, under that is where you set the posts for access, I don't know if this is the information you were looking for, but if you don't see any of that or something is messed up then I would say upload your backed up files to reset your forum back to the original state and try adding it again.... good luck! :)
OctoberTheHottie
www.aimxpress.net/

UTA
Registered User
Posts: 4
Joined: Fri Apr 16, 2004 12:42 pm

Post by UTA »

can anybody just create a installer for it?
I cant get it to work! :(

octoberthehottie
Registered User
Posts: 35
Joined: Fri Sep 19, 2003 7:25 pm
Contact:

Post by octoberthehottie »

Rapid Dr3am wrote: http://www.phpbbsupport.co.uk/db_generator.php
Create a db_update.php yourself. :)


Yes, this message has a link to an installer creator page, go there, it is fairly simple...
OctoberTheHottie
www.aimxpress.net/

User avatar
transwarp™
Registered User
Posts: 92
Joined: Fri Jul 19, 2002 11:34 pm

Post by transwarp™ »

I got the following trouble with this kind of MOD - I could enter any value there, but it always display an zero inside the field ! - Everything inside the DATABASE was correct, but I always saw an zero if editing the forum settings -

I have done this kind of fix to this one -

FIND:

Code: Select all

'ACCESS_POSTS' => ( isset($pr_row['access_posts']) ) ? $pr_row['access_posts'] : 0, 
REPLACE WITH:

Code: Select all

'ACCESS_POSTS' => ( isset($row['access_posts']) ) ? $row['access_posts'] : 0,
This solved everything for me, and all is working now fine ! - :wink:
- TERRA OCEANICA -

jongartman
Registered User
Posts: 57
Joined: Tue May 11, 2004 8:17 am

Post by jongartman »

mod works GREAT. thank you so much.

Post Reply

Return to “[2.0.x] MODs in Development”