19 declare(strict_types=1);
48 return self::ACTION_ID;
53 return $this->test_access->checkManageParticipantsAccess();
62 return $this->ui_factory->table()->action()->standard(
63 $this->
lng->txt(self::ACTION_ID),
73 array $selected_participants,
74 bool $all_participants_selected
76 $valid_ip_constraint = $this->
refinery->custom()->constraint(
77 fn(?
string $ip):
bool => $ip ===
null 79 || filter_var($ip, FILTER_VALIDATE_IP) !==
false,
80 $this->
lng->txt(
'invalid_ip')
82 $validate_order = $this->
refinery->custom()->constraint(
83 function (?array $vs):
bool {
92 sprintf($this->
lng->txt(
'not_greater_than'), $this->
lng->txt(
'max_ip_label'), $this->
lng->txt(
'min_ip_label'))
94 $ip_range_group_trafo = $this->
refinery->custom()->transformation(
95 static function (?array $vs): array {
113 $selected_participants
116 return $this->ui_factory->modal()->roundtrip(
117 $this->
lng->txt(
'client_ip_range'),
119 $this->ui_factory->messageBox()->info(
121 $this->resolveInfoMessage(
122 $selected_participants,
123 $all_participants_selected
127 $this->ui_factory->listing()->unordered($participant_rows)
130 'ip_range' => $this->ui_factory->input()->field()->group([
131 'from' => $this->ui_factory->input()->field()->text(
132 $this->
lng->txt(
'min_ip_label')
134 'to' => $this->ui_factory->input()->field()->text(
135 $this->
lng->txt(
'max_ip_label'),
136 $this->
lng->txt(
'ip_range_byline')
141 'from' => $selected_participants[0]->getClientIpFrom() ??
'',
142 'to' => $selected_participants[0]->getClientIpTo() ??
'' 150 ->withAdditionalTransformation($validate_order)
152 $url_builder->
buildURI()->__toString()
153 )->withSubmitLabel($this->
lng->txt(
'change'));
159 array $selected_participants,
160 bool $all_participants_selected
162 if (!$this->test_access->checkManageParticipantsAccess()) {
163 $this->tpl->setOnScreenMessage(
165 $this->
lng->txt(
'no_permission'),
173 $selected_participants,
174 $all_participants_selected
175 )->withRequest($request);
177 $data = $modal->getData();
179 return $modal->withOnLoad($modal->getShowSignal());
182 $this->participant_repository->updateIpRange(
185 ->withClientIpTo(
$data[
'ip_range'][
'to']),
186 $selected_participants
190 $this->tpl->setOnScreenMessage(
192 $this->
lng->txt(
'ip_range_updated'),
207 array $selected_participants,
208 bool $all_participants_selected
210 if ($all_participants_selected) {
211 return 'ip_range_for_all_participants';
214 if (count($selected_participants) === 1) {
215 return 'ip_range_for_single_participant';
218 return 'ip_range_for_selected_participants';
223 return count($selected_participants) === 1
226 $selected_participants
232 if (filter_var($start, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) !==
false 233 && filter_var($end, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) !==
false) {
234 return ip2long($start) <= ip2long($end);
237 if (filter_var($start, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !==
false 238 && filter_var($end, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !==
false) {
239 return bin2hex(inet_pton($start)) <= bin2hex(inet_pton($end));
This describes commonalities between the different modals.
onSubmit(URLBuilder $url_builder, ServerRequestInterface $request, array $selected_participants, bool $all_participants_selected)
getSelectionErrorMessage()
buildURI()
Get a URI representation of the full URL including query string and fragment/hash.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getTableAction(URLBuilder $url_builder, URLBuilderToken $row_id_token, URLBuilderToken $action_token, URLBuilderToken $action_type_token)
const MESSAGE_TYPE_SUCCESS
resolveInfoMessage(array $selected_participants, bool $all_participants_selected)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
isUniqueClientIp(array $selected_participants)
allowActionForRecord(Participant $record)
getModal(URLBuilder $url_builder, array $selected_participants, bool $all_participants_selected)
withParameter(URLBuilderToken $token, string|array $value)
Change an acquired parameter's value if the supplied token is valid.
__construct(private readonly Language $lng, private readonly \ilGlobalTemplateInterface $tpl, private readonly UIFactory $ui_factory, private readonly Refinery $refinery, private readonly ParticipantRepository $participant_repository, private readonly \ilTestAccess $test_access,)
const MESSAGE_TYPE_FAILURE
checkIpRangeValidity(string $start, string $end)
withClientIpFrom(?string $ip)