ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
ILIAS\Test\Settings\MainSettings\SettingsAccess Class Reference
+ Inheritance diagram for ILIAS\Test\Settings\MainSettings\SettingsAccess:
+ Collaboration diagram for ILIAS\Test\Settings\MainSettings\SettingsAccess:

Public Member Functions

 __construct (protected bool $start_time_enabled=false, protected ?\DateTimeImmutable $start_time=null, protected bool $end_time_enabled=false, protected ?\DateTimeImmutable $end_time=null, protected bool $password_enabled=false, protected ?string $password=null, protected ?string $ip_range_from=null, protected ?string $ip_range_to=null, protected bool $fixed_participants=false)
 
 toForm (\ilLanguage $lng, FieldFactory $f, Refinery $refinery, ?array $environment=null)
 
 toStorage ()
 
 toLog (AdditionalInformationGenerator $additional_info)
 
 getStartTimeEnabled ()
 
 withStartTimeEnabled (bool $start_time_enabled)
 
 getStartTime ()
 
 withStartTime (?\DateTimeImmutable $start_time)
 
 getEndTimeEnabled ()
 
 withEndTimeEnabled (bool $end_time_enabled)
 
 getEndTime ()
 
 withEndTime (?\DateTimeImmutable $end_time)
 
 getPasswordEnabled ()
 
 withPasswordEnabled (bool $password_enabled)
 
 getPassword ()
 
 withPassword (?string $password)
 
 getIpRangeFrom ()
 
 withIpRangeFrom (?string $ip_range_from)
 
 getIpRangeTo ()
 
 withIpRangeTo (?string $ip_range_to)
 
 isIpRangeEnabled ()
 
 getFixedParticipants ()
 
 withFixedParticipants (bool $fixed_participants)
 
 toExport ()
 Transform the object into a simple, associative array. More...
 
- Public Member Functions inherited from ILIAS\Test\Settings\TestSettings
 __construct ()
 
 toForm (\ilLanguage $lng, FieldFactory $f, Refinery $refinery, ?array $environment=null)
 
 toStorage ()
 
 toLog (AdditionalInformationGenerator $additional_info)
 
 toExport ()
 Transform the object into a simple, associative array. More...
 

Static Public Member Functions

static fromExport (array $data)
 Creates an instance of the object from an array. More...
 
static fromExport (array $data)
 Creates an instance of the object from an array. More...
 

Private Member Functions

 getInputAccessWindow (\ilLanguage $lng, FieldFactory $f, Refinery $refinery, ?array $environment=null)
 
 getSubInputsAccessWindow (\ilLanguage $lng, FieldFactory $f, array $environment)
 
 getInputPassword (\ilLanguage $lng, FieldFactory $f, Refinery $refinery)
 
 getInputIpRange (\ilLanguage $lng, FieldFactory $f, Refinery $refinery)
 
 checkIpRangeValidity (string $start, string $end)
 

Private Attributes

const MAX_PASSWORD_LENGTH = 20
 

Detailed Description

Definition at line 32 of file SettingsAccess.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Test\Settings\MainSettings\SettingsAccess::__construct ( protected bool  $start_time_enabled = false,
protected ?\DateTimeImmutable  $start_time = null,
protected bool  $end_time_enabled = false,
protected ?\DateTimeImmutable  $end_time = null,
protected bool  $password_enabled = false,
protected ?string  $password = null,
protected ?string  $ip_range_from = null,
protected ?string  $ip_range_to = null,
protected bool  $fixed_participants = false 
)

Definition at line 36 of file SettingsAccess.php.

