Skip to content

Commit e5606b3

Browse files
committed
User: Fix Validation of StartingPoint in Legacy
1 parent 6a5877f commit e5606b3

4 files changed

Lines changed: 28 additions & 10 deletions

File tree

components/ILIAS/User/classes/class.ilObjUserGUI.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,12 @@ public function saveObject(): void
338338
$profile_maybe_incomplete = $this->retrieveAllowIncompleteProfileFromPost();
339339
$this->initForm(!$profile_maybe_incomplete, null);
340340

341-
if (!$this->form_gui->checkInput()) {
341+
if (!$this->form_gui->checkInput()
342+
|| !$this->user_settings->performAdditionalChecks(
343+
$this->tpl,
344+
$this->form_gui
345+
)
346+
) {
342347
$this->form_gui->setValuesByPost();
343348
$this->renderForm();
344349
return;
@@ -430,7 +435,10 @@ public function updateObject(): void
430435
$this->initForm(!$profile_maybe_incomplete, $this->object);
431436

432437
if (!$this->form_gui->checkInput()
433-
|| !$this->isAccessRangeInputValid()) {
438+
|| !$this->user_settings->performAdditionalChecks(
439+
$this->tpl,
440+
$this->form_gui
441+
) || !$this->isAccessRangeInputValid()) {
434442
$this->form_gui->setValuesByPost();
435443
$this->tabs_gui->activateTab('properties');
436444
$this->renderForm();

components/ILIAS/User/src/LocalDIC.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ private function init(ILIASContainer $DIC): void
7373
new UserSettingsImplementation(
7474
$DIC['lng'],
7575
$DIC['ilSetting'],
76-
$DIC['tpl'],
7776
$DIC['ui.factory'],
7877
$DIC['refinery'],
7978
$c[UserSettingsConfigurationRepository::class],

components/ILIAS/User/src/Settings/SettingsImplementation.php

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ class SettingsImplementation implements Settings
3030
public function __construct(
3131
private readonly Language $lng,
3232
private readonly \ilSetting $settings,
33-
private readonly \ilGlobalTemplateInterface $tpl,
3433
private readonly UIFactory $ui_factory,
3534
private readonly Refinery $refinery,
3635
private readonly ConfigurationRepository $user_settings_configuration_repository,
@@ -105,9 +104,13 @@ public function addSectionsToLegacyForm(
105104
}
106105

107106
public function performAdditionalChecks(
107+
\ilGlobalTemplateInterface $tpl,
108108
\ilPropertyFormGUI $form
109109
): bool {
110-
return $this->checkStartingPointValue($form);
110+
return $this->checkStartingPointValue(
111+
$tpl,
112+
$form
113+
);
111114
}
112115

113116
/**
@@ -366,9 +369,17 @@ private function retrieveValuefromInputs(
366369
return $form[$section_key][$setting->getIdentifier()];
367370
}
368371

369-
private function checkStartingPointValue(\ilPropertyFormGUI $form): bool
370-
{
372+
private function checkStartingPointValue(
373+
\ilGlobalTemplateInterface $tpl,
374+
\ilPropertyFormGUI $form
375+
): bool {
371376
return $form->getInput('additional') === ''
372-
|| $this->user_settings_configuration_repository->getByIdentifier('starting_point')->validateUserChoice($this->tpl, $this->lng, $form);
377+
|| $this->user_settings_configuration_repository
378+
->getByIdentifier('starting_point')
379+
->validateUserChoice(
380+
$tpl,
381+
$this->lng,
382+
$form
383+
);
373384
}
374385
}

components/ILIAS/User/src/Settings/StartingPoint/Setting.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ public function validateUserChoice(
225225
Language $lng,
226226
\ilPropertyFormGUI $form
227227
): bool {
228-
if ($form->getInput($this->getIdentifier()) !== Repository::START_REPOSITORY_OBJ) {
228+
if ((int) $form->getInput($this->getIdentifier()) !== Repository::START_REPOSITORY_OBJ) {
229229
return true;
230230
}
231231

@@ -244,7 +244,7 @@ private function buildValidateObjectConstraint(
244244
): CustomConstraint {
245245
return $refinery->custom()->constraint(
246246
function (array $v): bool {
247-
if ($v[0] !== Repository::START_REPOSITORY_OBJ) {
247+
if ((int) $v[0] !== Repository::START_REPOSITORY_OBJ) {
248248
return true;
249249
}
250250
if (!is_int($v[1]['usr_start_ref_id']) || !\ilObject::_exists($v[1]['usr_start_ref_id'], true)) {

0 commit comments

Comments
 (0)