ILIAS  release_8 Revision v8.24
ADNProvider.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
22
29use Closure;
31
36{
37 protected \ILIAS\GlobalScreen\Helper\BasicAccessCheckClosures $access;
38
39 public function __construct(Container $dic)
40 {
43 }
44
48 public function getNotifications(): array
49 {
50 return [];
51 }
52
56 public function getAdministrativeNotifications(): array
57 {
58 $adns = [];
59
60 $i = fn (string $id): IdentificationInterface => $this->if->identifier($id);
65 foreach (ilADNNotification::get() as $item) {
66 $adn = $this->notification_factory->administrative($i((string) $item->getId()))->withTitle($item->getTitle())->withSummary($item->getBody());
67 $adn = $this->handleDenotation($item, $adn);
68
69 $is_visible = static fn (): bool => true;
70
71 // is limited to roles
72 if ($item->isLimitToRoles()) {
73 $is_visible = $this->combineClosure($is_visible, fn () => $this->dic->rbac()->review()->isAssignedToAtLeastOneGivenRole(
74 $this->dic->user()->getId(),
75 $item->getLimitedToRoleIds()
76 ));
77 }
78
79 // is dismissale
80 if ($item->getDismissable() && $this->access->isUserLoggedIn()()) {
81 $adn = $adn->withClosedCallable(function () use ($item): void {
82 $item->dismiss($this->dic->user());
83 });
84 $is_visible = $this->combineClosure($is_visible, fn (): bool => !\ilADNDismiss::hasDimissed($this->dic->user(), $item));
85 }
86
87 $is_visible = $this->combineClosure($is_visible, fn (): bool => $item->isVisibleForUser($this->dic->user()));
88
89 $adns[] = $adn->withVisibilityCallable($is_visible);
90 }
91 return $adns;
92 }
93
94 private function handleDenotation(
99 switch ($type) {
101 return $adn->withBreakingDenotation();
103 return $adn->withImportantDenotation();
105 default:
106 return $adn->withNeutralDenotation();
107 }
108 };
109
110 // denotation during event
111 if (!$item->isPermanent() && $item->isDuringEvent()) {
112 return $settype($item->getTypeDuringEvent(), $adn);
113 }
114 return $settype($item->getType(), $adn);
115 }
116
117 private function combineClosure(Closure $closure, ?Closure $additional = null): Closure
118 {
119 if ($additional instanceof Closure) {
120 return static fn (): bool => $additional() && $closure();
121 }
122
123 return $closure;
124 }
125}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
static return function(ContainerConfigurator $containerConfigurator)
Definition: basic_rector.php:9
handleDenotation(ilADNNotification $item, AdministrativeNotification $adn)
Definition: ADNProvider.php:94
ILIAS GlobalScreen Helper BasicAccessCheckClosures $access
Definition: ADNProvider.php:37
combineClosure(Closure $closure, ?Closure $additional=null)
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:32
return true
static hasDimissed(ilObjUser $ilObjUser, ilADNNotification $ilADNNotification)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if(!file_exists(getcwd() . '/ilias.ini.php'))
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: confirmReg.php:20
$additional
Definition: goto.php:53
$i
Definition: metadata.php:41
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: ADNProvider.php:21
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$type