ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\User\Settings\StartingPoint\Setting Class Reference
+ Inheritance diagram for ILIAS\User\Settings\StartingPoint\Setting:
+ Collaboration diagram for ILIAS\User\Settings\StartingPoint\Setting:

Public Member Functions

 __construct ()
 
 getIdentifier ()
 
 isAvailable ()
 If this function returns false the setting will not be shown, even if it's PropertyAttributes would allow it to be. More...
 
 getLabel (Language $lng)
 
 getSettingsPage ()
 
 getSection ()
 
 getInput (FieldFactory $field_factory, Language $lng, Refinery $refinery, \ilSetting $settings, ?\ilObjUser $user=null)
 
 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, thus you can also not rely on the post_var anywhere else, as it will be changed. More...
 
 getDefaultValueForDisplay (Language $lng, \ilSetting $settings)
 
 hasUserPersonalizedSetting (\ilSetting $settings, \ilObjUser $user)
 
 persistUserInput (\ilObjUser $user, mixed $input, ?\ilPropertyFormGUI $form=null)
 
 validateUserChoice (\ilGlobalTemplateInterface $tpl, Language $lng, \ilPropertyFormGUI $form)
 
 retrieveValueFromUser (\ilObjUser $user)
 
- Public Member Functions inherited from ILIAS\User\Settings\SettingDefinition
 isAvailable ()
 If this function returns false the setting will not be shown, even if it's PropertyAttributes would allow it to be. More...
 
 getSettingsPage ()
 
 getDefaultValueForDisplay (Language $lng, \ilSetting $settings)
 
 hasUserPersonalizedSetting (\ilSetting $settings, \ilObjUser $user)
 
 getInput (FieldFactory $field_factory, Language $lng, Refinery $refinery, \ilSetting $settings, ?\ilObjUser $user=null)
 
 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, thus you can also not rely on the post_var anywhere else, as it will be changed. More...
 
 persistUserInput (\ilObjUser $user, mixed $input)
 
 getIdentifier ()
 
 getLabel (Language $lng)
 
 getSection ()
 
 retrieveValueFromUser (\ilObjUser $user)
 

Private Member Functions

 buildValidateObjectConstraint (Refinery $refinery, Language $lng)
 
 buildValueSetterArray (int $starting_point_id, ?int $object_ref_id)
 

Private Attributes

readonly Repository $starting_point_repository
 

Detailed Description

Definition at line 33 of file Setting.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\User\Settings\StartingPoint\Setting::__construct ( )

Definition at line 37 of file Setting.php.

38 {
39 $this->starting_point_repository = LocalDIC::dic()[Repository::class];
40 }

References ILIAS\User\LocalDIC\dic().

+ Here is the call graph for this function:

Member Function Documentation

◆ buildValidateObjectConstraint()

ILIAS\User\Settings\StartingPoint\Setting::buildValidateObjectConstraint ( Refinery  $refinery,
Language  $lng 
)
private

Definition at line 241 of file Setting.php.

244 : CustomConstraint {
245 return $refinery->custom()->constraint(
246 function (array $v): bool {
247 if ($v[0] !== Repository::START_REPOSITORY_OBJ) {
248 return true;
249 }
250 if (!is_int($v[1]['usr_start_ref_id']) || !\ilObject::_exists($v[1]['usr_start_ref_id'], true)) {
251 return false;
252 }
253 return true;
254 },
255 $lng->txt('obj_ref_id_not_exist')
256 );
257 }
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
global $lng
Definition: privfeed.php:31

◆ buildValueSetterArray()

ILIAS\User\Settings\StartingPoint\Setting::buildValueSetterArray ( int  $starting_point_id,
?int  $object_ref_id 
)
private

Definition at line 267 of file Setting.php.

270 : int|array {
271 if ($starting_point_id !== Repository::START_REPOSITORY_OBJ) {
272 return $starting_point_id;
273 }
274
275 return [
276 0 => $starting_point_id,
277 1 => [
278 'usr_start_ref_id' => $object_ref_id
279 ]
280 ];
281 }

◆ getDefaultValueForDisplay()

ILIAS\User\Settings\StartingPoint\Setting::getDefaultValueForDisplay ( Language  $lng,
\ilSetting  $settings 
)

Implements ILIAS\User\Settings\SettingDefinition.