46 {
48 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References ILIAS\GlobalScreen\Provider\__construct().

+ Here is the call graph for this function:

Member Function Documentation

◆ checkIpRangeValidity()

ILIAS\Test\Settings\MainSettings\SettingsAccess::checkIpRangeValidity ( string  $start,
string  $end 
)
private

Definition at line 231 of file SettingsAccess.php.

231 : bool
232 {
233 if (filter_var($start, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) !== false
234 && filter_var($end, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) !== false) {
235 return ip2long($start) <= ip2long($end);
236 }
237
238 if (filter_var($start, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false
239 && filter_var($end, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false) {
240 return bin2hex(inet_pton($start)) <= bin2hex(inet_pton($end));
241 }
242 return false;
243 }

◆ fromExport()

static ILIAS\Test\Settings\MainSettings\SettingsAccess::fromExport ( array  $data)
static

Creates an instance of the object from an array.

This static factory method is responsible for constructing a new object instance from the provided array data. It should validate the input and may throw an exception if the data is incomplete or malformed.

Parameters
ExportableArray$dataThe data to restore the object from
Returns
static A new instance of the class

Implements ILIAS\Test\ExportImport\Exportable.

Definition at line 403 of file SettingsAccess.php.

403 : static
404 {
405 return new self(
406 (bool) $data['starting_time_enabled'],
407 $data['starting_time'] !== null ? new \DateTimeImmutable($data['starting_time']) : null,
408 (bool) $data['ending_time_enabled'],
409 $data['ending_time'] !== null ? new \DateTimeImmutable($data['ending_time']) : null,
410 (bool) $data['password_enabled'],
411 $data['password'],
412 $data['ip_range_from'],
413 $data['ip_range_to'],
414 (bool) $data['fixed_participants'],
415 );
416 }

References $data.

Referenced by ILIAS\Test\Settings\MainSettings\MainSettings\fromExport().

+ Here is the caller graph for this function:

◆ getEndTime()

ILIAS\Test\Settings\MainSettings\SettingsAccess::getEndTime ( )

Definition at line 317 of file SettingsAccess.php.

317 : ?\DateTimeImmutable
318 {
319 return $this->end_time;
320 }

◆ getEndTimeEnabled()

ILIAS\Test\Settings\MainSettings\SettingsAccess::getEndTimeEnabled ( )

Definition at line 306 of file SettingsAccess.php.

306 : bool
307 {
308 return $this->end_time_enabled;
309 }

◆ getFixedParticipants()

ILIAS\Test\Settings\MainSettings\SettingsAccess::getFixedParticipants ( )

Definition at line 377 of file SettingsAccess.php.

377 : bool
378 {
379 return $this->fixed_participants;
380 }

◆ getInputAccessWindow()

ILIAS\Test\Settings\MainSettings\SettingsAccess::getInputAccessWindow ( \ilLanguage  $lng,
FieldFactory  $f,
Refinery  $refinery,
?array  $environment = null 
)
private

Definition at line 72 of file SettingsAccess.php.

77 : Group {
78 $constraint = $refinery->custom()->constraint(
79 static fn(array $vs) =>
80 $vs['start_time'] === null || $vs['end_time'] === null || $vs['start_time'] < $vs['end_time'],
81 $lng->txt('duration_end_must_not_be_earlier_than_start')
82 );
83
84 $trafo = $refinery->custom()->transformation(
85 static function (array $vs): array {
86 $vs['start_time_enabled'] = $vs['start_time'] !== null;
87 $vs['end_time_enabled'] = $vs['end_time'] !== null;
88 return $vs;
89 }
90 );
91
92 return $f->group($this->getSubInputsAccessWindow($lng, $f, $environment))
93 ->withAdditionalTransformation($constraint)
94 ->withAdditionalTransformation($trafo);
95 }
getSubInputsAccessWindow(\ilLanguage $lng, FieldFactory $f, array $environment)
global $lng
Definition: privfeed.php:31

◆ getInputIpRange()

ILIAS\Test\Settings\MainSettings\SettingsAccess::getInputIpRange ( \ilLanguage  $lng,
FieldFactory  $f,
Refinery  $refinery 
)
private

Definition at line 168 of file SettingsAccess.php.

172 : FormInput {
173 $validate_ip = $refinery->custom()->constraint(
174 static function (?string $v): bool {
175 if ($v === null) {
176 return true;
177 }
178 return filter_var($v, FILTER_VALIDATE_IP) !== false;
179 },
180 $lng->txt('invalid_ip')
181 );
182
183 $validate_order = $refinery->custom()->constraint(
184 function (?array $vs): bool {
185 if ($vs === null) {
186 return true;
187 }
188 return $this->checkIpRangeValidity(
189 $vs['ip_range_from'],
190 $vs['ip_range_to']
191 );
192 },
193 sprintf($lng->txt('not_greater_than'), $lng->txt('max_ip_label'), $lng->txt('min_ip_label'))
194 );
195 $trafo = $refinery->custom()->transformation(
196 static function (?array $vs): array {
197 if ($vs === null) {
198 $vs = [
199 'ip_range_from' => null,
200 'ip_range_to' => null
201 ];
202 }
203 return $vs;
204 }
205 );
206
207 $get_ip_range = $f->optionalGroup(
208 [
209 'ip_range_from' => $f->text($lng->txt('min_ip_label'))
210 ->withAdditionalTransformation($validate_ip),
211 'ip_range_to' => $f->text($lng->txt('max_ip_label'))
212 ->withAdditionalTransformation($validate_ip)
213 ],
214 $lng->txt('ip_range_label'),
215 $lng->txt('ip_range_info')
216 )->withValue(null);
217
218 if ($this->isIpRangeEnabled()) {
219 $get_ip_range = $get_ip_range->withValue(
220 [
221 'ip_range_from' => $this->getIpRangeFrom(),
222 'ip_range_to' => $this->getIpRangeTo()
223 ]
224 );
225 }
226
227 return $get_ip_range->withAdditionalTransformation($validate_order)
228 ->withAdditionalTransformation($trafo);
229 }
checkIpRangeValidity(string $start, string $end)
withValue($value)
Get an input like this with another value displayed on the client side.
Definition: Group.php:61

◆ getInputPassword()

ILIAS\Test\Settings\MainSettings\SettingsAccess::getInputPassword ( \ilLanguage  $lng,
FieldFactory  $f,
Refinery  $refinery 
)
private

Definition at line 130 of file SettingsAccess.php.

134 : OptionalGroup {
135 $trafo = $refinery->custom()->transformation(
136 static function (?array $vs): array {
137 if ($vs === null) {
138 return [
139 'password_enabled' => false,
140 'password_value' => null
141 ];
142 }
143
144 $vs['password_enabled'] = true;
145 return $vs;
146 }
147 );
148
149 $sub_inputs_password['password_value'] = $f->text($lng->txt('tst_password_enter'))
150 ->withRequired(true)->withMaxLength(self::MAX_PASSWORD_LENGTH);
151
152 $password_input = $f->optionalGroup(
153 $sub_inputs_password,
154 $lng->txt('tst_password'),
155 $lng->txt('tst_password_details')
156 )->withValue(null)
157 ->withAdditionalTransformation($trafo);
158
159 if (!$this->getPasswordEnabled()) {
160 return $password_input;
161 }
162
163 return $password_input->withValue(
164 ['password_value' => $this->getPassword()]
165 );
166 }

◆ getIpRangeFrom()

ILIAS\Test\Settings\MainSettings\SettingsAccess::getIpRangeFrom ( )

Definition at line 350 of file SettingsAccess.php.

350 : ?string
351 {
352 return $this->ip_range_from;
353 }

◆ getIpRangeTo()

ILIAS\Test\Settings\MainSettings\SettingsAccess::getIpRangeTo ( )

Definition at line 361 of file SettingsAccess.php.

361 : ?string
362 {
363 return $this->ip_range_to;
364 }

◆ getPassword()

ILIAS\Test\Settings\MainSettings\SettingsAccess::getPassword ( )

Definition at line 339 of file SettingsAccess.php.

339 : ?string
340 {
341 return $this->password;
342 }

◆ getPasswordEnabled()

ILIAS\Test\Settings\MainSettings\SettingsAccess::getPasswordEnabled ( )

Definition at line 328 of file SettingsAccess.php.

328 : bool
329 {
330 return $this->password_enabled;
331 }

◆ getStartTime()

ILIAS\Test\Settings\MainSettings\SettingsAccess::getStartTime ( )

Definition at line 295 of file SettingsAccess.php.

295 : ?\DateTimeImmutable
296 {
297 return $this->start_time;
298 }

◆ getStartTimeEnabled()

ILIAS\Test\Settings\MainSettings\SettingsAccess::getStartTimeEnabled ( )

Definition at line 284 of file SettingsAccess.php.

284 : bool
285 {
286 return $this->start_time_enabled;
287 }

◆ getSubInputsAccessWindow()

ILIAS\Test\Settings\MainSettings\SettingsAccess::getSubInputsAccessWindow ( \ilLanguage  $lng,
FieldFactory  $f,
array  $environment 
)
private

Definition at line 97 of file SettingsAccess.php.

101 : array {
102 $sub_inputs_access_window['start_time'] = $f->dateTime(
103 $lng->txt('tst_starting_time'),
104 $lng->txt('tst_starting_time_desc')
105 )->withTimezone($environment['user_time_zone'])
106 ->withFormat($environment['user_date_format'])
107 ->withUseTime(true);
108 if ($this->getStartTime() !== null) {
109 $sub_inputs_access_window['start_time'] = $sub_inputs_access_window['start_time']
110 ->withValue($this->getStartTime()->setTimezone(new \DateTimeZone($environment['user_time_zone'])));
111 }
112 if ($environment['participant_data_exists']) {
113 $sub_inputs_access_window['start_time'] = $sub_inputs_access_window['start_time']->withDisabled(true);
114 }
115
116 $sub_inputs_access_window['end_time'] = $f->dateTime(
117 $lng->txt('tst_ending_time'),
118 $lng->txt('tst_ending_time_desc')
119 )->withTimezone($environment['user_time_zone'])
120 ->withFormat($environment['user_date_format'])
121 ->withUseTime(true);
122 if ($this->getEndTime() !== null) {
123 $sub_inputs_access_window['end_time'] = $sub_inputs_access_window['end_time']
124 ->withValue($this->getEndTime()->setTimezone(new \DateTimeZone($environment['user_time_zone'])));
125 }
126
127 return $sub_inputs_access_window;
128 }

◆ isIpRangeEnabled()

ILIAS\Test\Settings\MainSettings\SettingsAccess::isIpRangeEnabled ( )

Definition at line 372 of file SettingsAccess.php.

372 : ?bool
373 {
374 return $this->ip_range_from !== null && $this->ip_range_to !== null;
375 }

◆ toExport()

ILIAS\Test\Settings\MainSettings\SettingsAccess::toExport ( )

Transform the object into a simple, associative array.

The resulting array represents the object's state and should contain only scalar values, arrays, or other Exportable objects.

Returns
ExportableArray The exportable array representation of the object

Implements ILIAS\Test\ExportImport\Exportable.

Definition at line 388 of file SettingsAccess.php.

388 : array
389 {
390 return [
391 'starting_time_enabled' => $this->getStartTimeEnabled(),
392 'starting_time' => $this->getStartTime()?->format(\DateTimeInterface::ATOM),
393 'ending_time_enabled' => $this->getEndTimeEnabled(),
394 'ending_time' => $this->getEndTime()?->format(\DateTimeInterface::ATOM),
395 'password_enabled' => $this->getPasswordEnabled(),
396 'password' => $this->getPassword(),
397 'ip_range_from' => $this->getIpRangeFrom(),
398 'ip_range_to' => $this->getIpRangeTo(),
399 'fixed_participants' => $this->getFixedParticipants()
400 ];
401 }

◆ toForm()

ILIAS\Test\Settings\MainSettings\SettingsAccess::toForm ( \ilLanguage  $lng,
FieldFactory  $f,
Refinery  $refinery,
?array  $environment = null 
)

Reimplemented from ILIAS\Test\Settings\TestSettings.

Definition at line 50 of file SettingsAccess.php.

55 : FormInput {
56 $inputs['access_window'] = $this->getInputAccessWindow($lng, $f, $refinery, $environment);
57 $inputs['test_password'] = $this->getInputPassword($lng, $f, $refinery);
58 $inputs['ip_range'] = $this->getInputIpRange($lng, $f, $refinery);
59
60 $inputs['fixed_participants_enabled'] = $f->checkbox(
61 $lng->txt('participants_invitation'),
62 $lng->txt('participants_invitation_description')
63 )->withValue($this->getFixedParticipants());
64 if ($environment['participant_data_exists']) {
65 $inputs['fixed_participants_enabled'] = $inputs['fixed_participants_enabled']
66 ->withDisabled(true);
67 }
68
69 return $f->section($inputs, $lng->txt('tst_settings_header_execution'));
70 }
getInputIpRange(\ilLanguage $lng, FieldFactory $f, Refinery $refinery)
getInputAccessWindow(\ilLanguage $lng, FieldFactory $f, Refinery $refinery, ?array $environment=null)
getInputPassword(\ilLanguage $lng, FieldFactory $f, Refinery $refinery)

◆ toLog()

ILIAS\Test\Settings\MainSettings\SettingsAccess::toLog ( AdditionalInformationGenerator  $additional_info)

Reimplemented from ILIAS\Test\Settings\TestSettings.

Definition at line 260 of file SettingsAccess.php.

260 : array
261 {
262 $starting_time = $additional_info->getNoneTag();
263 if (($st_immutable = $this->getStartTime()) instanceof \DateTimeImmutable) {
264 $starting_time = $st_immutable->format(AdditionalInformationGenerator::DATE_STORAGE_FORMAT);
265 }
266
267 $end_time = $additional_info->getNoneTag();
268 if (($et_immutable = $this->getEndTime()) instanceof \DateTimeImmutable) {
269 $end_time = $et_immutable->format(AdditionalInformationGenerator::DATE_STORAGE_FORMAT);
270 }
271
272 return [
277 ? $this->getIpRangeFrom() . ' - ' . $this->getIpRangeTo()
278 : $additional_info->getEnabledDisabledTagForBool(false),
279 AdditionalInformationGenerator::KEY_TEST_FIXED_PARTICIPANTS => $additional_info
280 ->getEnabledDisabledTagForBool($this->getFixedParticipants())
281 ];
282 }

References ILIAS\Test\Logging\AdditionalInformationGenerator\getEnabledDisabledTagForBool(), and ILIAS\Test\Logging\AdditionalInformationGenerator\getNoneTag().

+ Here is the call graph for this function:

◆ toStorage()

ILIAS\Test\Settings\MainSettings\SettingsAccess::toStorage ( )

Reimplemented from ILIAS\Test\Settings\TestSettings.

Definition at line 245 of file SettingsAccess.php.

245 : array
246 {
247 return [
248 'starting_time_enabled' => ['integer', (int) $this->getStartTimeEnabled()],
249 'starting_time' => ['integer', $this->getStartTime() !== null ? $this->getStartTime()->getTimestamp() : 0],
250 'ending_time_enabled' => ['integer', (int) $this->getEndTimeEnabled()],
251 'ending_time' => ['integer', $this->getEndTime() !== null ? $this->getEndTime()->getTimestamp() : 0],
252 'password_enabled' => ['integer', (int) $this->getPasswordEnabled()],
253 'password' => ['text', $this->getPassword()],
254 'ip_range_from' => ['text', $this->getIpRangeFrom()],
255 'ip_range_to' => ['text', $this->getIpRangeTo()],
256 'fixed_participants' => ['integer', (int) $this->getFixedParticipants()]
257 ];
258 }

References ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ withEndTime()

ILIAS\Test\Settings\MainSettings\SettingsAccess::withEndTime ( ?\DateTimeImmutable  $end_time)

Definition at line 321 of file SettingsAccess.php.

321 : self
322 {
323 $clone = clone $this;
324 $clone->end_time = $end_time;
325 return $clone;
326 }

◆ withEndTimeEnabled()

ILIAS\Test\Settings\MainSettings\SettingsAccess::withEndTimeEnabled ( bool  $end_time_enabled)

Definition at line 310 of file SettingsAccess.php.

310 : self
311 {
312 $clone = clone $this;
313 $clone->end_time_enabled = $end_time_enabled;
314 return $clone;
315 }

◆ withFixedParticipants()

ILIAS\Test\Settings\MainSettings\SettingsAccess::withFixedParticipants ( bool  $fixed_participants)

Definition at line 381 of file SettingsAccess.php.

381 : self
382 {
383 $clone = clone $this;
384 $clone->fixed_participants = $fixed_participants;
385 return $clone;
386 }

◆ withIpRangeFrom()

ILIAS\Test\Settings\MainSettings\SettingsAccess::withIpRangeFrom ( ?string  $ip_range_from)

Definition at line 354 of file SettingsAccess.php.

354 : self
355 {
356 $clone = clone $this;
357 $clone->ip_range_from = $ip_range_from;
358 return $clone;
359 }

◆ withIpRangeTo()

ILIAS\Test\Settings\MainSettings\SettingsAccess::withIpRangeTo ( ?string  $ip_range_to)

Definition at line 365 of file SettingsAccess.php.

365 : self
366 {
367 $clone = clone $this;
368 $clone->ip_range_to = $ip_range_to;
369 return $clone;
370 }

◆ withPassword()

ILIAS\Test\Settings\MainSettings\SettingsAccess::withPassword ( ?string  $password)

Definition at line 343 of file SettingsAccess.php.

343 : self
344 {
345 $clone = clone $this;
346 $clone->password = $password;
347 return $clone;
348 }

◆ withPasswordEnabled()

ILIAS\Test\Settings\MainSettings\SettingsAccess::withPasswordEnabled ( bool  $password_enabled)

Definition at line 332 of file SettingsAccess.php.

332 : self
333 {
334 $clone = clone $this;
335 $clone->password_enabled = $password_enabled;
336 return $clone;
337 }

◆ withStartTime()

ILIAS\Test\Settings\MainSettings\SettingsAccess::withStartTime ( ?\DateTimeImmutable  $start_time)

Definition at line 299 of file SettingsAccess.php.

299 : self
300 {
301 $clone = clone $this;
302 $clone->start_time = $start_time;
303 return $clone;
304 }

◆ withStartTimeEnabled()

ILIAS\Test\Settings\MainSettings\SettingsAccess::withStartTimeEnabled ( bool  $start_time_enabled)

Definition at line 288 of file SettingsAccess.php.

288 : self
289 {
290 $clone = clone $this;
291 $clone->start_time_enabled = $start_time_enabled;
292 return $clone;
293 }

Referenced by ILIAS\Test\Settings\MainSettings\SettingsMainGUI\getAccessSettingsForStorage().

+ Here is the caller graph for this function:

Field Documentation

◆ MAX_PASSWORD_LENGTH

const ILIAS\Test\Settings\MainSettings\SettingsAccess::MAX_PASSWORD_LENGTH = 20
private

Definition at line 34 of file SettingsAccess.php.


The documentation for this class was generated from the following file: