FEATURE [voter][confidential] voter adapted. repository changes left to do

This commit is contained in:
2023-02-10 19:15:09 +01:00
committed by Julien Fastré
parent b3d993165d
commit a7dbdc2b9d
3 changed files with 11 additions and 19 deletions

View File

@@ -42,11 +42,6 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH
self::RE_OPEN_COURSE,
];
/**
* Give the ability to see all confidential courses.
*/
public const CONFIDENTIAL_CRUD = 'CHILL_PERSON_ACCOMPANYING_PERIOD_CRUD_CONFIDENTIAL';
public const CREATE = 'CHILL_PERSON_ACCOMPANYING_PERIOD_CREATE';
/**
@@ -110,7 +105,7 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH
/**
* Right to see confidential period even if not referrer
*/
public const SEE_CONFIDENTIAL = 'CHILL_PERSON_ACCOMPANYING_PERIOD_SEE_CONFIDENTIAL';
public const SEE_CONFIDENTIAL_ALL = 'CHILL_PERSON_ACCOMPANYING_PERIOD_SEE_CONFIDENTIAL';
private Security $security;
@@ -136,7 +131,6 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH
return [
self::SEE,
self::SEE_DETAILS,
self::CONFIDENTIAL_CRUD,
self::CREATE,
self::EDIT,
self::DELETE,
@@ -154,7 +148,7 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH
public function getRolesWithoutScope(): array
{
return [self::REASSIGN_BULK];
return [];
}
protected function supports($attribute, $subject)
@@ -221,14 +215,10 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH
// if confidential, only the referent can see it
if ($subject->isConfidential()) {
if ($this->voterHelper->voteOnAttribute(self::CONFIDENTIAL_CRUD, $subject, $token)) {
if ($this->voterHelper->voteOnAttribute(self::SEE_CONFIDENTIAL_ALL, $subject, $token)) {
return true;
}
/* if ($this->voterHelper->voteOnAttribute(self::REASSIGN_BULK, null, $token)) {
return true;
}*/
return $token->getUser() === $subject->getUser();
}
}