19 declare(strict_types=1);
51 $this->db = $DIC[
'ilDB'];
52 $this->
lng = $DIC[
'lng'];
54 $this->participant_repository = TestDIC::dic()[
'participant.repository'];
55 $this->
access = $DIC->access();
56 $this->main_settings_repository = TestDIC::dic()[
'settings.main.repository'];
153 if ($this->
getAccess()->checkRbacOrPositionPermissionAccess(
154 'read_learning_progress',
167 $participantData->setActiveIdsFilter([$active_id]);
168 $participantData->setParticipantAccessFilter($access_filter);
169 $participantData->load($test_id);
171 return in_array($active_id, $participantData->getActiveIds());
176 $access_filter = $this->participant_access_filter->getAccessResultsUserFilter($this->
getRefId());
182 $access_filter = $this->participant_access_filter->getScoreParticipantsUserFilter($this->
getRefId());
189 $access_settings = $this->main_settings_repository->getForObjFi($obj_id)
190 ->getAccessSettings();
192 return ParticipantAccess::BROKEN_TEST;
195 $participant = $this->participant_repository->getParticipantByUserId(
202 if ($access_settings->getFixedParticipants()
203 && ($participant === null || !$participant->isInvitedParticipant())) {
204 return ParticipantAccess::NOT_INVITED;
210 if ($allowed_individual ===
false) {
211 return ParticipantAccess::INDIVIDUAL_CLIENT_IP_MISMATCH;
215 if ($allowed_individual ===
true 216 || !$access_settings->isIpRangeEnabled()) {
217 return ParticipantAccess::ALLOWED;
221 return ParticipantAccess::TEST_LEVEL_CLIENT_IP_MISMATCH;
224 return ParticipantAccess::ALLOWED;
234 if ($range_start === null && $range_end === null) {
238 if ($this->
isIpTypeOf(FILTER_FLAG_IPV4, $ip, $range_start, $range_end)) {
242 if ($this->
isIpTypeOf(FILTER_FLAG_IPV6, $ip, $range_start, $range_end)) {
260 if ($this->
isIpTypeOf(FILTER_FLAG_IPV4, $ip, $range_start, $range_end)) {
264 if ($this->
isIpTypeOf(FILTER_FLAG_IPV6, $ip, $range_start, $range_end)) {
271 private function isIpTypeOf(
int $ip_type_flag,
string $ip,
string $range_start,
string $range_end): bool
273 return filter_var($ip, FILTER_VALIDATE_IP, $ip_type_flag) !==
false 274 && filter_var($range_start, FILTER_VALIDATE_IP, $ip_type_flag) !==
false 275 && filter_var($range_end, FILTER_VALIDATE_IP, $ip_type_flag) !==
false;
278 private function isIpv4Between(
string $ip,
string $range_start,
string $range_end): bool
280 return ip2long($range_start) <= ip2long($ip)
281 && ip2long($ip) <= ip2long($range_end);
284 private function isIpv6Between(
string $ip,
string $range_start,
string $range_end): bool
286 return bin2hex(inet_pton($range_start)) <= bin2hex(inet_pton($ip))
287 && bin2hex(inet_pton($ip)) <= bin2hex(inet_pton($range_end));
isIpTypeOf(int $ip_type_flag, string $ip, string $range_start, string $range_end)
checkScoreParticipantsAccess()
ParticipantRepository $participant_repository
setAccess(ilAccessHandler $access)
MainSettingsDatabaseRepository $main_settings_repository
static _lookupObjId(int $ref_id)
checkResultsAccessForActiveId(int $active_id, int $test_id)
checkParticipantsResultsAccess()
checkOtherParticipantsLearningProgressAccess()
const OP_READ_LEARNING_PROGRESS
const OP_SCORE_PARTICIPANTS
checkAccessForActiveId(Closure $access_filter, int $active_id, int $test_id)
isParticipantExplicitelyAllowedByIndividualIPRange(?Participant $participant, string $ip)
const OP_MANAGE_PARTICIPANTS
isIpv4Between(string $ip, string $range_start, string $range_end)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getTestIDFromObjectID($object_id)
Returns the ILIAS test id for a given object id.
checkManageParticipantsAccess()
checkScoreParticipantsAccessForActiveId(int $active_id, int $test_id)
isIpAllowedToAccessTest(string $ip, SettingsAccess $access_settings)
__construct(Container $dic, ilPlugin $plugin)
isIpv6Between(string $ip, string $range_start, string $range_end)
isParticipantAllowed(int $obj_id, int $user_id)
ilTestParticipantAccessFilterFactory $participant_access_filter