diff --git a/components/ILIAS/IndividualAssessment/classes/AccessControl/class.ilIndividualAssessmentAccessHandler.php b/components/ILIAS/IndividualAssessment/classes/AccessControl/class.ilIndividualAssessmentAccessHandler.php index 32907f1bdfe7..03684de05ec0 100755 --- a/components/ILIAS/IndividualAssessment/classes/AccessControl/class.ilIndividualAssessmentAccessHandler.php +++ b/components/ILIAS/IndividualAssessment/classes/AccessControl/class.ilIndividualAssessmentAccessHandler.php @@ -1,7 +1,5 @@ isSystemAdmin() || $this->handler->checkAccessOfUser($this->usr->getId(), $operation, '', $this->iass->getRefId(), 'iass'); + if($this->simulateMember()) { + return $this->checkMemberRoleForPermission($operation); + } else { + return $this->isSystemAdmin() || + $this->handler->checkAccessOfUser($this->usr->getId(), $operation, '', $this->iass->getRefId(), 'iass'); + } } public function checkRBACOrPositionAccessToObj(string $operation) @@ -78,6 +83,33 @@ public function checkRBACOrPositionAccessToObj(string $operation) throw new \LogicException("Unknown rbac/position-operation: $operation"); } + public function simulateMember(): bool + { + $settings = ilMemberViewSettings::getInstance(); + return $settings->isActive() && + $settings->getContainer() === $this->iass->getParentContainerIdByType($this->iass->getRefId(), ['crs']); + } + + protected function checkMemberRoleForPermission(string $operation): bool + { + $ref_id = $this->iass->getRefId(); + $roles = array_filter( + $this->review->getParentRoleIds($ref_id), + static fn(array $role): bool => str_starts_with($role['title'], 'il_crs_member_') + ); + if($roles === []) { + return false; + } + $role = array_shift($roles); + $active_ops = $this->review->getActiveOperationsOfRole($ref_id, $role['rol_id']); + foreach($active_ops as $op) { + if($this->review->getOperation($op)['operation'] === $operation) { + return true; + } + } + return false; + } + /** * @inheritdoc */ diff --git a/components/ILIAS/IndividualAssessment/classes/class.ilObjIndividualAssessment.php b/components/ILIAS/IndividualAssessment/classes/class.ilObjIndividualAssessment.php index 5b8aec9276d3..621898c5cd03 100755 --- a/components/ILIAS/IndividualAssessment/classes/class.ilObjIndividualAssessment.php +++ b/components/ILIAS/IndividualAssessment/classes/class.ilObjIndividualAssessment.php @@ -268,7 +268,7 @@ public function isActiveLP(): bool * @param int $id start at this id * @param string[] $types search for these strings * - * @return int the obj_id or 0 if root is reached + * @return int the ref_id or 0 if root is reached */ public function getParentContainerIdByType(int $id, array $types): int { diff --git a/components/ILIAS/IndividualAssessment/classes/class.ilObjIndividualAssessmentAccess.php b/components/ILIAS/IndividualAssessment/classes/class.ilObjIndividualAssessmentAccess.php index ff999233835a..56bb6a06856a 100755 --- a/components/ILIAS/IndividualAssessment/classes/class.ilObjIndividualAssessmentAccess.php +++ b/components/ILIAS/IndividualAssessment/classes/class.ilObjIndividualAssessmentAccess.php @@ -1,7 +1,5 @@ object->accessHandler()->simulateMember()) { + $cmd = 'view'; + } + $cmd .= 'Object'; $this->$cmd(); }