diff --git a/docs/developers/roles.md b/docs/developers/roles.md index 434f43cd..773fdf06 100644 --- a/docs/developers/roles.md +++ b/docs/developers/roles.md @@ -116,6 +116,11 @@ if ($authorizer->isGranted('orga:see', $organization)) { if ($authorizer->isGrantedToUser($a_user, 'orga:see', $organization)) { // … } + +// Check if the current user is an agent +if ($authorizer->isAgent($organization)) { + // … +} ``` In templates: @@ -130,9 +135,14 @@ In templates: {% if is_granted_to_user(a_user, 'orga:manage', organization) %} Delete {% endif %} + +{# Check if the current user is an agent #} +{% if is_agent(organization) %} + Delete +{% endif %} ``` -You can check that a permission is given at least by one authorization: +You can check that a permission is given at least by one authorization by passing `any` instead of an organization: ```php $this->denyAccessUnlessGranted('orga:see', 'any'); diff --git a/templates/organizations/tickets/index.html.twig b/templates/organizations/tickets/index.html.twig index 53519735..7f4be08b 100644 --- a/templates/organizations/tickets/index.html.twig +++ b/templates/organizations/tickets/index.html.twig @@ -19,7 +19,7 @@ {% block title %}{{ title ~ ' – ' ~ organization.name }}{% endblock %} {% block sidebar %} - {% if is_granted('orga:see:tickets:all', 'any') %} + {% if is_agent('any') %} {{ include('tickets/_sidebar.html.twig', { current: view, countOwned: countOwned, @@ -30,7 +30,7 @@ {% block body %}
-
+
{{ organization.name }}

{{ title }}

diff --git a/templates/tickets/index.html.twig b/templates/tickets/index.html.twig index b09ec24d..02e0ce29 100644 --- a/templates/tickets/index.html.twig +++ b/templates/tickets/index.html.twig @@ -19,7 +19,7 @@ {% block title %}{{ title }}{% endblock %} {% block sidebar %} - {% if is_granted('orga:see:tickets:all', 'any') %} + {% if is_agent('any') %} {{ include('tickets/_sidebar.html.twig', { current: view, countOwned: countOwned, @@ -30,7 +30,7 @@ {% block body %}
-
+

{{ title }}