+ */
+class SectionMenuBuilder implements LocalMenuBuilderInterface
+{
+ /**
+ *
+ * @var AuthorizationCheckerInterface
+ */
+ protected $authorizationChecker;
+
+ public function __construct(AuthorizationCheckerInterface $authorizationChecker)
+ {
+ $this->authorizationChecker = $authorizationChecker;
+ }
+
+
+ public function buildMenu($menuId, MenuItem $menu, array $parameters)
+ {
+ if ($this->authorizationChecker->isGranted(PersonVoter::CREATE)) {
+ $menu->addChild('Add a person', [
+ 'route' => 'chill_person_new'
+ ])
+ ->setExtras([
+ 'order' => 10,
+ 'icons' => [ 'plus' ]
+ ]);
+ }
+ }
+
+ public static function getMenuIds(): array
+ {
+ return [ 'section' ];
+ }
+}
diff --git a/Resources/config/routing.yml b/Resources/config/routing.yml
index 6792ca184..56244cae3 100644
--- a/Resources/config/routing.yml
+++ b/Resources/config/routing.yml
@@ -18,12 +18,6 @@ chill_person_general_update:
chill_person_new:
path: /{_locale}/person/new
defaults: {_controller: ChillPersonBundle:Person:new }
- options:
- menus:
- section:
- order: 10
- label: Add a person
- icons: [plus]
chill_person_review:
path: /{_locale}/person/review
diff --git a/Resources/config/services/menu.yml b/Resources/config/services/menu.yml
new file mode 100644
index 000000000..09b24d86b
--- /dev/null
+++ b/Resources/config/services/menu.yml
@@ -0,0 +1,6 @@
+services:
+ Chill\PersonBundle\Menu\SectionMenuBuilder:
+ arguments:
+ $authorizationChecker: '@Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface'
+ tags:
+ - { name: 'chill.menu_builder' }
diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml
index 59ab7e5bf..65b7cd632 100644
--- a/Resources/translations/messages.fr.yml
+++ b/Resources/translations/messages.fr.yml
@@ -51,6 +51,8 @@ man: Homme
woman: Femme
Man: Homme
Woman: Femme
+both: Indéterminé
+Both: Indéterminé
Divorced: Divorcé(e)
Separated: Séparé(e)
Widow: Veuf(ve)
@@ -141,6 +143,7 @@ Add an address: Ajouter une adresse
Back to the person details: Retour aux détails de la personne
#timeline
+Timeline: Historique
Closing the accompanying period: Fermeture de la période d'accompagnement
Opening the accompanying period: Ouverture d'une période d'accompagnement
diff --git a/Resources/views/Person/create_review.html.twig b/Resources/views/Person/create_review.html.twig
index eed4d57b2..22e51ae27 100644
--- a/Resources/views/Person/create_review.html.twig
+++ b/Resources/views/Person/create_review.html.twig
@@ -51,7 +51,7 @@
{% endspaceless %}
- {{ person.birthdate|localizeddate('long', 'none', app.request.locale) }} |
+ {% if person.birthdate is not null %}{{ person.birthdate|localizeddate('long', 'none', app.request.locale) }}{% else %} {% endif %} |
{% if person.nationality is not null %}{{ person.nationality.name|localize_translatable_string }}{% else %}{{ 'Without nationality'|trans }}{% endif %}
|
diff --git a/Resources/views/Person/list.html.twig b/Resources/views/Person/list.html.twig
index 4d7288d9a..31b80f477 100644
--- a/Resources/views/Person/list.html.twig
+++ b/Resources/views/Person/list.html.twig
@@ -64,11 +64,13 @@
+ {% if is_granted('CHILL_PERSON_CREATE') %}
-
{{ 'Add a person'|trans }}
+ {% endif %}
-
{{ 'Advanced search'|trans }}
diff --git a/Resources/views/Widget/homepage_add_a_person.html.twig b/Resources/views/Widget/homepage_add_a_person.html.twig
index d328da8e1..3849974c4 100644
--- a/Resources/views/Widget/homepage_add_a_person.html.twig
+++ b/Resources/views/Widget/homepage_add_a_person.html.twig
@@ -1,3 +1,4 @@
+{% if is_granted('CHILL_PERSON_CREATE') %}
-
+{% endif %}
diff --git a/Resources/views/layout.html.twig b/Resources/views/layout.html.twig
index 3a9b6aae5..0d6bd372e 100644
--- a/Resources/views/layout.html.twig
+++ b/Resources/views/layout.html.twig
@@ -45,7 +45,9 @@
@@ -105,7 +107,7 @@
{% block vertical_menu_content %}
{{ chill_menu('person', {
'layout': 'ChillPersonBundle::menu.html.twig',
- 'args' : {'person_id': person.id },
+ 'args' : {'person_id': person.id, 'person': person },
'activeRouteKey': activeRouteKey
}) }}
diff --git a/Resources/views/menu.html.twig b/Resources/views/menu.html.twig
index 234beca3b..3c5968b25 100644
--- a/Resources/views/menu.html.twig
+++ b/Resources/views/menu.html.twig
@@ -15,13 +15,9 @@
* along with this program. If not, see .
#}
\ No newline at end of file
diff --git a/Search/SimilarPersonMatcher.php b/Search/SimilarPersonMatcher.php
index 7d672d4df..2667f061f 100644
--- a/Search/SimilarPersonMatcher.php
+++ b/Search/SimilarPersonMatcher.php
@@ -70,10 +70,12 @@ class SimilarPersonMatcher
);
$dql = 'SELECT p from ChillPersonBundle:Person p WHERE'
- . ' UNACCENT(LOWER(p.firstName)) LIKE UNACCENT(LOWER(:firstName))'
- . ' OR UNACCENT(LOWER(p.lastName)) LIKE UNACCENT(LOWER(:lastName))'
- . ' OR UNACCENT(LOWER(p.firstName)) LIKE UNACCENT(LOWER(:lastName))'
- . ' OR UNACCENT(LOWER(p.lastName)) LIKE UNACCENT(LOWER(:firstName))'
+ . ' ('
+ . ' UNACCENT(LOWER(p.firstName)) LIKE UNACCENT(LOWER(:firstName)) '
+ . ' OR UNACCENT(LOWER(p.lastName)) LIKE UNACCENT(LOWER(:lastName)) '
+ . ' OR UNACCENT(LOWER(p.firstName)) LIKE UNACCENT(LOWER(:lastName)) '
+ . ' OR UNACCENT(LOWER(p.lastName)) LIKE UNACCENT(LOWER(:firstName)) '
+ . ' ) '
. ' AND p.center IN (:centers)';
$query =
diff --git a/Security/Authorization/PersonVoter.php b/Security/Authorization/PersonVoter.php
index 9b4899c65..1d3229567 100644
--- a/Security/Authorization/PersonVoter.php
+++ b/Security/Authorization/PersonVoter.php
@@ -26,6 +26,7 @@ use Chill\MainBundle\Security\ProvideRoleHierarchyInterface;
use Chill\PersonBundle\Entity\Person;
use Chill\MainBundle\Entity\Center;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
+use Symfony\Component\Security\Core\Role\Role;
/**
*
@@ -61,6 +62,8 @@ class PersonVoter extends AbstractChillVoter implements ProvideRoleHierarchyInte
return \in_array($attribute, [
self::STATS, self::LISTS
]);
+ } elseif ($subject === null) {
+ return $attribute === self::CREATE;
} else {
return false;
}
@@ -72,6 +75,13 @@ class PersonVoter extends AbstractChillVoter implements ProvideRoleHierarchyInte
return false;
}
+ if ($subject === null) {
+ $centers = $this->helper->getReachableCenters($token->getUser(),
+ new Role($attribute));
+
+ return count($centers) > 0;
+ }
+
return $this->helper->userHasAccess($token->getUser(), $subject, $attribute);
}