19declare(strict_types=1);
34 private readonly UIFactory $ui_factory,
51 function (array
$c, array $v) use ($pages,
$context, $user): array {
53 if ($settings === []) {
57 $page = $settings[0]->getSettingsPage();
58 $section = $settings[0]->getSection();
66 if (!in_array(AvailablePages::MainSettings, $pages)
67 || $page === AvailablePages::MainSettings && $section === AvailableSections::Main) {
71 $c[$section_key] = $this->ui_factory->input()->field()->optionalGroup(
73 $this->
lng->txt(
"personalise_{$section_key}"),
78 $c[$section_key] =
$c[$section_key]->withValue(
null);
97 $this->getSettingsForPagesBySections($pages),
101 $this->filterSettingsInSectionForAvailability(
$context, $v)
110 return $this->checkStartingPointValue($form);
125 foreach ($this->getSettingsForPagesBySections($pages) as $section => $settings) {
126 $available_settings = $this->filterSettingsInSectionForAvailability(
$context, $settings);
127 $set_settings_to_default =
false;
130 is_array($form) && $form[$section] ===
null
132 && (($input = $form->getInput($section)) ===
'' || $input ===
'0')
135 $set_settings_to_default =
true;
137 foreach ($available_settings as $setting) {
138 $setting->persistUserInput(
141 $set_settings_to_default ?
null : $this->retrieveValueFromInputs($form, $setting),
152 string $definition_class
154 $setting = $this->user_settings_configuration_repository->getByDefinitionClass($definition_class);
155 if ($setting ===
null) {
156 throw new \UnexpectedValueException(
'No class by that name');
162 string $definition_class,
166 $this->getSettingByDefinitionClass($definition_class)->getIdentifier()
171 string $definition_class
174 $this->getSettingByDefinitionClass($definition_class)
180 return $this->user_settings_data_repository->getFor(
$user_id)[$key] ??
null;
187 $this->user_settings_configuration_repository->get(),
198 return $this->reorderSections(
200 $this->user_settings_configuration_repository->
get(),
201 function (array
$c,
Setting $v) use ($pages): array {
202 if (!in_array($v->getSettingsPage(), $pages)) {
206 $section_key = $this->buildSectionKey($v);
207 if (!array_key_exists($section_key,
$c)) {
208 $c[$section_key] = [];
211 $c[$section_key][] = $v;
223 $default_section = $sections[AvailableSections::Main->value];
224 unset($sections[AvailableSections::Main->value]);
225 array_unshift($sections, $default_section);
242 function (array
$c,
Setting $v) use ($user): array {
243 $c[
'inputs'][$v->getIdentifier()] = $v->getInput(
244 $this->ui_factory->input()->field(),
250 $c[
'byline'] .=
"{$v->getLabel($this->lng)}: "
251 .
"{$v->getDefaultValueForDisplay($this->lng, $this->settings)}; ";
252 if ($v->hasUserPersonalizedSetting($this->settings, $user)) {
253 $c[
'personalized'] =
true;
259 'byline' =>
"{$this->lng->txt('default')}<br>",
260 'personalized' => false
270 if ($section === []) {
274 if ($section[0]->getSettingsPage() === AvailablePages::MainSettings
275 && $section[0]->getSection() === AvailableSections::Main) {
276 return $this->addDefaultInputsToLegacyForm($form, $user, $section);
279 return $this->addAdditionalInputsToLegacyForm($form, $user, $section);
290 $input = $v->getLegacyInput($this->
lng, $this->
settings, $user);
303 $section_key = $this->buildSectionKey($section[0]);
304 $values = array_reduce(
306 function (array
$c,
Setting $v) use ($user): array {
309 $c[
'checkbox']->addSubItem($input);
310 $c[
'defaults'] .=
"{$v->getLabel($this->lng)}: "
311 .
"{$v->getDefaultValueForDisplay($this->lng, $this->settings)}; ";
313 $c[
'has_personalization'] = true;
318 'checkbox' => new \ilCheckboxInputGUI(
319 $this->
lng->txt(
"personalise_{$section_key}"),
322 'defaults' =>
"{$this->lng->txt('default')}<br>",
323 'has_personalization' => false
326 $values[
'checkbox']->setInfo(trim($values[
'defaults']));
327 $values[
'checkbox']->setChecked($values[
'has_personalization']);
329 $form->
addItem($values[
'checkbox']);
361 $section_key = $this->buildSectionKey($setting);
363 if ($section_key === AvailableSections::Main->value) {
364 return $form[$setting->getIdentifier()];
366 return $form[$section_key][$setting->getIdentifier()];
371 return $form->
getInput(
'additional') ===
''
372 || $this->user_settings_configuration_repository->getByIdentifier(
'starting_point')->validateUserChoice($this->tpl, $this->
lng, $form);
Builds a Color from either hex- or rgb values.
hasUserPersonalizedSetting(\ilSetting $settings, ?\ilObjUser $user)
getLegacyInput(Language $lng, \ilSetting $settings, ?\ilObjUser $user=null)
addSectionsToLegacyForm(\ilPropertyFormGUI $form, array $pages, Context $context, ?\ilObjUser $user)
buildInputsForSection(array $settings, ?\ilObjUser $user)
getSettingByDefinitionClass(string $definition_class)
settingAvailableToUser(string $definition_class)
__construct(private readonly Language $lng, private readonly \ilSetting $settings, private readonly \ilGlobalTemplateInterface $tpl, private readonly UIFactory $ui_factory, private readonly Refinery $refinery, private readonly ConfigurationRepository $user_settings_configuration_repository, private readonly DataRepository $user_settings_data_repository)
getSettingsForPagesBySections(array $pages)
getSettingValueFor(int $user_id, string $key)
buildFormInputs(array $pages, Context $context, ?\ilObjUser $user)
retrieveValuefromInputs(\ilPropertyFormGUI|array $form, Setting $setting)
addSectionToLegacyForm(\ilPropertyFormGUI $form, ?\ilObjUser $user, array $section)
performAdditionalChecks(\ilPropertyFormGUI $form)
checkStartingPointValue(\ilPropertyFormGUI $form)
addAdditionalInputsToLegacyForm(\ilPropertyFormGUI $form, ?\ilObjUser $user, array $section)
saveForm(\ilPropertyFormGUI|array $form, array $pages, Context $context, \ilObjUser $user)
If it is possible to set the preference on the user, this is what will be done, the user needs to be ...
addDefaultInputsToLegacyForm(\ilPropertyFormGUI $form, ?\ilObjUser $user, array $section)
filterSettingsInSectionForAvailability(Context $context, array $settings)
getValueFromLegacyFormByDefinitionClass(string $definition_class, \ilPropertyFormGUI $form)
reorderSections(array $sections)
buildSectionKey(Setting $setting)
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if(!file_exists('../ilias.ini.php'))