From 31aa50b4eaa0a3ba15ed84773a341937d38b3109 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sun, 20 Sep 2015 21:44:08 +0200 Subject: [PATCH] merging add_ui_permission into master MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit refs #573 Squashed commit of the following: commit 33635722c231a3a80518e0dc027911766a95cbfa Author: Julien Fastré Date: Sun Sep 20 21:42:37 2015 +0200 translation of roles commit 18d96fe59f836564ace5e6045fa87ac81da6b27b Author: Julien Fastré Date: Sun Sep 20 11:54:46 2015 +0200 remove admin menu for person bundle commit 2acd79930e28fda315d97df2c0ff8aae33ab489a Author: Julien Fastré Date: Fri Sep 18 21:05:00 2015 +0200 add logger to project commit 724d2fc8685fced0cf9da77e9e9730c5c57337ed Author: Julien Fastré Date: Mon Sep 14 00:50:01 2015 +0200 switch to role declaration in code commit 10f6219b277445b0dfeb51fa0b7566a28fdd41bf Author: Julien Fastré Date: Mon Aug 31 23:51:47 2015 +0200 declare role in parameter chill.available_roles --- .gitignore | 4 +++- Controller/AdminController.php | 24 ------------------------ DataFixtures/ORM/LoadPersonACL.php | 7 +++---- Resources/config/routing.yml | 10 ---------- Resources/config/services.yml | 1 + Resources/translations/messages.fr.yml | 5 +++++ Security/Authorization/PersonVoter.php | 14 +++++++++++++- Tests/Fixtures/App/app/AppKernel.php | 3 ++- composer.json | 4 ++-- 9 files changed, 29 insertions(+), 43 deletions(-) delete mode 100644 Controller/AdminController.php diff --git a/.gitignore b/.gitignore index 9fcdf9d28..f1b94a9ff 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,6 @@ parameters.yml *~ *.DS_Store *.sass-cache -Resources/node_modules/ \ No newline at end of file +Resources/node_modules/ +Tests/Fixtures/App/app/config/parameters.yml + diff --git a/Controller/AdminController.php b/Controller/AdminController.php deleted file mode 100644 index b0cb638a9..000000000 --- a/Controller/AdminController.php +++ /dev/null @@ -1,24 +0,0 @@ -forward('CLChillMainBundle:Admin:index', - array( - 'menu' => 'admin_person', - 'page_title' => 'menu.person.admin.index', - 'header_title' => 'menu.person.header_index' - ) - ); - } - -} diff --git a/DataFixtures/ORM/LoadPersonACL.php b/DataFixtures/ORM/LoadPersonACL.php index 1f4163deb..01cf0ade9 100644 --- a/DataFixtures/ORM/LoadPersonACL.php +++ b/DataFixtures/ORM/LoadPersonACL.php @@ -43,7 +43,6 @@ class LoadPersonACL extends AbstractFixture implements OrderedFixtureInterface { foreach (LoadPermissionsGroup::$refs as $permissionsGroupRef) { $permissionsGroup = $this->getReference($permissionsGroupRef); - $scope = $this->getReference('scope_all'); //create permission group switch ($permissionsGroup->getName()) { @@ -52,11 +51,11 @@ class LoadPersonACL extends AbstractFixture implements OrderedFixtureInterface printf("Adding CHILL_PERSON_UPDATE & CHILL_PERSON_CREATE to %s permission group \n", $permissionsGroup->getName()); $roleScopeUpdate = (new RoleScope()) ->setRole('CHILL_PERSON_UPDATE') - ->setScope($scope); + ->setScope(null); $permissionsGroup->addRoleScope($roleScopeUpdate); $roleScopeCreate = (new RoleScope()) ->setRole('CHILL_PERSON_CREATE') - ->setScope($scope); + ->setScope(null); $permissionsGroup->addRoleScope($roleScopeCreate); $manager->persist($roleScopeUpdate); $manager->persist($roleScopeCreate); @@ -65,7 +64,7 @@ class LoadPersonACL extends AbstractFixture implements OrderedFixtureInterface printf("Adding CHILL_PERSON_SEE to %s permission group \n", $permissionsGroup->getName()); $roleScopeSee = (new RoleScope()) ->setRole('CHILL_PERSON_SEE') - ->setScope($scope); + ->setScope(null); $permissionsGroup->addRoleScope($roleScopeSee); $manager->persist($roleScopeSee); break; diff --git a/Resources/config/routing.yml b/Resources/config/routing.yml index 3950eaa2f..91b481ea4 100644 --- a/Resources/config/routing.yml +++ b/Resources/config/routing.yml @@ -70,16 +70,6 @@ chill_person_accompanying_period_open: path: /{_locale}/person/{person_id}/accompanying-period/open defaults: { _controller: ChillPersonBundle:AccompanyingPeriod:open } -chill_person_admin: - path: /{_locale}/admin/person - defaults: { _controller: ChillPersonBundle:Admin:index } - options: - menus: - admin: - order: 100 - label: menu.person.admin.index - helper: menu.person.admin.helper - chill_person_export: path: /{_locale}/person/export/ defaults: { _controller: ChillPersonBundle:Person:export } diff --git a/Resources/config/services.yml b/Resources/config/services.yml index 9e22fc5a0..26d220c2f 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -47,3 +47,4 @@ services: - "@chill.main.security.authorization.helper" tags: - { name: security.voter } + - { name: chill.role } diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml index f7752152c..84919f5ef 100644 --- a/Resources/translations/messages.fr.yml +++ b/Resources/translations/messages.fr.yml @@ -72,3 +72,8 @@ Reset: 'Remise à zéro' #timeline 'An accompanying period is opened for %person% on %date%': Une période d'accompagnement a été ouverte le %date% pour %person% 'An accompanying period is closed for %person% on %date%': Une période d'accompagnement a été fermée le %date% pour %person% + +#roles +CHILL_PERSON_SEE: Voir les personnes +CHILL_PERSON_UPDATE: Modifier les personnes +CHILL_PERSON_CREATE: Ajouter des personnes diff --git a/Security/Authorization/PersonVoter.php b/Security/Authorization/PersonVoter.php index e373c34a8..d795c39cf 100644 --- a/Security/Authorization/PersonVoter.php +++ b/Security/Authorization/PersonVoter.php @@ -22,13 +22,14 @@ namespace Chill\PersonBundle\Security\Authorization; use Chill\MainBundle\Security\Authorization\AbstractChillVoter; use Chill\MainBundle\Entity\User; use Chill\MainBundle\Security\Authorization\AuthorizationHelper; +use Chill\MainBundle\Security\ProvideRoleInterface; /** * * * @author Julien Fastré */ -class PersonVoter extends AbstractChillVoter +class PersonVoter extends AbstractChillVoter implements ProvideRoleInterface { const CREATE = 'CHILL_PERSON_CREATE'; const UPDATE = 'CHILL_PERSON_UPDATE'; @@ -64,4 +65,15 @@ class PersonVoter extends AbstractChillVoter return $this->helper->userHasAccess($user, $person, $attribute); } + + public function getRoles() + { + return $this->getSupportedAttributes(); + } + + public function getRolesWithoutScope() + { + return $this->getSupportedAttributes(); + } + } diff --git a/Tests/Fixtures/App/app/AppKernel.php b/Tests/Fixtures/App/app/AppKernel.php index 23b95d3fa..29c257406 100644 --- a/Tests/Fixtures/App/app/AppKernel.php +++ b/Tests/Fixtures/App/app/AppKernel.php @@ -17,7 +17,8 @@ class AppKernel extends Kernel new Chill\PersonBundle\ChillPersonBundle(), new Chill\MainBundle\ChillMainBundle(), new \Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(), - new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle() + new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(), + new Symfony\Bundle\MonologBundle\MonologBundle(), #add here all the required bundle (some bundle are not required) ); } diff --git a/composer.json b/composer.json index 8001d1474..9f9850232 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "php": "~5.5", "twig/extensions": "~1.0", "symfony/assetic-bundle": "~2.3", - "symfony/monolog-bundle": "~2.4", + "symfony/monolog-bundle": "^2.7", "symfony/framework-bundle": "~2.7", "symfony/yaml": "~2.7", "symfony/symfony": "~2.7", @@ -27,7 +27,7 @@ "doctrine/orm": "~2.4", "doctrine/common": "~2.4", "doctrine/doctrine-bundle": "~1.2", - "chill-project/main": "dev-master@dev", + "chill-project/main": "dev-add_ui_permission as dev-master", "chill-project/custom-fields": "dev-master@dev", "doctrine/doctrine-fixtures-bundle": "~2.2", "champs-libres/composer-bundle-migration": "~1.0",