Definition at line 179 of file Setting.php.

182 : string {
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
187 || ($obj_id = \ilObject::_lookupObjId($ref_id)) === 0) {
188 return $starting_point;
189 }
190 return $lng->txt('obj_' . \ilObject::_lookupType($obj_id)) . ' - ' . \ilObject::_lookupTitle($obj_id);
191 }
static _lookupType(int $id, bool $reference=false)
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
$ref_id
Definition: ltiauth.php:66

◆ getIdentifier()

ILIAS\User\Settings\StartingPoint\Setting::getIdentifier ( )

Implements ILIAS\User\Property.

Definition at line 42 of file Setting.php.

42 : string
43 {
44 return 'starting_point';
45 }

Referenced by ILIAS\User\Settings\StartingPoint\Setting\getLabel().

+ Here is the caller graph for this function:

◆ getInput()

ILIAS\User\Settings\StartingPoint\Setting::getInput ( FieldFactory  $field_factory,
Language  $lng,
Refinery  $refinery,
\ilSetting  $settings,
?\ilObjUser  $user = null 
)

Implements ILIAS\User\Settings\SettingDefinition.

Definition at line 67 of file Setting.php.

73 : Input {
74 $starting_point_id = null;
75 $object_ref_id = null;
76 if ($user !== null) {
77 [
78 'starting_point_id' => $starting_point_id ,
79 'object_id' => $object_ref_id
80 ] = $this->retrieveValueFromUser($user);
81 }
82 $possible_starting_points = $this->starting_point_repository->getPossibleStartingPoints();
83 return $field_factory->switchableGroup(
84 array_reduce(
85 array_keys($possible_starting_points),
86 static function (array $c, int $v) use (
87 $field_factory,
88 $lng,
89 $possible_starting_points,
90 $object_ref_id
91 ): array {
92 $c[$v] = $field_factory->group(
94 ? [
95 'usr_start_ref_id' => $field_factory->numeric(
96 $lng->txt('adm_user_starting_point_ref_id'),
97 $object_ref_id === null || ($start_obj_id = \ilObject::_lookupObjId($object_ref_id)) === 0
98 ? $lng->txt('adm_user_starting_point_ref_id_info')
99 : $lng->txt('obj_' . \ilObject::_lookupType($start_obj_id))
100 . ': ' . \ilObject::_lookupTitle($start_obj_id)
101 )->withRequired(true)
102 ] : [],
103 $lng->txt($possible_starting_points[$v])
104 );
105 return $c;
106 },
107 [
108 0 => $field_factory->group(
109 [],
110 $lng->txt('adm_user_starting_point_inherit'),
111 $lng->txt('adm_user_starting_point_inherit_info')
112 )
113 ]
114 ),
115 $lng->txt('adm_user_starting_point'),
116 $lng->txt('adm_user_starting_point_info')
117 )->withAdditionalTransformation(
119 )->withAdditionalTransformation(
120 $refinery->custom()->transformation(
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
124 ]
125 )
126 )->withValue(
128 $starting_point_id,
129 $object_ref_id
130 )
131 );
132 }
buildValueSetterArray(int $starting_point_id, ?int $object_ref_id)
Definition: Setting.php:267
buildValidateObjectConstraint(Refinery $refinery, Language $lng)
Definition: Setting.php:241
$c
Definition: deliver.php:25

References ILIAS\User\Settings\StartingPoint\Setting\retrieveValueFromUser().

+ Here is the call graph for this function:

◆ getLabel()

ILIAS\User\Settings\StartingPoint\Setting::getLabel ( Language  $lng)

Implements ILIAS\User\Property.

Definition at line 52 of file Setting.php.

52 : string
53 {
54 return $lng->txt($this->getIdentifier());
55 }

References $lng, and ILIAS\User\Settings\StartingPoint\Setting\getIdentifier().

+ Here is the call graph for this function:

◆ getLegacyInput()

ILIAS\User\Settings\StartingPoint\Setting::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, thus you can also not rely on the post_var anywhere else, as it will be changed.

Implements ILIAS\User\Settings\SettingDefinition.

