mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
fix some authorization check in menu
This commit is contained in:
@@ -34,12 +34,23 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH
|
||||
self::FULL,
|
||||
self::TOGGLE_CONFIDENTIAL_ALL,
|
||||
self::TOGGLE_INTENSITY,
|
||||
self::RE_OPEN_COURSE,
|
||||
];
|
||||
|
||||
public const CREATE = 'CHILL_PERSON_ACCOMPANYING_PERIOD_CREATE';
|
||||
|
||||
/**
|
||||
* role to DELETE the course
|
||||
*
|
||||
* Will be true only for the creator, and if the course is still at DRAFT step.
|
||||
*/
|
||||
public const DELETE = 'CHILL_PERSON_ACCOMPANYING_PERIOD_DELETE';
|
||||
|
||||
/**
|
||||
* role to EDIT the course.
|
||||
*
|
||||
* If the course is closed, it will be always false.
|
||||
*/
|
||||
public const EDIT = 'CHILL_PERSON_ACCOMPANYING_PERIOD_UPDATE';
|
||||
|
||||
/**
|
||||
@@ -56,6 +67,14 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH
|
||||
*/
|
||||
public const SEE_DETAILS = 'CHILL_PERSON_ACCOMPANYING_PERIOD_SEE_DETAILS';
|
||||
|
||||
/**
|
||||
* Reopen a closed course.
|
||||
*
|
||||
* This forward to the EDIT role, without taking into account that the course
|
||||
* is closed
|
||||
*/
|
||||
public const RE_OPEN_COURSE = 'CHILL_PERSON_ACCOMPANYING_PERIOD_REOPEN';
|
||||
|
||||
public const TOGGLE_CONFIDENTIAL = 'CHILL_PERSON_ACCOMPANYING_PERIOD_TOGGLE_CONFIDENTIAL';
|
||||
|
||||
/**
|
||||
@@ -116,6 +135,10 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH
|
||||
if (in_array($attribute, [self::EDIT, self::DELETE], true)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (self::RE_OPEN_COURSE === $attribute) {
|
||||
return $this->voterHelper->voteOnAttribute(self::EDIT, $subject, $token);
|
||||
}
|
||||
}
|
||||
|
||||
if (AccompanyingPeriod::STEP_DRAFT === $subject->getStep()) {
|
||||
|
Reference in New Issue
Block a user