You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: development/extensions/tutorial_permissions.rst
+88-10
Original file line number
Diff line number
Diff line change
@@ -5,11 +5,13 @@ Tutorial: Permissions
5
5
Introduction
6
6
============
7
7
8
-
Adding new permissions in an extension is an easy three-step process:
8
+
The permission system in phpBB is used to control access to different parts of the software. It works by allowing administrators to assign certain permissions to user groups or individual users, which determine what actions they are able to perform.
9
9
10
10
1. `Create permissions`_ with a migration.
11
11
2. `Define permissions`_ with language keys.
12
12
3. `Wire up permissions`_ with events.
13
+
4. `Checking permissions`_ with PHP.
14
+
5. `Understanding Permissions`_ in phpBB.
13
15
14
16
Create permissions
15
17
==================
@@ -28,7 +30,7 @@ assign your permissions to if desired.
28
30
Permissions must first be created in a migration using the :doc:`../migrations/tools/permission`.
29
31
It helps with adding, removing, setting, and unsetting permissions and adding
30
32
or removing permission roles. For example, to create a new User permission
31
-
``u_foo_bar`` and set it to "yes" for the Registered Users group and
33
+
``u_foo_bar`` and set it to ``YES`` for the Registered Users group and
32
34
the Standard User Role:
33
35
34
36
.. code-block:: php
@@ -66,17 +68,93 @@ add your new permissions to phpBB's permission data array:
Note how the ``permissions`` event variable is first copied by assigning
76
-
it to a local variable, then modified, and then copied back. This is because the event
77
-
variables are overloaded, which is a limitation in PHP. For example, this shortcut
78
-
will not work:
75
+
In order to support phpBB 3.2.1 or earlier versions, you can not use the ``update_subarray()`` method, and must instead use the following older style of code:
79
76
80
77
.. code-block:: php
81
78
79
+
# Wiring permissions the correct way for phpBB 3.1.0 - 3.2.1
When checking permissions, it's also important to keep in mind whether the global or local permissions should be checked.
122
+
If ``acl_get`` is called without a forum id, the global permissions will be used. Instead, passing a forum id will also
123
+
check the local permissions which can then potentially override a ``NO`` with a ``YES``.
124
+
After checking all user, group, forum, and global permissions, the return permission is always either ``YES`` or ``NO``,
125
+
``NEVER`` is only used to enforce a ``NO``.
126
+
127
+
Understanding Permissions
128
+
=========================
129
+
130
+
Permissions in phpBB control what actions users are allowed to perform on the forum, such as creating a new topic, replying to a post, or editing a user’s profile. Each permission is assigned a value of ``YES``, ``NO``, or ``NEVER``.
131
+
132
+
- ``YES`` means that the user or group is allowed to perform the action.
133
+
- ``NO`` means that the user or group is not allowed to perform the action, but it can be overruled by a ``YES`` from a group or role they are assigned to.
134
+
- ``NEVER`` means that the user or group is not allowed to perform the action and cannot be overruled by a ``YES`` from a group or role they are assigned to.
135
+
136
+
When a user requests to perform an action, phpBB combines all the permissions assigned to the user through their groups, roles, and direct permission assignments. If any permission is set to ``NEVER``, it overrides all other permissions and denies the user access to that action. If a permission is set to ``NO``, it can be overridden by a ``YES`` permission from another group or role.
137
+
138
+
Permission Types
139
+
----------------
140
+
141
+
There are four types of permissions in phpBB:
142
+
143
+
- ``a_*`` Administrator: These permissions are applied to users who are assigned administrator roles.
144
+
- ``f_*`` Forum: These permissions are applied to individual forums and can be set for each user group or individual user.
145
+
- ``m_*`` Moderator: These permissions are applied to users who are assigned moderator roles for specific forums.
146
+
- ``u_*`` User: These permissions are applied to individual users and override the permissions set for their user group.
147
+
148
+
Local and Global Permissions
149
+
----------------------------
150
+
151
+
Permissions can be set to apply locally or globally. Local permissions are specific to a single forum, while global permissions apply to the entire board. By default, forum permissions are set to local. Administrator and User permissions are typically set to global.
152
+
153
+
Permission options can also be set to apply both locally and globally, which is typical for Moderator permissions. This allows some users to be granted the permission on a single forum, while others might be granted the permission board-wide.
154
+
155
+
Roles
156
+
-----
157
+
158
+
Roles are a predefined set of permission options that can be applied to users or groups. When the permission options of a role are changed, the users or groups assigned that role are automatically updated.
159
+
160
+
The effective permission for any option is determined by a combination of the user's group membership, assigned roles, and direct permission assignments. In some cases, opposing permissions may exist, which can lead to unexpected results. It's important to carefully consider the permission settings to ensure that users are granted the appropriate level of access on the forum.
0 commit comments