19declare(strict_types=1);
24use ILIAS\User\RedirectOnMissingWrite;
41use Psr\Http\Message\ServerRequestInterface;
45 use RedirectOnMissingWrite;
55 private readonly \
ilCtrl $ctrl,
58 private readonly UIFactory $ui_factory,
59 private readonly UIRenderer $ui_renderer,
61 private readonly ServerRequestInterface $request,
63 private readonly HttpService
$http,
64 private readonly
Repository $user_settings_repository
66 $this->available_settings = $this->user_settings_repository->get();
82 $this->redirectOnMissingWrite($this->
access, $this->
ctrl, $this->tpl, $this->
lng);
83 $cmd = $this->
ctrl->getCmd() .
'Cmd';
87 public function showCmd(?RoundTripModal $modal =
null): void
93 if ($modal !==
null) {
97 $this->tpl->setContent(
98 $this->ui_renderer->render($content)
104 $this->
http->saveResponse(
105 $this->
http->response()->withBody(
107 $this->ui_renderer->renderAsync($this->buildEditModal())
111 $this->
http->sendResponse();
112 $this->
http->close();
118 $data = $modal->getData();
119 if (
$data ===
null) {
121 $modal->withOnLoad($modal->getShowSignal())
126 $this->user_settings_repository->storeConfiguration(
$data[
'setting']);
127 $this->available_settings = $this->user_settings_repository->get();
128 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'usr_settings_saved'));
134 array $visible_column_ids,
138 ?array $additional_parameters
141 foreach ($this->available_settings as
$setting) {
151 ?array $additional_parameters
153 return count($this->available_settings);
158 return $this->ui_factory->table()->data(
160 $this->
lng->txt(
'user_settings'),
163 $this->ui_factory->table()->action()->single(
164 $this->lng->txt(
'edit_setting'),
166 $this->setting_id_token
168 ])->withRequest($this->request);
173 $cf = $this->ui_factory->table()->column();
175 'field' => $cf->text($this->
lng->txt(
'user_field'))->withIsSortable(
true),
176 'changeable_by_user' => $cf->boolean(
178 PropertyAttributes::ChangeableByUser->value
180 $this->ui_factory->symbol()->glyph()->checked(),
181 $this->ui_factory->symbol()->glyph()->unchecked()
182 )->withIsSortable(
true),
183 'changeable_in_local_user_administration' => $cf->boolean(
185 PropertyAttributes::ChangeableInLocalUserAdministration->value
187 $this->ui_factory->symbol()->glyph()->checked(),
188 $this->ui_factory->symbol()->glyph()->unchecked()
189 )->withIsSortable(
true),
190 'export' => $cf->boolean(
192 PropertyAttributes::Export->value
194 $this->ui_factory->symbol()->glyph()->checked(),
195 $this->ui_factory->symbol()->glyph()->unchecked()
196 )->withIsSortable(
true)
202 $identifier = $this->retrieveIdentifierFromQuery();
203 $this->
ctrl->setParameterByClass(self::class, $this->setting_id_token->getName(), $identifier);
204 return $this->ui_factory->modal()->roundtrip(
205 $this->
lng->txt(
'edit_setting'),
207 $this->user_settings_repository->getByIdentifier(
211 $this->ui_factory->input()->field(),
214 $this->ctrl->getFormActionByClass(self::class,
'save')
220 $identifier = $this->request_wrapper->retrieve(
221 $this->setting_id_token->getName(),
222 $this->refinery->byTrying([
223 $this->refinery->kindlyTo()->string(),
224 $this->refinery->kindlyTo()->listOf(
225 $this->refinery->kindlyTo()->string()
230 if (is_array($identifier)) {
231 return $identifier[0];
238 $order_array = $order->
get();
239 $key = array_key_first($order_array);
240 $factor = array_shift($order_array) ===
'ASC' ? 1 : -1;
241 if ($key ===
'field') {
243 $this->available_settings,
249 if ($key ===
'export') {
251 $this->available_settings,
257 if ($key ===
'changeable_by_user') {
259 $this->available_settings,
265 if ($key ===
'changeable_in_local_user_administration') {
267 $this->available_settings,
Builds a Color from either hex- or rgb values.
Both the subject and the direction need to be specified when expressing an order.
A simple class to express a naive range of whole positive numbers.
The scope of this class is split ilias-conform URI's into components.
Stream factory which enables the user to create streams without the knowledge of the concrete class.
static ofString(string $string)
Creates a new stream with an initial value.
acquireParameters(array $namespace, string ... $names)
array $available_settings
readonly URLBuilder $url_builder
getTotalRowCount(?array $filter_data, ?array $additional_parameters)
Mainly for the purpose of pagination-support, it is important to know about the total number of recor...
readonly URLBuilderToken $setting_id_token
__construct(private readonly \ILIAS\Language\Language $lng, private readonly \ilCtrl $ctrl, private readonly \ilAccess $access, private readonly \ilGlobalTemplateInterface $tpl, private readonly UIFactory $ui_factory, private readonly UIRenderer $ui_renderer, private readonly Refinery $refinery, private readonly ServerRequestInterface $request, private readonly RequestWrapper $request_wrapper, private readonly HttpService $http, private readonly Repository $user_settings_repository)
getRows(DataRowBuilder $row_builder, array $visible_column_ids, Range $range, Order $order, ?array $filter_data, ?array $additional_parameters)
This is called by the table to retrieve rows; map data-records to rows using the $row_builder e....
retrieveIdentifierFromQuery()
readonly URLBuilderToken $action_token
showCmd(?RoundTripModal $modal=null)
isChangeableInLocalUserAdministration()
Class ilAccessHandler Checks access for ILIAS objects.
Class ilCtrl provides processing control methods.
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Interface RequestWrapper.
This describes a Data Table.
An entity that renders components to a string output.
static http()
Fetches the global http state from ILIAS.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.