19declare(strict_types=1);
52 $this->db =
$DIC[
'ilDB'];
53 $this->
lng = $DIC[
'lng'];
55 $this->participant_repository = TestDIC::dic()[
'participant.repository'];
56 $this->
access = $DIC->access();
57 $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::MISSING_SETTINGS;
193 }
catch (\Exception
$e) {
194 return ParticipantAccess::BROKEN_TEST;
197 $participant = $this->participant_repository->getParticipantByUserId(
204 if ($access_settings->getFixedParticipants()
205 && ($participant ===
null || !$participant->isInvitedParticipant())) {
206 return ParticipantAccess::NOT_INVITED;
212 if ($allowed_individual ===
false) {
213 return ParticipantAccess::INDIVIDUAL_CLIENT_IP_MISMATCH;
217 if ($allowed_individual ===
true
218 || !$access_settings->isIpRangeEnabled()) {
219 return ParticipantAccess::ALLOWED;
223 return ParticipantAccess::TEST_LEVEL_CLIENT_IP_MISMATCH;
226 return ParticipantAccess::ALLOWED;
233 $range_start = $participant?->getClientIpFrom();
236 if ($range_start ===
null && $range_end ===
null) {
240 if ($this->
isIpTypeOf(FILTER_FLAG_IPV4, $ip, $range_start, $range_end)) {
244 if ($this->
isIpTypeOf(FILTER_FLAG_IPV6, $ip, $range_start, $range_end)) {
255 if (!$access_settings->isIpRangeEnabled()) {
259 $range_start = $access_settings->getIpRangeFrom();
260 $range_end = $access_settings->getIpRangeTo();
262 if ($this->isIpTypeOf(FILTER_FLAG_IPV4, $ip, $range_start, $range_end)) {
263 return $this->isIpv4Between($ip, $range_start, $range_end);
266 if ($this->isIpTypeOf(FILTER_FLAG_IPV6, $ip, $range_start, $range_end)) {
267 return $this->isIpv6Between($ip, $range_start, $range_end);
273 private function isIpTypeOf(
int $ip_type_flag,
string $ip,
string $range_start,
string $range_end): bool
275 return filter_var($ip, FILTER_VALIDATE_IP, $ip_type_flag) !==
false
276 && filter_var($range_start, FILTER_VALIDATE_IP, $ip_type_flag) !==
false
277 && filter_var($range_end, FILTER_VALIDATE_IP, $ip_type_flag) !==
false;
280 private function isIpv4Between(
string $ip,
string $range_start,
string $range_end): bool
282 return ip2long($range_start) <= ip2long($ip)
283 && ip2long($ip) <= ip2long($range_end);
286 private function isIpv6Between(
string $ip,
string $range_start,
string $range_end): bool
288 return bin2hex(inet_pton($range_start)) <= bin2hex(inet_pton($ip))
289 && bin2hex(inet_pton($ip)) <= bin2hex(inet_pton($range_end));
@depracated This is only a temporary exception to identify missing migrations and will be removed in ...
static _getTestIDFromObjectID($object_id)
Returns the ILIAS test id for a given object id.
static _lookupObjId(int $ref_id)
const OP_READ_LEARNING_PROGRESS
const OP_SCORE_PARTICIPANTS
const OP_MANAGE_PARTICIPANTS
isIpv6Between(string $ip, string $range_start, string $range_end)
MainSettingsDatabaseRepository $main_settings_repository
checkScoreParticipantsAccessAnon()
checkResultsAccessForActiveId(int $active_id, int $test_id)
checkParticipantsResultsAccess()
isParticipantExplicitelyAllowedByIndividualIPRange(?Participant $participant, string $ip)
isIpTypeOf(int $ip_type_flag, string $ip, string $range_start, string $range_end)
checkOtherParticipantsLearningProgressAccess()
checkScoreParticipantsAccess()
checkAccessForActiveId(Closure $access_filter, int $active_id, int $test_id)
isIpv4Between(string $ip, string $range_start, string $range_end)
ParticipantRepository $participant_repository
checkScoreParticipantsAccessForActiveId(int $active_id, int $test_id)
isIpAllowedToAccessTest(string $ip, SettingsAccess $access_settings)
checkManageParticipantsAccess()
isParticipantAllowed(int $obj_id, int $user_id)
setAccess(ilAccessHandler $access)
ilTestParticipantAccessFilterFactory $participant_access_filter
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
if(!file_exists('../ilias.ini.php'))