Creating new permission groups

Discussion forum for Extension Writers regarding Extension Development.
User avatar
Kailey
Community Team Leader
Community Team Leader
Posts: 3948
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Snay

Creating new permission groups

Post by Kailey »

I've looked through the docs, code and searched, but can't seem to find the answer I'm looking for.

It's common knowledge that you can check if a user has any moderator permissions set by querying $auth->acl_get('m_'). What I'd like to do is create my own group of permissions to query (m_kb_ for example). I'm assuming I would need to create the m_kb_ permission in my migration, but after that, how can I check if a user has any m_kb_ permissions? I know I could probably use $auth->acl_gets() and list each permission, but that seems excessive.
Kailey Snay - Community Team Leader
Knowledge Base | Documentation | Community rules
If you have any questions about the rules/customs of this website, feel free to send me a PM.

My little corner of the world | Administrator @ phpBB Modders
rxu
Extensions Development Team
Posts: 3954
Joined: Wed Oct 25, 2006 12:46 pm
Location: Siberia, Russian Federation

Re: Creating new permission groups

Post by rxu »

As far as adding permission types is not documented, I can just assume from the core code.
I guess that multi-underscore like m_kb_ won't work because the code looks for the first occurrence of _ so it will be treated as m_ permission type.
Also, I guess it'd require adding permission type itself too, like ['permission.add', ['mkb_']] because all built-in permission types are in phpbb_acl_options too.
Then $auth->acl_get('mkb_') presumably should work but it needs testing 1st.
User avatar
Kailey
Community Team Leader
Community Team Leader
Posts: 3948
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Snay

Re: Creating new permission groups

Post by Kailey »

rxu wrote: Wed Aug 07, 2024 3:00 am I can just assume from the core code.
I guess that multi-underscore like m_kb_ won't work because the code looks for the first occurrence of _
Interesting. Would you happen to know where at in the code this is handled?
Kailey Snay - Community Team Leader
Knowledge Base | Documentation | Community rules
If you have any questions about the rules/customs of this website, feel free to send me a PM.

My little corner of the world | Administrator @ phpBB Modders
rxu
Extensions Development Team
Posts: 3954
Joined: Wed Oct 25, 2006 12:46 pm
Location: Siberia, Russian Federation

Re: Creating new permission groups

Post by rxu »

User avatar
Kailey
Community Team Leader
Community Team Leader
Posts: 3948
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Snay

Re: Creating new permission groups

Post by Kailey »

Nice catch! Thanks for the information. I'll have to re-think how I want to proceed.
Kailey Snay - Community Team Leader
Knowledge Base | Documentation | Community rules
If you have any questions about the rules/customs of this website, feel free to send me a PM.

My little corner of the world | Administrator @ phpBB Modders

Return to “Extension Writers Discussion”