Definition at line 134 of file Setting.php.

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);
143 }
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) {
150 if ($value === Repository::START_REPOSITORY_OBJ) {
151 continue;
152 }
153 $input->addOption(new \ilRadioOption($lng->txt($caption), (string) $value));
154 }
155 $input->setValue((string) $starting_point_id);
156
157 $starting_point_repository = new \ilRadioOption(
158 $lng->txt('adm_user_starting_point_object'),
160 );
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);
167 if (($start_obj_id = \ilObject::_lookupObjId($object_ref_id)) !== 0) {
168 $repository_object_id->setInfo(
169 $lng->txt('obj_' . \ilObject::_lookupType($start_obj_id)) .
170 ': ' . \ilObject::_lookupTitle($start_obj_id)
171 );
172 }
173 }
174 $starting_point_repository->addSubItem($repository_object_id);
175 $input->addOption($starting_point_repository);
176 return $input;
177 }
readonly Repository $starting_point_repository
Definition: Setting.php:35
This class represents a property in a property form.
This class represents an option in a radio group.

◆ getSection()

ILIAS\User\Settings\StartingPoint\Setting::getSection ( )

◆ getSettingsPage()

ILIAS\User\Settings\StartingPoint\Setting::getSettingsPage ( )

Implements ILIAS\User\Settings\SettingDefinition.

Definition at line 57 of file Setting.php.

58 {
59 return AvailablePages::MainSettings;
60 }

◆ hasUserPersonalizedSetting()

ILIAS\User\Settings\StartingPoint\Setting::hasUserPersonalizedSetting ( \ilSetting  $settings,
\ilObjUser  $user 
)

Implements ILIAS\User\Settings\SettingDefinition.

Definition at line 193 of file Setting.php.

196 : bool {
197 return $this->starting_point_repository->isPersonalStartingPointEnabledForUser($user);
198 }

◆ isAvailable()

ILIAS\User\Settings\StartingPoint\Setting::isAvailable ( )

If this function returns false the setting will not be shown, even if it's PropertyAttributes would allow it to be.

This is meant e.g. to check if the chat server is configured or the badges enabled. Settings that are not available will also not be available on the table to define their PropertyAttributes

Implements ILIAS\User\Settings\SettingDefinition.

Definition at line 47 of file Setting.php.

47 : bool
48 {
49 return true;
50 }

◆ persistUserInput()

ILIAS\User\Settings\StartingPoint\Setting::persistUserInput ( \ilObjUser  $user,
mixed  $input,
?\ilPropertyFormGUI  $form = null 
)

Definition at line 200 of file Setting.php.

204 : \ilObjUser {
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;
210 } else {
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;
214 }
215 $this->starting_point_repository->setPersonalStartingPointForUser(
216 $user,
217 $starting_point_id,
218 $object_ref_id
219 );
220 return $user;
221 }
User class.

◆ retrieveValueFromUser()

ILIAS\User\Settings\StartingPoint\Setting::retrieveValueFromUser ( \ilObjUser  $user)

Implements ILIAS\User\Property.

Definition at line 259 of file Setting.php.

259 : array
260 {
261 return [
262 'starting_point_id' => $this->starting_point_repository->getPersonalStartingPointForUser($user),
263 'object_id' => $this->starting_point_repository->getPersonalStartingObjectForUser($user)
264 ];
265 }

Referenced by ILIAS\User\Settings\StartingPoint\Setting\getInput().

+ Here is the caller graph for this function:

◆ validateUserChoice()

ILIAS\User\Settings\StartingPoint\Setting::validateUserChoice ( \ilGlobalTemplateInterface  $tpl,
Language  $lng,
\ilPropertyFormGUI  $form 
)

Definition at line 223 of file Setting.php.

227 : bool {
228 if ($form->getInput($this->getIdentifier()) !== Repository::START_REPOSITORY_OBJ) {
229 return true;
230 }
231
232 $ref_id = $form->getInput('usr_start_ref_id');
233 if (!is_numeric($ref_id) || !\ilObject::_exists((int) $ref_id, true)) {
234 $tpl->setOnScreenMessage('failure', $lng->txt('obj_ref_id_not_exist'), true);
235 return false;
236 }
237
238 return true;
239 }

Field Documentation

◆ $starting_point_repository

readonly Repository ILIAS\User\Settings\StartingPoint\Setting::$starting_point_repository
private

Definition at line 35 of file Setting.php.


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