ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
Setting.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\User\Settings;
22
27use ILIAS\Refinery\Factory as Refinery;
33
34class Setting implements Property
35{
36 public function __construct(
37 private SettingDefinition $definition,
38 private bool $changeable_by_user,
39 private bool $changeable_in_local_user_administration,
40 private bool $export
41 ) {
42 }
43
44 public function getIdentifier(): string
45 {
46 return $this->definition->getIdentifier();
47 }
48
49 public function getLabel(Language $lng): string
50 {
51 return $this->definition->getLabel($lng);
52 }
53
54 public function isChangeableByUser(): bool
55 {
56 return $this->changeable_by_user;
57 }
58
60 {
61 return $this->changeable_in_local_user_administration;
62 }
63
64 public function export(): bool
65 {
66 return $this->export;
67 }
68
70 {
71 return $this->definition->getSettingsPage();
72 }
73
74 public function getSection(): AvailableSections
75 {
76 return $this->definition->getSection();
77 }
78
79 public function getTableRow(
80 DataRowBuilder $row_builder,
82 ): DataRow {
83 return $row_builder->buildDataRow(
84 $this->definition->getIdentifier(),
85 [
86 'field' => $this->definition->getLabel($lng),
87 'changeable_by_user' => $this->changeable_by_user,
88 'changeable_in_local_user_administration' => $this->changeable_in_local_user_administration,
89 'export' => $this->export
90 ]
91 );
92 }
93
94 public function getInput(
95 FieldFactory $field_factory,
99 ?\ilObjUser $user = null
100 ): Input {
101 return $this->definition->getInput($field_factory, $lng, $refinery, $settings, $user);
102 }
103
104 public function getLegacyInput(
107 ?\ilObjUser $user = null
109 $input = $this->definition->getLegacyInput(
110 $lng,
111 $settings,
112 $user
113 );
114
115 $input->setPostVar($this->definition->getIdentifier());
116 return $input;
117 }
118
122 public function getForm(
124 FieldFactory $ff,
126 ): array {
127 return [
128 'setting' => $ff->group([
129 'changeable_by_user' => $ff->checkbox($lng->txt(
130 PropertyAttributes::ChangeableByUser->value
131 ))->withValue($this->changeable_by_user),
132 'changeable_in_local_user_administration' => $ff->checkbox($lng->txt(
133 PropertyAttributes::ChangeableInLocalUserAdministration->value
134 ))->withValue($this->changeable_in_local_user_administration),
135 'export' => $ff->checkbox($lng->txt(
136 PropertyAttributes::Export->value
137 ))->withValue($this->export),
139 $this->buildCreateSettingTransformation($refinery)
140 )
141 ];
142 }
143
147 ): string {
148 $default_value = $this->definition->getDefaultValueForDisplay($lng, $settings);
149 if ($default_value === null) {
150 return '';
151 }
152 return $default_value;
153 }
154
157 ?\ilObjUser $user
158 ): bool {
159 if ($user === null) {
160 return false;
161 }
162 return $this->definition->hasUserPersonalizedSetting($settings, $user);
163 }
164
165 public function persistUserInput(
166 \ilObjUser $user,
167 Context $context,
168 mixed $input,
169 ?\ilPropertyFormGUI $form = null
170 ): \ilObjUser {
171 if (!$context->isSettingAvailable($this)) {
172 throw new \DomainException('It is not possible to Change this from here!');
173 }
174 return $this->definition->persistUserInput($user, $input, $form);
175 }
176
177 public function retrieveValueFromUser(\ilObjUser $user): mixed
178 {
179 return $this->definition->retrieveValueFromUser($user);
180 }
181
182 public function validateUserChoice(
185 \ilPropertyFormGUI $form
186 ): ?bool {
187 return $this->definition->validateUserChoice($tpl, $lng, $form);
188 }
189
192 ): Transformation {
193 return $refinery->custom()->transformation(
194 function (array $vs): self {
195 $clone = clone $this;
196 $clone->changeable_by_user = $vs['changeable_by_user'];
197 $clone->changeable_in_local_user_administration = $vs['changeable_in_local_user_administration'];
198 $clone->export = $vs['export'];
199 return $clone;
200 }
201 );
202 }
203}
$settings
Definition: index.php:44
Builds data types.
Definition: Factory.php:36
__construct(private SettingDefinition $definition, private bool $changeable_by_user, private bool $changeable_in_local_user_administration, private bool $export)
Definition: Setting.php:36
getTableRow(DataRowBuilder $row_builder, Language $lng)
Definition: Setting.php:79
persistUserInput(\ilObjUser $user, Context $context, mixed $input, ?\ilPropertyFormGUI $form=null)
Definition: Setting.php:165
validateUserChoice(\ilGlobalTemplateInterface $tpl, Language $lng, \ilPropertyFormGUI $form)
Definition: Setting.php:182
getDefaultValueForDisplay(Language $lng, \ilSetting $settings)
Definition: Setting.php:144
getLabel(Language $lng)
Definition: Setting.php:49
hasUserPersonalizedSetting(\ilSetting $settings, ?\ilObjUser $user)
Definition: Setting.php:155
getLegacyInput(Language $lng, \ilSetting $settings, ?\ilObjUser $user=null)
Definition: Setting.php:104
buildCreateSettingTransformation(Refinery $refinery)
Definition: Setting.php:190
getForm(Language $lng, FieldFactory $ff, Refinery $refinery)
Definition: Setting.php:122
retrieveValueFromUser(\ilObjUser $user)
Definition: Setting.php:177
getInput(FieldFactory $field_factory, Language $lng, Refinery $refinery, \ilSetting $settings, ?\ilObjUser $user=null)
Definition: Setting.php:94
This class represents a property in a property form.
setPostVar(string $a_postvar)
User class.
This class represents a property form user interface.
ILIAS Setting Class.
return['3gp', '7z', 'ai', 'aif', 'aifc', 'aiff', 'au', 'arw', 'avi', 'backup', 'bak', 'bas', 'bpmn', 'bpmn2', 'bmp', 'bib', 'bibtex', 'bz', 'bz2', 'c', 'c++', 'cc', 'cct', 'cdf', 'cer', 'class', 'cls', 'conf', 'cpp', 'crt', 'crs', 'crw', 'cr2', 'css', 'cst', 'csv', 'cur', 'db', 'dcr', 'des', 'dng', 'doc', 'docx', 'dot', 'dotx', 'dtd', 'dvi', 'el', 'eps', 'epub', 'f', 'f77', 'f90', 'flv', 'for', 'g3', 'gif', 'gl', 'gan', 'ggb', 'gsd', 'gsm', 'gtar', 'gz', 'gzip', 'h', 'hpp', 'htm', 'html', 'htmls', 'ibooks', 'ico', 'ics', 'ini', 'ipynb', 'java', 'jbf', 'jpeg', 'jpg', 'js', 'jsf', 'jso', 'json', 'latex', 'lang', 'less', 'log', 'lsp', 'ltx', 'm1v', 'm2a', 'm2v', 'm3u', 'm4a', 'm4v', 'markdown', 'm', 'mat', 'md', 'mdl', 'mdown', 'mid', 'min', 'midi', 'mobi', 'mod', 'mov', 'movie', 'mp2', 'mp3', 'mp4', 'mpa', 'mpeg', 'mpg', 'mph', 'mpga', 'mpp', 'mpt', 'mpv', 'mpx', 'mv', 'mw', 'mv4', 'nb', 'nbp', 'nef', 'nif', 'niff', 'obj', 'obm', 'odt', 'ods', 'odp', 'odg', 'odf', 'oga', 'ogg', 'ogv', 'old', 'p', 'pas', 'pbm', 'pcl', 'pct', 'pcx', 'pdf', 'pgm', 'pic', 'pict', 'png', 'por', 'pov', 'project', 'properties', 'ppa', 'ppm', 'pps', 'ppsx', 'ppt', 'pptx', 'ppz', 'ps', 'psd', 'pwz', 'qt', 'qtc', 'qti', 'qtif', 'r', 'ra', 'ram', 'rar', 'rast', 'rda', 'rev', 'rexx', 'ris', 'rf', 'rgb', 'rm', 'rmd', 'rmi', 'rmm', 'rmp', 'rt', 'rtf', 'rtx', 'rv', 's', 's3m', 'sav', 'sbs', 'sec', 'sdml', 'sgm', 'sgml', 'smi', 'smil', 'srt', 'sps', 'spv', 'stl', 'svg', 'swa', 'swf', 'swz', 'tar', 'tex', 'texi', 'texinfo', 'text', 'tgz', 'tif', 'tiff', 'ttf', 'txt', 'tmp', 'uvproj', 'vdf', 'vimeo', 'viv', 'vivo', 'vrml', 'vsdx', 'vtt', 'wav', 'webm', 'wmv', 'wmx', 'wmz', 'woff', 'wwd', 'xhtml', 'xif', 'xls', 'xlsx', 'xmind', 'xml', 'xsl', 'xsd', 'zip']
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
A transformation is a function from one datatype to another.
This is what a factory for input fields looks like.
Definition: Factory.php:31
This describes commonalities between all inputs.
Definition: Input.php:47
readonly ilGlobalTemplateInterface $tpl
withAdditionalTransformation(Transformation $trafo)
@inheritDoc
withValue($value)
Get an input like this with another value displayed on the client side.
Definition: Group.php:61
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $lng
Definition: privfeed.php:26
if(!file_exists('../ilias.ini.php'))