diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml
index 9dfaafe0c..f08d6aa05 100644
--- a/Resources/translations/messages.fr.yml
+++ b/Resources/translations/messages.fr.yml
@@ -8,7 +8,7 @@ Scope: Cercle
'Start date': 'Date de début'
'End date': "Date d'échéance"
'Warning date': "Date d'avertissement"
-'Warning interval': "Délai d'avertissement de la date d'échéance"
+'Warning interval': "Délai d'avertissement avant la date d'échéance"
'Unknown dates': 'Dates non spécifiées'
'N': ''
'Unit': ''
diff --git a/Resources/views/SingleTask/_list.html.twig b/Resources/views/SingleTask/_list.html.twig
index d0ee8d104..6d969bf3e 100644
--- a/Resources/views/SingleTask/_list.html.twig
+++ b/Resources/views/SingleTask/_list.html.twig
@@ -1,6 +1,6 @@
{% macro date_status(title, tasks, count, paginator, status, isSingleStatus, person, user) %}
{% if tasks|length > 0 %}
-
{{ title|trans }}
+ {{ title|trans }}
@@ -141,10 +141,10 @@
{% import _self as helper %}
- {{ 'Task list'|trans }}
+ {{ app.request.title|default('Task list')|trans }}
{% if false == app.request.query.boolean('hide_form', false) %}
- {{ 'Filter the tasks'|trans }}
+ {{ 'Filter the tasks'|trans }}
{{ form_start(form) }}
{{ form_row(form.user_id) }}
@@ -168,18 +168,32 @@
{% if tasks_count == 0 %}
{{ "There is no tasks."|trans }}
- {% if person is not null %}
-
- {{ 'Add a new task' | trans }}
-
+ {% if person is not null and is_granted('CHILL_TASK_TASK_CREATE', person) %}
+
{% endif %}
-
-
{% else %}
+
+ {{ 'Tasks'|trans }}
+
+ {% if person is not null and is_granted('CHILL_TASK_TASK_CREATE', person) %}
+
+ {% endif %}
{% if single_task_ended_tasks is defined %}
{{ helper.date_status('Tasks with expired deadline', single_task_ended_tasks, single_task_ended_count, single_task_ended_paginator, 'ended', isSingleStatus, person) }}
@@ -204,17 +218,11 @@
{% if isSingleStatus == false %}
-
- {% if person is not null %}
+ {% if person is not null and is_granted('CHILL_TASK_TASK_CREATE', person) %}
{{ 'Add a new task' | trans }}
{% endif %}
-
-
{% endif %}
diff --git a/Security/Authorization/TaskVoter.php b/Security/Authorization/TaskVoter.php
index 7de8fdb83..c28fcf942 100644
--- a/Security/Authorization/TaskVoter.php
+++ b/Security/Authorization/TaskVoter.php
@@ -27,6 +27,7 @@ use Psr\Log\LoggerInterface;
use Chill\MainBundle\Security\ProvideRoleHierarchyInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Chill\MainBundle\Entity\User;
+use Chill\PersonBundle\Entity\Person;
/**
*
@@ -77,8 +78,9 @@ class TaskVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterf
public function supports($attribute, $subject)
{
- return $subject instanceof AbstractTask
- && in_array($attribute, self::ROLES);
+ return ($subject instanceof AbstractTask && in_array($attribute, self::ROLES))
+ ||
+ ($subject instanceof Person && $attribute === self::CREATE);
}
/**
@@ -96,12 +98,18 @@ class TaskVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterf
return false;
}
- if ($subject->getPerson() === null) {
- throw new \LogicException("You should associate a person with task "
- . "in order to check autorizations");
+ if ($subject instanceof AbstractTask) {
+ if ($subject->getPerson() === null) {
+ throw new \LogicException("You should associate a person with task "
+ . "in order to check autorizations");
+ }
+
+ $person = $subject->getPerson();
+ } else {
+ $person = $subject;
}
- if (!$this->accessDecisionManager->decide($token, [PersonVoter::SEE], $subject->getPerson())) {
+ if (!$this->accessDecisionManager->decide($token, [PersonVoter::SEE], $person)) {
return false;
}