ILIAS  release_8 Revision v8.24
ilNotificationConfig.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
22
26use ilObjUser;
27
32{
33 public const TTL_LONG = 1800;
34 public const TTL_SHORT = 120;
35 public const DEFAULT_TTS = 5;
36
37 private string $type;
41 private array $links = [];
43 private string $iconPath;
46 private bool $disableAfterDelivery = false;
47 private int $validForSeconds = 0;
48 protected int $visibleForSeconds = 0;
49 private array $handlerParams = [];
51
53 {
54 $this->type = $provider;
55 if ($identification === null) {
57 }
58 $this->identification = $identification;
59 }
60
61 public function getType(): string
62 {
63 return $this->type;
64 }
65
66 public function setAutoDisable(bool $value): void
67 {
68 $this->disableAfterDelivery = $value;
69 }
70
71 public function hasDisableAfterDeliverySet(): bool
72 {
74 }
75
79 public function setLinks(array $links): void
80 {
81 $this->links = $links;
82 }
83
87 public function getLinks(): array
88 {
89 return $this->links;
90 }
91
92 public function setIconPath(string $path): void
93 {
94 $this->iconPath = $path;
95 }
96
97 public function getIconPath(): ?string
98 {
99 return $this->iconPath;
100 }
101
105 public function setTitleVar(string $name, array $parameters = [], string $language_module = 'notification'): void
106 {
107 $this->title = new ilNotificationParameter($name, $parameters, $language_module);
108 }
109
110 public function getTitleVar(): string
111 {
112 return $this->title->getName();
113 }
114
118 public function setShortDescriptionVar(string $name, array $parameters = [], string $language_module = 'notification'): void
119 {
120 $this->short_description = new ilNotificationParameter($name, $parameters, $language_module);
121 }
122
123 public function getShortDescriptionVar(): string
124 {
125 return $this->short_description->getName();
126 }
127
131 public function setLongDescriptionVar(string $name, array $parameters = [], string $language_module = 'notification'): void
132 {
133 $this->long_description = new ilNotificationParameter($name, $parameters, $language_module);
134 }
135
136 public function getLongDescriptionVar(): string
137 {
138 return $this->long_description->getName();
139 }
140
144 public function getLanguageParameters(): array
145 {
146 $params = [
147 'title' => $this->title,
148 'longDescription' => $this->long_description,
149 'shortDescription' => $this->short_description,
150 ];
151
152 foreach ($this->links as $id => $link) {
153 $params['link_' . $id] = $link->getTitle();
154 }
155
156 return $params;
157 }
158
159 public function setValidForSeconds(int $seconds): void
160 {
161 $this->validForSeconds = $seconds;
162 }
163
164 public function getValidForSeconds(): int
165 {
167 }
168
169 public function getVisibleForSeconds(): int
170 {
172 }
173
177 public function setVisibleForSeconds(int $visibleForSeconds): void
178 {
179 $this->visibleForSeconds = $visibleForSeconds;
180 }
181
182 protected function beforeSendToUsers(): void
183 {
184 }
185
186 protected function afterSendToUsers(): void
187 {
188 }
189
190 protected function beforeSendToListeners(): void
191 {
192 }
193
194 protected function afterSendToListeners(): void
195 {
196 }
197
201 final public function notifyByUsers(array $recipients, bool $processAsync = false): void
202 {
203 $this->beforeSendToUsers();
204 ilNotificationSystem::sendNotificationToUsers($this, $recipients, $processAsync);
205 $this->afterSendToUsers();
206 }
207
208 final public function notifyByListeners(int $ref_id, $processAsync = false): void
209 {
210 $this->beforeSendToListeners();
212 $this->afterSendToListeners();
213 }
214
218 final public function notifyByRoles(array $roles, bool $processAsync = false): void
219 {
220 ilNotificationSystem::sendNotificationToRoles($this, $roles, $processAsync);
221 }
222
223 public function getUserInstance(ilObjUser $user, array $languageVars, string $defaultLanguage): ilNotificationObject
224 {
225 $notificationObject = new ilNotificationObject($this, $user);
226
227 $title = $this->title->getName();
228 if (isset($languageVars[$this->title->getName()])) {
229 $var = $languageVars[$this->title->getName()]->lang;
230 if (isset($var[$user->getLanguage()])) {
231 $title = $var[$user->getLanguage()];
232 } elseif (isset($var[$defaultLanguage])) {
233 $title = $var[$defaultLanguage];
234 }
235 }
236 $notificationObject->title = $title;
237
238 $short = $this->short_description->getName();
239 if (isset($languageVars[$this->short_description->getName()])) {
240 $var = $languageVars[$this->short_description->getName()]->lang;
241 if (isset($var[$user->getLanguage()])) {
242 $short = $var[$user->getLanguage()];
243 } elseif (isset($var[$defaultLanguage])) {
244 $short = $var[$defaultLanguage];
245 }
246 }
247 $notificationObject->shortDescription = $short;
248
249 $long = $this->long_description->getName();
250 if (isset($languageVars[$this->long_description->getName()])) {
251 $var = $languageVars[$this->long_description->getName()]->lang;
252 if (isset($var[$user->getLanguage()])) {
253 $long = $var[$user->getLanguage()];
254 } elseif (isset($var[$defaultLanguage])) {
255 $long = $var[$defaultLanguage];
256 }
257 }
258 $notificationObject->longDescription = $long;
259
260 $process_links = [];
261 foreach ($this->links as $link) {
262 $link_title = $link->getTitle()->getName();
263 if (isset($languageVars[$link->getTitle()->getName()])) {
264 $var = $languageVars[$link->getTitle()->getName()]->lang;
265 if (isset($var[$user->getLanguage()])) {
266 $link_title = $var[$user->getLanguage()];
267 } elseif (isset($var[$defaultLanguage])) {
268 $link_title = $var[$defaultLanguage];
269 }
270 }
271
272 $process_link = clone $link;
273 $process_link->setTitle($link_title);
274 $process_links[] = $process_link;
275 }
276 $notificationObject->links = $process_links;
277
278 $notificationObject->iconPath = $this->iconPath;
279
280 return $notificationObject;
281 }
282
283 public function setHandlerParam(string $name, string $value): void
284 {
285 if (strpos($name, '.')) {
286 $nsParts = explode('.', $name, 2);
287 $ns = $nsParts[0];
288 $field = $nsParts[1];
289 $this->handlerParams[$ns][$field] = $value;
290 } else {
291 $this->handlerParams[''][$name] = $value;
292 }
293 }
294
295 public function getHandlerParams(): array
296 {
298 }
299
300 public function unsetHandlerParam(string $name): void
301 {
302 unset($this->handlerParams[$name]);
303 }
304
306 {
307 $this->identification = $identification;
308 }
309
311 {
313 }
314}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
setTitleVar(string $name, array $parameters=[], string $language_module='notification')
notifyByUsers(array $recipients, bool $processAsync=false)
notifyByListeners(int $ref_id, $processAsync=false)
setIdentification(NotificationIdentification $identification)
getUserInstance(ilObjUser $user, array $languageVars, string $defaultLanguage)
notifyByRoles(array $roles, bool $processAsync=false)
setLongDescriptionVar(string $name, array $parameters=[], string $language_module='notification')
__construct(string $provider, ?NotificationIdentification $identification=null)
setShortDescriptionVar(string $name, array $parameters=[], string $language_module='notification')
description of a localized parameter this information is used locate translations while processing no...
static sendNotificationToUsers(ilNotificationConfig $notification, array $users, bool $processAsync=false)
static sendNotificationToRoles(ilNotificationConfig $notification, array $roles, bool $processAsync=false)
static sendNotificationToListeners(ilNotificationConfig $notification, int $ref_id, bool $processAsync=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
User class.
$ref_id
Definition: ltiauth.php:67
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:33
$path
Definition: ltiservices.php:32
$provider
Definition: ltitoken.php:83
if($format !==null) $name
Definition: metadata.php:247
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$defaultLanguage
Definition: xapiexit.php:24