add specific role for LIST and STAT

This commit is contained in:
Julien Fastré 2017-04-20 16:27:06 +02:00
parent 1bc93af148
commit be2edec605
5 changed files with 14 additions and 4 deletions

View File

@ -24,6 +24,7 @@ use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Chill\MainBundle\DataFixtures\ORM\LoadPermissionsGroup;
use Chill\MainBundle\Entity\RoleScope;
use Chill\PersonBundle\Security\Authorization\PersonVoter;
/**
* Add a role CHILL_PERSON_UPDATE & CHILL_PERSON_CREATE for all groups except administrative,
@ -57,6 +58,14 @@ class LoadPersonACL extends AbstractFixture implements OrderedFixtureInterface
->setRole('CHILL_PERSON_CREATE')
->setScope(null);
$permissionsGroup->addRoleScope($roleScopeCreate);
$roleScopeList = (new RoleScope())
->setRole(PersonVoter::LISTS)
->setScope(null);
$permissionsGroup->addRoleScope($roleScopeList);
$roleScopeStats = (new RoleScope())
->setRole(PersonVoter::STATS)
->setScope(null);
$permissionsGroup->addRoleScope($roleScopeStats);
$manager->persist($roleScopeUpdate);
$manager->persist($roleScopeCreate);
break;

View File

@ -160,8 +160,7 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
$container->prependExtensionConfig('security', array(
'role_hierarchy' => array(
'CHILL_PERSON_UPDATE' => array('CHILL_PERSON_SEE'),
'CHILL_PERSON_CREATE' => array('CHILL_PERSON_SEE'),
'CHILL_PERSON_SEE' => array(PersonVoter::STATS)
'CHILL_PERSON_CREATE' => array('CHILL_PERSON_SEE')
)
));
}

View File

@ -421,7 +421,7 @@ class ListPerson implements ListInterface, ExportElementValidatedInterface
*/
public function requiredRole()
{
return new Role(PersonVoter::STATS);
return new Role(PersonVoter::LISTS);
}
/**

View File

@ -141,6 +141,7 @@ CHILL_PERSON_SEE: Voir les personnes
CHILL_PERSON_UPDATE: Modifier les personnes
CHILL_PERSON_CREATE: Ajouter des personnes
CHILL_PERSON_STATS: Statistiques sur les personnes
CHILL_PERSON_LISTS: Liste des personnes
#period
Period closed!: Période clôturée!

View File

@ -35,6 +35,7 @@ class PersonVoter extends AbstractChillVoter implements ProvideRoleHierarchyInte
const UPDATE = 'CHILL_PERSON_UPDATE';
const SEE = 'CHILL_PERSON_SEE';
const STATS = 'CHILL_PERSON_STATS';
const LISTS = 'CHILL_PERSON_LISTS';
/**
*
@ -49,7 +50,7 @@ class PersonVoter extends AbstractChillVoter implements ProvideRoleHierarchyInte
protected function getSupportedAttributes()
{
return array(self::CREATE, self::UPDATE, self::SEE, self::STATS);
return array(self::CREATE, self::UPDATE, self::SEE, self::STATS, self::LISTS);
}
protected function getSupportedClasses()