Skip to content

Commit

Permalink
imp: Display tickets views if user is an agent
Browse files Browse the repository at this point in the history
Before, an agent without the `orga:see:tickets:all` permission would not
see the tickets views. I realized then that an agent without this
permission is a normal case in certain situations.
  • Loading branch information
marien-probesys committed Mar 14, 2024
1 parent f8f477d commit 1c83b30
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
12 changes: 11 additions & 1 deletion docs/developers/roles.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -130,9 +135,14 @@ In templates:
{% if is_granted_to_user(a_user, 'orga:manage', organization) %}
<a href="...">Delete</a>
{% endif %}
{# Check if the current user is an agent #}
{% if is_agent(organization) %}
<a href="...">Delete</a>
{% 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');
Expand Down
4 changes: 2 additions & 2 deletions templates/organizations/tickets/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -30,7 +30,7 @@

{% block body %}
<main class="layout__body">
<div class="flow wrapper wrapper--large {{ not is_granted('orga:see:tickets:all', 'any') ? 'wrapper--center' }}">
<div class="flow wrapper wrapper--large {{ not is_agent('any') ? 'wrapper--center' }}">
<div class="layout__breadcrumb">
<a href="{{ path('organization', { uid: organization.uid }) }}">{{ organization.name }}</a>
<h1>{{ title }}</h1>
Expand Down
4 changes: 2 additions & 2 deletions templates/tickets/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -30,7 +30,7 @@

{% block body %}
<main class="layout__body">
<div class="flow wrapper wrapper--large {{ not is_granted('orga:see:tickets:all', 'any') ? 'wrapper--center' }}">
<div class="flow wrapper wrapper--large {{ not is_agent('any') ? 'wrapper--center' }}">
<div class="layout__breadcrumb">
<h1>{{ title }}</h1>
</div>
Expand Down

0 comments on commit 1c83b30

Please sign in to comment.