Help with adding an extra group permission

Extensions, styles and support for everything else about phpBB
Gary
Posts: 30
Joined: 24 Sep 2018, 22:28

Help with adding an extra group permission

Post by Gary » 02 Jun 2020, 19:23

I know how to add permissions in templates easy. But I'm using a HIDE mod that adds a new BBCODE with an XSL file that lists this below in the BBCODE.

Code: Select all

<xsl:choose>
	<xsl:when test="$S_USER_LOGGED_IN and not($S_IS_BOT)">
		<div>
			<xsl:attribute name="class">
					hidden-content
			</xsl:attribute>
			<div style="color: #4C5D77; font-weight: bold; margin-bottom: 5px;">{L_HIDDEN_CONTENT_TITLE}</div>{TEXT}
		</div>
	</xsl:when>
	<xsl:otherwise>
		<div>
			<xsl:attribute name="class">
					hidden-content-error
			</xsl:attribute>
			{L_HIDDEN_CONTENT_EXPLAIN}
		</div>
	</xsl:otherwise>
</xsl:choose>
You can see it adds permissions a little different from how you would write them in a template.

Code: Select all

<xsl:when test="$S_USER_LOGGED_IN and not($S_IS_BOT)">
Does anyone know how I can also add a Group 17 to be blocked also in that permission (which I use for a restricted group).

But keeping in mind they would be in two groups (members group and restricted group), and not setting the restricted group as their "main group". Members group still remains set as their main group - but they get restricted because the restricted group uses some never permissions with it.

So the permission added extra in the code has to cover if a person is stuck in group 17 (not set as their main group). That it will still work

User avatar
kasimi
mChat developer
Posts: 1079
Joined: 06 Oct 2016, 09:56
Location: Germany

Re: Help with adding an extra group permission

Post by kasimi » 02 Jun 2020, 20:26

By default phpBB only fetches the user's default group from the database. You will need to write PHP code that fetches all user groups on the pages where your BBCode is rendered, assign them to the template and then add your check in the XSL.

Gary
Posts: 30
Joined: 24 Sep 2018, 22:28

Re: Help with adding an extra group permission

Post by Gary » 02 Jun 2020, 20:35

Well I already do use this on my site. In functions.php I added this extra line so you can add group permissions in templates

Code: Select all

'S_USERGROUP'           => $user->data['group_id'],
So I can use this permission in templates now

Code: Select all

<!-- IF S_USERGROUP eq 4 or S_USERGROUP eq 5 or S_USERGROUP eq 12 or S_USERGROUP eq 13 -->
So if you're saying what I think you mean, my site already does have this added to work for groups. I just don't know if that means adding group permissions in that XSL file would work also based me already doing that on my site?
Last edited by Gary on 02 Jun 2020, 20:42, edited 1 time in total.

User avatar
kasimi
mChat developer
Posts: 1079
Joined: 06 Oct 2016, 09:56
Location: Germany

Re: Help with adding an extra group permission

Post by kasimi » 02 Jun 2020, 20:42

$user->data['group_id'] is the user's default group, it's a single integer. You'll want to fetch all groups the user is in by using the group_memberships() function.

Gary
Posts: 30
Joined: 24 Sep 2018, 22:28

Re: Help with adding an extra group permission

Post by Gary » 02 Jun 2020, 20:49

it works for what I do with it though. I get what you mean, that it isn't counting all the groups a user may be in. But that's fine because the permission is used to only show certain stuff to those groups listed (staff groups) that have the staff group set as main group, which I don't want a members group to see that they are in by default also.

But guess what your saying. With that permission used for groups, then I would need to set the Restricted Group as the main group if that 17 ID "restricted" group is going to be blocked. Which is different from how I said it in the first post. But that's okay, I can always set the restricted group as main group if it would work that way
Last edited by Gary on 02 Jun 2020, 20:52, edited 1 time in total.

User avatar
kasimi
mChat developer
Posts: 1079
Joined: 06 Oct 2016, 09:56
Location: Germany

Re: Help with adding an extra group permission

Post by kasimi » 02 Jun 2020, 20:52

Then I don't see what the problem is. Where are you stuck?

Gary
Posts: 30
Joined: 24 Sep 2018, 22:28

Re: Help with adding an extra group permission

Post by Gary » 02 Jun 2020, 20:54

I don't know how to change the permissions in this code below that list guests and bot to also included group 17

Code: Select all

<xsl:when test="$S_USER_LOGGED_IN and not($S_IS_BOT)">

User avatar
kasimi
mChat developer
Posts: 1079
Joined: 06 Oct 2016, 09:56
Location: Germany

Re: Help with adding an extra group permission

Post by kasimi » 02 Jun 2020, 20:57

Code: Select all

<xsl:when test="$S_USERGROUP != '17' and $S_USER_LOGGED_IN and not($S_IS_BOT)">

Gary
Posts: 30
Joined: 24 Sep 2018, 22:28

Re: Help with adding an extra group permission

Post by Gary » 02 Jun 2020, 20:58

Thanks for that Kasimi. I will test it out now

Added in 5 minutes 56 seconds:
No, that has not worked.

User avatar
kasimi
mChat developer
Posts: 1079
Joined: 06 Oct 2016, 09:56
Location: Germany

Re: Help with adding an extra group permission

Post by kasimi » 02 Jun 2020, 21:10

Try this:

Code: Select all

<xsl:when test="not($S_USERGROUP = '17') and $S_USER_LOGGED_IN and not($S_IS_BOT)">

Who is online

Users browsing this forum: CCBot [Bot] and 0 guests