Forum Template User-defined permissions

Discussion forum for MOD Writers regarding MOD Development.
User avatar
ironlion
Registered User
Posts: 117
Joined: Fri Aug 26, 2005 10:16 pm

Re: Forum Template User-defined permissions

Post by ironlion »

Is it possible to use the abouve code with RANKS.

say:

<!-- IF S_RANK_2 -->some stuff here<!-- ENDIF -->

if so, what needs to be modified in:

Code: Select all

        if ( !function_exists('group_memberships') )
        {
            include($phpbb_root_path . 'includes/functions_user.'.$phpEx);
        }
        $groups = group_memberships(false,$user->data['user_id']);
        foreach ($groups as $grouprec)
        {
            $template->assign_vars(array(
            'S_GROUP_' . $grouprec['group_id'] => true
            ));
        }


many thanks
User avatar
durangod
Registered User
Posts: 817
Joined: Tue Nov 03, 2009 1:26 pm
Location: USA East Texas
Name: Dave

Re: Forum Template User-defined permissions

Post by durangod »

ok just in case anyone is interested who may be confused on where to put the switch, here is what i did and it might help you understand this better.

now this is just what i did, you might want to do something different.. im just adding this because i just did this and i wanted to share to make it easier for you..


after you place the code in the functions php file.. which by the way that place your looking for to place that code is near the bottom of functions php lol... i should have started from the bottom up lol

now once thats is there... i went to the templates folder forumlist_body.html and at the very top of that file before anything else i put this

Code: Select all

<!-- switch for adult group members only, this will not display for non members -->
<!-- IF S_GROUP_8 -->Welcome back Afterdark Group Member. You may access the Afterdark Forum <a href="http://forum.xxxxxx.com/viewforum.php?f=29">Here</a>
<!-- ENDIF -->
then refresh your template from the acp... at the top of your forum list on the main page you will see that switch display if you are a member ... the way it works is that the message only displayes if in fact you are a member of that group.. everyone else just sees nothing there.

the address of course i got from just coping the url from the browser..

hope that helps someone.. thanks
Username is short for durango dave
User avatar
cprgolds
Registered User
Posts: 459
Joined: Thu Oct 11, 2007 5:49 am
Location: Portland, Oregon

Re: Forum Template User-defined permissions

Post by cprgolds »

Hi -- I am using the User Defined Permissions as shown in the early posts.

I set it up on a test board and it works fine.

I set it up on another board and I get the following warning:

Code: Select all

