From 4daa44ed57ae656f31c7ac748f7808997a6344a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 21 Sep 2015 23:08:32 +0200 Subject: [PATCH] implements role declaration in activity close #610 @0h15 --- Resources/config/services.yml | 1 + Resources/translations/messages.fr.yml | 4 ++++ Security/Authorization/ActivityVoter.php | 14 +++++++++++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Resources/config/services.yml b/Resources/config/services.yml index 64e72f8f5..39ba42839 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -36,6 +36,7 @@ services: - "@chill.main.security.authorization.helper" tags: - { name: security.voter } + - { name: chill.role } chill.activity.timeline: diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml index 82172eca1..9fc56b438 100644 --- a/Resources/translations/messages.fr.yml +++ b/Resources/translations/messages.fr.yml @@ -32,3 +32,7 @@ Reset form: Remise à zéro du formulaire 'Success : activity updated!': Bravo ! L'activité a été mise à jour. 'The form is not valid. The activity has not been updated !': Le formulaire est invalide. L'activité n'a pas été mise à jour. +# CONTROLLER +CHILL_ACTIVITY_CREATE: Créer une activité +CHILL_ACTIVITY_UPDATE: Modifier une activité +CHILL_ACTIVITY_SEE: Voir une activité \ No newline at end of file diff --git a/Security/Authorization/ActivityVoter.php b/Security/Authorization/ActivityVoter.php index b6f82c1ed..0e9ffc2ed 100644 --- a/Security/Authorization/ActivityVoter.php +++ b/Security/Authorization/ActivityVoter.php @@ -21,13 +21,14 @@ namespace Chill\ActivityBundle\Security\Authorization; use Chill\MainBundle\Security\Authorization\AbstractChillVoter; use Chill\MainBundle\Security\Authorization\AuthorizationHelper; +use Chill\MainBundle\Security\ProvideRoleInterface; /** * * * @author Julien Fastré */ -class ActivityVoter extends AbstractChillVoter +class ActivityVoter extends AbstractChillVoter implements ProvideRoleInterface { const CREATE = 'CHILL_ACTIVITY_CREATE'; const SEE = 'CHILL_ACTIVITY_SEE'; @@ -63,4 +64,15 @@ class ActivityVoter extends AbstractChillVoter return $this->helper->userHasAccess($user, $report, $attribute); } + + public function getRoles() + { + return $this->getSupportedAttributes(); + } + + public function getRolesWithoutScope() + { + return array(); + } + }