Skip to content

Commit 93f828f

Browse files
Apply suggestions from code review
Co-authored-by: Ruth Cheesley <[email protected]>
1 parent e2f1a69 commit 93f828f

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

docs/design/displaying_elements_based_on_user_permissions.rst

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ Here's the basic syntax:
1818
<!-- Content to display if the user has the specified permission -->
1919
{% endif %}
2020
21-
In this structure, 'permission:string' represents the specific permission being checked for. Mautic uses a hierarchical permission system, in the format of 'bundle:level:permission'.
21+
In this structure, ``permission:string`` represents the specific permission being checked for. Mautic uses a hierarchical permission system, in the format of ``bundle:level:permission``.
2222

23-
Displaying a user invitation link as example
23+
Displaying a User invitation link as example
2424
--------------------------------------------
2525

26-
Let's examine a practical example of how to use this function to display a link for inviting new users to the platform. This link should only be visible to users who have the permission to create new user accounts.
26+
Let's examine a practical example of how to use this function to display a link for inviting new Users to the platform. This link should only be visible to Users who have the permission to create new User accounts.
2727

28-
In this example, we're using the securityIsGranted function to check if the current user has the 'user:users:create' permission. This permission string is structured to indicate that we're checking for the ability to create new users within the user management system.
28+
In this example, we're using the ``securityIsGranted`` function to check if the current User has the ``user:users:create`` permission. This permission string is structured to indicate that we're checking for the ability to create new Users within the User management system.
2929

3030
.. code-block:: twig
3131
@@ -38,9 +38,9 @@ In this example, we're using the securityIsGranted function to check if the curr
3838
</li>
3939
{% endif %}
4040
41-
If the current user has the user:users:create permission, the code inside the if block will be rendered, displaying the link to invite new users. The link is created using the path function, which generates a URL based on the specified route (mautic_user_action) and any additional parameters ({objectAction: 'new'}).
41+
If the current User has the ``user:users:create`` permission, the code inside the if block is rendered, displaying the link to invite new users. The path function creates the link, which generates a URL based on the specified route (``mautic_user_action```) and any additional parameters (``{objectAction: 'new'}``).
4242

43-
The 'mautic.user.profile.invite'|trans expression is used to translate the text "Invite your team" using Mautic's translation system. This ensures that the text is displayed in the appropriate language based on the user's locale settings.
43+
The ``'mautic.user.profile.invite'|trans`` expression is used to translate the text 'Invite your team' using Mautic's translation system. This ensures that the text is displayed in the appropriate language based on the user's locale settings.
4444

4545
This not only prevents unauthorized access but also keeps the interface clean and relevant for each user's role.
4646

@@ -51,26 +51,26 @@ Locating defined permissions
5151

5252
Mautic organizes its permissions on a per-bundle basis. Each bundle typically defines its own set of permissions in a dedicated PHP file. The standard location for these permission definitions is:
5353

54-
[BundleName]/Security/[BundleName]Permissions.php
54+
``[BundleName]/Security/[BundleName]Permissions.php``
5555

5656
For example:
5757

58-
- User permissions: UserBundle/Security/UserPermissions.php
59-
- Email permissions: EmailBundle/Security/EmailPermissions.php
60-
- SMS permissions: SmsBundle/Security/SmsPermissions.php
58+
- User permissions: ``UserBundle/Security/UserPermissions.php``
59+
- Email permissions: ``EmailBundle/Security/EmailPermissions.php``
60+
- SMS permissions: ``SmsBundle/Security/SmsPermissions.php``
6161

62-
These PHP files contain classes that extend AbstractPermissions and define the specific permissions available for that bundle. They usually include methods for building the permission matrix and checking individual permissions.
62+
These PHP files contain classes that extend ``AbstractPermissions`` and define the specific permissions available for that bundle. They usually include methods for building the permission matrix and checking individual permissions.
6363

6464
Examining permission files
6565
--------------------------
6666

6767
When opening one of these permission files, they'll typically find:
6868

69-
- A definePermissions method that outlines all available permissions for the bundle.
70-
- Constants defining permission levels (e.g., LEVEL_VIEW, LEVEL_EDIT, LEVEL_FULL).
71-
- Methods for checking specific permissions (e.g., canViewUsers, canEditEmails).
69+
- A ``definePermissions`` method that outlines all available permissions for the bundle.
70+
- Constants defining permission levels (for example, ``LEVEL_VIEW, LEVEL_EDIT, LEVEL_FULL``).
71+
- Methods for checking specific permissions (for example, ``canViewUsers``, ``canEditEmails``).
7272

73-
For example, in the UserPermissions.php file, the UserPermissions class defines the available permissions for the UserBundle using a more structured approach. Let's go through the important parts:
73+
For example, in the ``UserPermissions.php`` file, the ``UserPermissions`` class defines the available permissions for the ``UserBundle`` using a more structured approach. Let's go through the important parts:
7474

7575
.. code-block:: php
7676
@@ -86,16 +86,16 @@ For example, in the UserPermissions.php file, the UserPermissions class defines
8686
8787
In this example, the profile key represents the permission category, and the nested array defines the specific permission levels for actions like editing the username, email, position, name, and having full access to the user profile.
8888

89-
To use these permission keys with the securityIsGranted function in Twig templates, construct the appropriate permission string. The permission string follows the format: [bundle]:[level]:[permission].
89+
To use these permission keys with the ``securityIsGranted`` function in Twig templates, construct the appropriate permission string. The permission string follows the format: ``[bundle]:[level]:[permission]``.
9090

9191
Map the permission keys from the UserPermissions class to the corresponding permission strings:
9292

93-
- editusername => user:profile:editusername
94-
- editemail => user:profile:editemail
93+
- ``editusername`` => ``user:profile:editusername``
94+
- ``editemail`` => ``user:profile:editemail``
9595
- ``editposition`` => ``user:profile:editposition``
9696
- ``editname`` => ``user:profile:editname``
97-
- full => user:profile:full
97+
- ``full`` => ``user:profile:full``
9898

99-
In each if statement, the securityIsGranted function is used with the corresponding permission string. If the current user has the specified permission, the code inside the if block will be executed, displaying the relevant form fields for editing the user profile information.
99+
In each if statement, the ``securityIsGranted`` function is used with the corresponding permission string. If the current user has the specified permission, the code inside the if block will be executed, displaying the relevant form fields for editing the user profile information.
100100

101101
For more information, refer to the Security documentation.

0 commit comments

Comments
 (0)