19declare(strict_types=1);
39 $this->starting_point_repository =
LocalDIC::dic()[Repository::class];
44 return 'starting_point';
59 return AvailablePages::MainSettings;
68 FieldFactory $field_factory,
74 $starting_point_id = null;
75 $object_ref_id =
null;
78 'starting_point_id' => $starting_point_id ,
79 'object_id' => $object_ref_id
82 $possible_starting_points = $this->starting_point_repository->getPossibleStartingPoints();
83 return $field_factory->switchableGroup(
85 array_keys($possible_starting_points),
86 static function (array
$c,
int $v) use (
89 $possible_starting_points,
92 $c[$v] = $field_factory->group(
95 'usr_start_ref_id' => $field_factory->numeric(
96 $lng->txt(
'adm_user_starting_point_ref_id'),
98 ?
$lng->txt(
'adm_user_starting_point_ref_id_info')
101 )->withRequired(
true)
103 $lng->txt($possible_starting_points[$v])
108 0 => $field_factory->group(
110 $lng->txt(
'adm_user_starting_point_inherit'),
111 $lng->txt(
'adm_user_starting_point_inherit_info')
115 $lng->txt(
'adm_user_starting_point'),
116 $lng->txt(
'adm_user_starting_point_info')
117 )->withAdditionalTransformation(
119 )->withAdditionalTransformation(
121 static fn(array $v): array => [
122 'starting_point_id' =>
$refinery->kindlyTo()->int()->transform($v[0]),
123 'object_id' => $v[1][
'usr_start_ref_id'] ??
null
139 $starting_point_id = null;
140 $object_ref_id =
null;
141 if ($user !==
null) {
142 [
'starting_point_id' => $starting_point_id ,
'object_id' => $object_ref_id] = $this->retrieveValueFromUser($user);
144 $input = new \ilRadioGroupInputGUI(
$lng->txt(
'adm_user_starting_point'));
145 $input->setInfo(
$lng->txt(
'adm_user_starting_point_info'));
146 $inherit_starting_point = new \ilRadioOption(
$lng->txt(
'adm_user_starting_point_inherit'),
'0');
147 $inherit_starting_point->setInfo(
$lng->txt(
'adm_user_starting_point_inherit_info'));
148 $input->addOption($inherit_starting_point);
149 foreach ($this->starting_point_repository->getPossibleStartingPoints() as $value => $caption) {
155 $input->setValue((
string) $starting_point_id);
157 $starting_point_repository = new \ilRadioOption(
158 $lng->txt(
'adm_user_starting_point_object'),
161 $repository_object_id = new \ilTextInputGUI(
$lng->txt(
'adm_user_starting_point_ref_id'),
'usr_start_ref_id');
162 $repository_object_id->setInfo(
$lng->txt(
'adm_user_starting_point_ref_id_info'));
163 $repository_object_id->setRequired(
true);
164 $repository_object_id->setSize(5);
165 if ($object_ref_id !==
null) {
166 $repository_object_id->setValue($object_ref_id);
168 $repository_object_id->setInfo(
174 $starting_point_repository->addSubItem($repository_object_id);
175 $input->addOption($starting_point_repository);
183 $default_starting_point = $this->starting_point_repository->getSystemDefaultStartingPointType();
184 $starting_point = $this->starting_point_repository->getPossibleStartingPoints()[$default_starting_point];
185 if ($default_starting_point !== Repository::START_REPOSITORY_OBJ
186 || (
$ref_id = $this->starting_point_repository->getSystemDefaultStartingObject()) ===
null
188 return $starting_point;
197 return $this->starting_point_repository->isPersonalStartingPointEnabledForUser($user);
205 if ($input === null) {
206 $starting_point_id = 0;
207 $object_ref_id =
null;
208 } elseif (is_array($input)) {
209 [
'starting_point_id' => $starting_point_id ,
'object_id' => $object_ref_id] = $input;
211 $starting_point_id = (
int) $input;
212 $object_ref_id_input = $form->getInput(
'usr_start_ref_id');
213 $object_ref_id = $object_ref_id_input ===
'' ? null : (
int) $object_ref_id_input;
215 $this->starting_point_repository->setPersonalStartingPointForUser(
228 if ($form->getInput($this->getIdentifier()) !==
Repository::START_REPOSITORY_OBJ) {
232 $ref_id = $form->getInput(
'usr_start_ref_id');
234 $tpl->setOnScreenMessage(
'failure',
$lng->txt(
'obj_ref_id_not_exist'),
true);
244 ): CustomConstraint {
246 function (array $v): bool {
250 if (!is_int($v[1][
'usr_start_ref_id']) || !\
ilObject::_exists($v[1][
'usr_start_ref_id'],
true)) {
255 $lng->txt(
'obj_ref_id_not_exist')
262 'starting_point_id' => $this->starting_point_repository->getPersonalStartingPointForUser($user),
263 'object_id' => $this->starting_point_repository->getPersonalStartingObjectForUser($user)
268 int $starting_point_id,
271 if ($starting_point_id !==
Repository::START_REPOSITORY_OBJ) {
272 return $starting_point_id;
276 0 => $starting_point_id,
278 'usr_start_ref_id' => $object_ref_id
const START_REPOSITORY_OBJ
buildValueSetterArray(int $starting_point_id, ?int $object_ref_id)
getLegacyInput(Language $lng, \ilSetting $settings, ?\ilObjUser $user=null)
You don't need to add a post_var to the input as the User will handle this for you,...
readonly Repository $starting_point_repository
buildValidateObjectConstraint(Refinery $refinery, Language $lng)
isAvailable()
If this function returns false the setting will not be shown, even if it's PropertyAttributes would a...
retrieveValueFromUser(\ilObjUser $user)
persistUserInput(\ilObjUser $user, mixed $input, ?\ilPropertyFormGUI $form=null)
getInput(FieldFactory $field_factory, Language $lng, Refinery $refinery, \ilSetting $settings, ?\ilObjUser $user=null)
hasUserPersonalizedSetting(\ilSetting $settings, \ilObjUser $user)
validateUserChoice(\ilGlobalTemplateInterface $tpl, Language $lng, \ilPropertyFormGUI $form)
getDefaultValueForDisplay(Language $lng, \ilSetting $settings)
static _lookupType(int $id, bool $reference=false)
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
This class represents an option in a radio group.
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if(!file_exists('../ilias.ini.php'))