56 protected \ILIAS\UI\Factory
$ui;
70 $this->
ui = $DIC->ui()->factory();
71 $this->
renderer = $DIC->ui()->renderer();
72 $this->
http = $DIC->http();
73 $this->
ctrl = $DIC->ctrl();
74 $this->
lng = $DIC->language();
76 $this->rbac_review =
$DIC->rbac()->review();
80 protected function txt(
string $var): string
82 return $this->
lng->txt(
'msg_' . $var);
85 protected function infoTxt(
string $var): string
87 return $this->
txt($var .
'_info');
107 public function initForm(): void
109 $field = $this->
ui->input()->field();
118 $denotation = $field->select($this->
txt(self::F_TYPE), $types, $this->
infoTxt(self::F_TYPE))
121 ->withAdditionalTransformation(
122 $custom_trafo(
function ($v):
void {
128 $title = $field->text($this->
txt(self::F_TITLE), $this->
infoTxt(self::F_TITLE))
131 ->withAdditionalTransformation(
132 $custom_trafo(
function ($v):
void {
138 $body = $field->markdown(
140 $this->
txt(self::F_BODY),
144 ->withAdditionalTransformation(
145 $custom_trafo(
function ($v):
void {
152 $str = $format->toString() .
' H:i:s';
154 $display_date_start = $field->dateTime($this->
txt(self::F_DISPLAY_DATE_START))
156 ->withFormat($format)
157 ->withValue($this->
notification->getDisplayStart()->format($str))
159 $custom_trafo(
function (?DateTimeImmutable $v): ?\DateTimeImmutable {
160 $this->
notification->setDisplayStart($v ??
new DateTimeImmutable());
164 $display_date_end = $field->dateTime($this->
txt(self::F_DISPLAY_DATE_END))
166 ->withFormat($format)
167 ->withValue($this->
notification->getDisplayEnd()->format($str))
169 $custom_trafo(
function (?DateTimeImmutable $v): ?\DateTimeImmutable {
170 $this->
notification->setDisplayEnd($v ??
new DateTimeImmutable());
174 $event_date_start = $field->dateTime($this->
txt(self::F_EVENT_DATE_START))
176 ->withFormat($format)
177 ->withValue($this->
notification->getEventStart()->format($str))
179 $custom_trafo(
function (?DateTimeImmutable $v): ?\DateTimeImmutable {
180 $this->
notification->setEventStart($v ??
new DateTimeImmutable());
184 $event_date_end = $field->dateTime($this->
txt(self::F_EVENT_DATE_END))
186 ->withFormat($format)
187 ->withValue($this->
notification->getEventEnd()->format($str))
189 $custom_trafo(
function (?DateTimeImmutable $v): ?\DateTimeImmutable {
190 $this->
notification->setEventEnd($v ??
new DateTimeImmutable());
195 $type_during_event = $field->select($this->
txt(self::F_TYPE_DURING_EVENT), $types)
199 $custom_trafo(
function ($v):
void {
204 $permanent = $field->switchableGroup([
205 self::F_PERMANENT .
'_yes' => $field->group([], $this->txt(self::F_PERMANENT .
'_yes')),
206 self::F_PERMANENT .
'_no' => $field->group(
208 self::F_DISPLAY_DATE_START => $display_date_start,
209 self::F_DISPLAY_DATE_END => $display_date_end,
210 self::F_EVENT_DATE_START => $event_date_start,
211 self::F_EVENT_DATE_END => $event_date_end,
212 self::F_TYPE_DURING_EVENT => $type_during_event
214 $this->
txt(self::F_PERMANENT .
'_no')
216 ], $this->
txt(self::F_PERMANENT), $this->
infoTxt(self::F_PERMANENT))
219 ) ? self::F_PERMANENT .
'_yes' : self::F_PERMANENT .
'_no'
222 $custom_trafo(
function ($v) {
223 $permanent = isset($v[0]) && $v[0] === self::F_PERMANENT .
'_yes';
225 return $permanent ? null : $v[1];
228 ->withAdditionalTransformation(
229 $custom_constraint(
static function ($v):
bool {
239 if ($display_start >= $display_end) {
242 if ($event_start >= $event_end) {
245 if ($event_start < $display_start) {
248 return $event_end <= $display_end;
249 }, $this->
txt(
'error_false_date_configuration'))
253 $dismissable = $field->checkbox($this->
txt(self::F_DISMISSABLE), $this->
infoTxt(self::F_DISMISSABLE))
256 $custom_trafo(
function ($v):
void {
262 $installed_languages = $this->
lng->getInstalledLanguages();
264 $this->
lng->loadLanguageModule(
'meta');
265 foreach ($installed_languages as $installed_language) {
266 $lang_options[$installed_language] = $this->
lng->txt(
"meta_l_" . $installed_language);
269 $limited_to_languages = $field->multiSelect(
'', $lang_options)->withValue(
270 array_intersect($this->
notification->getLimitedToLanguages(), $installed_languages)
273 $lang_value = $this->
notification->hasLanguageLimitation()
277 $languages = $field->switchableGroup([
278 self::F_SHOW_TO_ALL_LANGUAGES => $field->group(
280 $this->txt(self::F_SHOW_TO_ALL_LANGUAGES)
282 self::F_HAS_LANGUAGE_LIMITATION => $field->group(
283 [$limited_to_languages],
284 $this->
txt(self::F_HAS_LANGUAGE_LIMITATION)
285 )->withByline($this->
infoTxt(self::F_HAS_LANGUAGE_LIMITATION))
286 ], $this->
txt(
"languages"))
288 ->withAdditionalTransformation(
289 $custom_trafo(
function ($v):
void {
290 $has_language_limitation = ($v[0] ??
null) === self::F_HAS_LANGUAGE_LIMITATION;
291 $limited_to_languages = (array) ($v[1][0] ?? []);
292 $this->
notification->setHasLanguageLimitation($has_language_limitation);
293 $this->
notification->setLimitedToLanguages($limited_to_languages);
299 $limited_to_role_ids = $field->multiSelect(
'', $available_roles)
300 ->withValue($this->
notification->getLimitedToRoleIds());
306 $roles = $field->switchableGroup([
307 self::F_SHOW_TO_ALL_ROLES => $field->group(
309 $this->txt(self::F_SHOW_TO_ALL_ROLES)
310 )->withByline($this->infoTxt(self::F_SHOW_TO_ALL_ROLES)),
311 self::F_LIMIT_TO_ROLES => $field->group(
312 [$limited_to_role_ids],
313 $this->txt(self::F_LIMIT_TO_ROLES)
314 )->withByline($this->infoTxt(self::F_LIMIT_TO_ROLES))
315 ], $this->txt(self::F_PRESENTATION))
317 ->withAdditionalTransformation(
318 $custom_trafo(
function ($v):
void {
319 $limit_to_roles = ($v[0] ??
null) === self::F_LIMIT_TO_ROLES;
320 $limited_to_role_ids = (array) ($v[1][0] ?? []);
322 $this->
notification->setLimitedToRoleIds($limited_to_role_ids);
327 $section = $field->section([
328 self::F_TYPE => $denotation,
329 self::F_TITLE => $title,
330 self::F_BODY => $body,
331 self::F_PERMANENT => $permanent,
332 self::F_DISMISSABLE => $dismissable,
333 self::F_HAS_LANGUAGE_LIMITATION => $languages,
334 self::F_LIMIT_TO_ROLES => $roles,
339 $this->
form = $this->
ui->input()->container()->form()->standard(
342 )->withAdditionalTransformation(
343 $this->
refinery->custom()->transformation(fn($v) => array_shift($v))
349 $this->
form = $this->
form->withRequest($this->
http->request());
382 foreach ($this->rbac_review->getRolesByFilter($filter) as $role) {
383 $opt[(
int) $role[
'obj_id']] = $role[
'title'] .
' (' . $role[
'obj_id'] .
')';
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
class ilRbacReview Contains Review functions of core Rbac.
An entity that renders components to a string output.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static http()
Fetches the global http state from ILIAS.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
form( $class_path, string $cmd, string $submit_caption="")