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');
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());
178 $event_date_start = $field->dateTime($this->
txt(self::F_EVENT_DATE_START))
180 ->withFormat($format)
181 ->withValue($has_event ? $this->
notification->getEventStart()->format($str) :
null)
183 $custom_trafo(
function (?DateTimeImmutable $v): ?\DateTimeImmutable {
190 $event_date_end = $field->dateTime($this->
txt(self::F_EVENT_DATE_END))
192 ->withFormat($format)
193 ->withValue($has_event ? $this->
notification->getEventEnd()->format($str) :
null)
195 $custom_trafo(
function (?DateTimeImmutable $v): ?\DateTimeImmutable {
203 $type_during_event = $field->select($this->
txt(self::F_TYPE_DURING_EVENT), $types)
206 $custom_trafo(
function ($v):
void {
207 if ($v !==
null && $v !==
'') {
213 $permanent = $field->switchableGroup([
214 self::F_PERMANENT .
'_yes' => $field->group([], $this->txt(self::F_PERMANENT .
'_yes')),
215 self::F_PERMANENT .
'_no' => $field->group(
217 self::F_DISPLAY_DATE_START => $display_date_start,
218 self::F_DISPLAY_DATE_END => $display_date_end,
219 self::F_EVENT_DATE_START => $event_date_start,
220 self::F_EVENT_DATE_END => $event_date_end,
221 self::F_TYPE_DURING_EVENT => $type_during_event
223 $this->
txt(self::F_PERMANENT .
'_no')
225 ], $this->
txt(self::F_PERMANENT), $this->
infoTxt(self::F_PERMANENT))
228 ) ? self::F_PERMANENT .
'_yes' : self::F_PERMANENT .
'_no'
231 $custom_trafo(
function ($v) {
232 $permanent = isset($v[0]) && $v[0] === self::F_PERMANENT .
'_yes';
235 && ($v[1][self::F_EVENT_DATE_START] ??
null) ===
null
236 && ($v[1][self::F_EVENT_DATE_END] ??
null) ===
null
241 return $permanent ? null : $v[1];
244 ->withAdditionalTransformation(
247 $this->
txt(
'error_false_date_configuration')
252 $dismissable = $field->checkbox($this->
txt(self::F_DISMISSABLE), $this->
infoTxt(self::F_DISMISSABLE))
255 $custom_trafo(
function ($v):
void {
261 $installed_languages = $this->
lng->getInstalledLanguages();
263 $this->
lng->loadLanguageModule(
'meta');
264 foreach ($installed_languages as $installed_language) {
265 $lang_options[$installed_language] = $this->
lng->txt(
"meta_l_" . $installed_language);
268 $limited_to_languages = $field->multiSelect(
'', $lang_options)->withValue(
269 array_intersect($this->
notification->getLimitedToLanguages(), $installed_languages)
272 $lang_value = $this->
notification->hasLanguageLimitation()
276 $languages = $field->switchableGroup([
277 self::F_SHOW_TO_ALL_LANGUAGES => $field->group(
279 $this->txt(self::F_SHOW_TO_ALL_LANGUAGES)
281 self::F_HAS_LANGUAGE_LIMITATION => $field->group(
282 [$limited_to_languages],
283 $this->
txt(self::F_HAS_LANGUAGE_LIMITATION)
284 )->withByline($this->
infoTxt(self::F_HAS_LANGUAGE_LIMITATION))
285 ], $this->
txt(
"languages"))
287 ->withAdditionalTransformation(
288 $custom_trafo(
function ($v):
void {
289 $has_language_limitation = ($v[0] ??
null) === self::F_HAS_LANGUAGE_LIMITATION;
290 $limited_to_languages = (array) ($v[1][0] ?? []);
291 $this->
notification->setHasLanguageLimitation($has_language_limitation);
292 $this->
notification->setLimitedToLanguages($limited_to_languages);
298 $limited_to_role_ids = $field->multiSelect(
'', $available_roles)
299 ->withValue($this->
notification->getLimitedToRoleIds());
305 $roles = $field->switchableGroup([
306 self::F_SHOW_TO_ALL_ROLES => $field->group(
308 $this->txt(self::F_SHOW_TO_ALL_ROLES)
309 )->withByline($this->infoTxt(self::F_SHOW_TO_ALL_ROLES)),
310 self::F_LIMIT_TO_ROLES => $field->group(
311 [$limited_to_role_ids],
312 $this->txt(self::F_LIMIT_TO_ROLES)
313 )->withByline($this->infoTxt(self::F_LIMIT_TO_ROLES))
314 ], $this->txt(self::F_PRESENTATION))
316 ->withAdditionalTransformation(
317 $custom_trafo(
function ($v):
void {
318 $limit_to_roles = ($v[0] ??
null) === self::F_LIMIT_TO_ROLES;
319 $limited_to_role_ids = (array) ($v[1][0] ?? []);
321 $this->
notification->setLimitedToRoleIds($limited_to_role_ids);
326 $section = $field->section([
327 self::F_TYPE => $denotation,
328 self::F_TITLE => $title,
329 self::F_BODY =>
$body,
330 self::F_PERMANENT => $permanent,
331 self::F_DISMISSABLE => $dismissable,
332 self::F_HAS_LANGUAGE_LIMITATION => $languages,
333 self::F_LIMIT_TO_ROLES => $roles,
338 $this->
form = $this->
ui->input()->container()->form()->standard(
341 )->withAdditionalTransformation(
342 $this->
refinery->custom()->transformation(fn($v) => array_shift($v))
348 $this->
form = $this->
form->withRequest($this->
http->request());
381 foreach ($this->rbac_review->getRolesByFilter($filter) as $role) {
382 $opt[(
int) $role[
'obj_id']] = (
string) $role[
'title'];
404 if ($display_start >= $display_end) {
407 if ($event_start ===
null && $event_end ===
null) {
410 if ($event_start ===
null || $event_end ===
null || $event_start >= $event_end) {
413 if ($event_start < $display_start) {
416 return $event_end <= $display_end;
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(?array $class_path, string $cmd, string $submit_caption="")