[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4509: Invalid argument supplied for foreach()

where line 4509 is:

foreach ($groups as $grouprec)
my whole block of added code is:

Code: Select all

//-- Custom Security by Groups
	if ( !function_exists('group_memberships') )
    {
        include($phpbb_root_path . 'includes/functions_user.'.$phpEx);
    }
    $groups = group_memberships(false,$user->data['user_id']);
    foreach ($groups as $grouprec)
    {
    $template->assign_vars(array('S_GROUP_' . $grouprec['group_id'] => true));
    }
Since this seems to work on one data set but not another, I am suspecting that there is something unexpected in the db.

The S_GROUP_N values appear to be working OK, I am just throwing off this message.

Any ideas??

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

Re: Forum Template User-defined permissions

Post by Brf »

That means that the user does not belong to any groups.
User avatar
cprgolds
Registered User
Posts: 459
Joined: Thu Oct 11, 2007 5:49 am
Location: Portland, Oregon

Re: Forum Template User-defined permissions

Post by cprgolds »

Thank you ever so much Brf... You were spot on.

It was my "Guest" User that was not present in the phpbb_user_group table.

For anyone else who runs into this, this SQL Query will find the culprit(s):

Code: Select all

SELECT phpbb_users.* FROM phpbb_users LEFT JOIN phpbb_user_group ON phpbb_users.user_id = phpbb_user_group.user_id WHERE phpbb_user_group.user_id IS NULL 
BuryGnome
Registered User
Posts: 10
Joined: Fri Jun 11, 2010 7:20 am

Re: Forum Template User-defined permissions

Post by BuryGnome »

Hello

Code: Select all

<!-- IF S_GROUP_N -->some stuff here<!-- ENDIF -->
I have a question: Is there a way to use couple of group premissions in one IF S_GROUP line?
User avatar
soumik
Registered User
Posts: 486
Joined: Tue Nov 06, 2007 7:27 pm

Re: Forum Template User-defined permissions

Post by soumik »

BuryGnome wrote:Hello

Code: Select all

<!-- IF S_GROUP_N -->some stuff here<!-- ENDIF --> 
I have a question: Is there a way to use couple of group premissions in one IF S_GROUP line?

Code: Select all

<!-- IF S_GROUP_X and S_GROUP_Y -->some stuff here<!-- ENDIF --> 
X and Y being group IDs of different groups.

Note: This shows "some stuff here" only if the user belngs to both X and Y groups. If you want to display "some stuff here" to users belnging to any of the groups, use this :

Code: Select all

<!-- IF S_GROUP_X || S_GROUP_Y -->some stuff here<!-- ENDIF --> 
Powered by chocolate
BuryGnome
Registered User
Posts: 10
Joined: Fri Jun 11, 2010 7:20 am

Re: Forum Template User-defined permissions

Post by BuryGnome »

So If i'm getting this right. I can use:

Code: Select all

<!-- IF S_GROUP_X || S_GROUP_Y -->some stuff here<!-- ENDIF --> 
and expand this line with || to more and more groups?
User avatar
soumik
Registered User
Posts: 486
Joined: Tue Nov 06, 2007 7:27 pm

Re: Forum Template User-defined permissions

Post by soumik »

BuryGnome wrote:So If i'm getting this right. I can use:

Code: Select all

<!-- IF S_GROUP_X || S_GROUP_Y -->some stuff here<!-- ENDIF --> 
and expand this line with || to more and more groups?
Yes.
Powered by chocolate
User avatar
Shturmfogell
Registered User
Posts: 159
Joined: Fri Oct 12, 2007 10:12 am
Location: Abkhazia

Re: Forum Template User-defined permissions

Post by Shturmfogell »

stevemaury wrote in this topic a tip to be able to use switches like <!-- IF S_GROUP_N --> and it did its job in posting_editor.html but when I am trying to use it in posting.php i cant make it work

i have a code like this $messagetemp .= ($boardlink1 && ($boardlink1 != 'http://')) ? "[spo_o]3445345[/spo_o][b]" . $u5 . "[/b] [url]" . $boardlink1 . "[/url][spo_cl]4564564[/spo_cl]\n" : '';

This bbcode: [spo_o]3445345[/spo_o] gives this html: <!-- IF S_GROUP_4 or S_GROUP_5 or S_GROUP_7 or S_GROUP_8 -->

and this one: [spo_cl]4564564[/spo_cl] gives: <!-- ENDIF -->

I suppose that a browser reads bbcode after reading groups IDs but I don't know how to make it right
User avatar
Brf
Support Team Member
Support Team Member
Posts: 53568
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}

Re: Forum Template User-defined permissions

Post by Brf »

Bbcodes are used in messages and template switches are used in templates. How would one "give" the other?
Neither are read by your webbrowser.
User avatar
Shturmfogell
Registered User
Posts: 159
Joined: Fri Oct 12, 2007 10:12 am
Location: Abkhazia

Re: Forum Template User-defined permissions

Post by Shturmfogell »

ok, so i understand that bbcode will not work in that moment but i really need to hide it somehow and writing new server-side working bbcode is not in my best :(
User avatar
Brf
Support Team Member
Support Team Member
Posts: 53568
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}

Re: Forum Template User-defined permissions

Post by Brf »

You are in the wrong topic. This topic is about hiding content in a template. You are trying to hide content in a post, which is a completely different thing.
amplifiedshock
Registered User
Posts: 51
Joined: Fri Jan 04, 2008 1:28 pm

Re: Forum Template User-defined permissions

Post by amplifiedshock »

I tried the above code and it works great, but:

It doesn't seem to work if a particular group is not set as the user's default. Any workaround?


i.e. <!-- IF not S_GROUP_5 -->some stuff here<!-- ENDIF -->
The user is in group id 3 and 5, however, their default is 3, so the above message still displays.
User avatar
Brf
Support Team Member
Support Team Member
Posts: 53568
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}

Re: Forum Template User-defined permissions

Post by Brf »

You are using the wrong code. The code that uses group_memberships() does not look at the user's default group.

Return to “[3.0.x] MOD Writers Discussion”