ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilNotificationConfig.php
Go to the documentation of this file.
1<?php
2
7{
8 const TTL_LONG = 1800;
9 const TTL_SHORT = 120;
10
11 const DEFAULT_TTS = 5;
12
17 private $type;
18
25 private $link;
26 private $linktarget = '_self';
27
28 private $title;
29
35 private $iconPath;
36
39
50 private $disableAfterDelivery = false;
56 private $validForSeconds = 0;
57
62 protected $visibleForSeconds = 0;
63
68 private $handlerParams = array();
69
70 public function __construct($type)
71 {
72 $this->type = $type;
73 }
74
75 public function getType()
76 {
77 return $this->type;
78 }
79
80 public function setAutoDisable($value)
81 {
82 $this->disableAfterDelivery = $value;
83 }
84
86 {
87 return (bool)$this->disableAfterDelivery;
88 }
89
90 public function setLink($link)
91 {
92 $this->link = $link;
93 }
94
95 public function getLink()
96 {
97 return $this->link;
98 }
99
100 public function setIconPath($path)
101 {
102 $this->iconPath = $path;
103 }
104
105 public function getIconPath()
106 {
107 return $this->iconPath;
108 }
109
120 public function setTitleVar($name, $parameters = array(), $language_module = 'notification')
121 {
122 $this->title = new ilNotificationParameter($name, $parameters, $language_module);
123 }
124
125 public function getTitleVar()
126 {
127 return $this->title->getName();
128 }
129
142 public function setShortDescriptionVar($name, $parameters = array(), $language_module = 'notification')
143 {
144 $this->short_description = new ilNotificationParameter($name, $parameters, $language_module);
145 }
146
147 public function getShortDescriptionVar()
148 {
149 return $this->short_description->getName();
150 }
151
164 public function setLongDescriptionVar($name, $parameters = array(), $language_module = 'notification')
165 {
166 $this->long_description = new ilNotificationParameter($name, $parameters, $language_module);
167 }
168
169 public function getLongDescriptionVar()
170 {
171 return $this->long_description->getName();
172 }
173
174 public function getLanguageParameters()
175 {
176 return array(
177 'title' => $this->title,
178 'longDescription' => $this->long_description,
179 'shortDescription' => $this->short_description,
180 );
181 }
182
183 public function getLinktarget()
184 {
185 return $this->linktarget;
186 }
187
188 public function setLinktarget($linktarget)
189 {
190 $this->linktarget = $linktarget;
191 }
192
193 public function setValidForSeconds($seconds)
194 {
195 $this->validForSeconds = $seconds;
196 }
197
198 public function getValidForSeconds()
199 {
201 }
202
206 public function getVisibleForSeconds()
207 {
209 }
210
215 {
216 $this->visibleForSeconds = $visibleForSeconds;
217 }
218
219 protected function beforeSendToUsers()
220 {
221
222 }
223
224 protected function afterSendToUsers()
225 {
226
227 }
228
229 protected function beforeSendToListeners()
230 {
231
232 }
233
234 protected function afterSendToListeners()
235 {
236
237 }
238
243 final public function notifyByUsers(array $recipients, $processAsync = false)
244 {
245 require_once 'Services/Notifications/classes/class.ilNotificationSystem.php';
246 $this->beforeSendToUsers();
247 ilNotificationSystem::sendNotificationToUsers($this, $recipients, $processAsync);
248 $this->afterSendToUsers();
249 }
250
251 final public function notifyByListeners($ref_id, $processAsync = false)
252 {
253 require_once 'Services/Notifications/classes/class.ilNotificationSystem.php';
254 $this->beforeSendToListeners();
256 $this->afterSendToListeners();
257 }
258
259 final public function notifyByRoles(array $roles, $processAsync = false)
260 {
261 require_once 'Services/Notifications/classes/class.ilNotificationSystem.php';
262 //$this->beforeSendToListeners();
263 ilNotificationSystem::sendNotificationToRoles($this, $roles, $processAsync);
264 //$this->afterSendToListeners();
265 }
266
267 public function getUserInstance(ilObjUser $user, $languageVars, $defaultLanguage)
268 {
269 $notificationObject = new ilNotificationObject($this, $user);
270
271 $title = '';
272 $short = '';
273 $long = '';
274
275 if($languageVars[$this->title->getName()]->lang[$user->getLanguage()])
276 {
277 $title = $languageVars[$this->title->getName()]->lang[$user->getLanguage()];
278 }
279 else if($languageVars[$this->title->getName()]->lang[$defaultLanguage])
280 {
281 $title = $languageVars[$this->title->getName()]->lang[$defaultLanguage];
282 }
283 else
284 {
285 $title = $this->title->getName();
286 }
287
288 if($languageVars[$this->short_description->getName()]->lang[$user->getLanguage()])
289 {
290 $short = $languageVars[$this->short_description->getName()]->lang[$user->getLanguage()];
291 }
292 else if($languageVars[$this->short_description->getName()]->lang[$defaultLanguage])
293 {
294 $short = $languageVars[$this->short_description->getName()]->lang[$defaultLanguage];
295 }
296 else
297 {
298 $short = $this->short_description->getName();
299 }
300
301 if($languageVars[$this->long_description->getName()]->lang[$user->getLanguage()])
302 {
303 $long = $languageVars[$this->long_description->getName()]->lang[$user->getLanguage()];
304 }
305 else if($languageVars[$this->long_description->getName()]->lang[$defaultLanguage])
306 {
307 $long = $languageVars[$this->long_description->getName()]->lang[$defaultLanguage];
308 }
309 else
310 {
311 $long = $this->long_description->getName();
312 }
313
314 $notificationObject->title = $title;
315 $notificationObject->shortDescription = $short;
316 $notificationObject->longDescription = $long;
317
318 $notificationObject->iconPath = $this->iconPath;
319
320 return $notificationObject;
321 }
322
323 public function setHandlerParam($name, $value)
324 {
325 if(strpos($name, '.'))
326 {
327 $nsParts = explode('.', $name, 2);
328 $ns = $nsParts[0];
329 $field = $nsParts[1];
330 $this->handlerParams[$ns][$field] = $value;
331 }
332 else
333 {
334 $this->handlerParams[''][$name] = $value;
335 }
336 }
337
338 public function getHandlerParams()
339 {
341 }
342
343 public function unsetHandlerParam($name)
344 {
345 unset($this->handlerParams[$name]);
346 }
347}
348
355{
356
361
365 public $user;
366
367 public $title;
370 public $link;
372 public $iconPath;
374
376 {
377
378 $this->baseNotification = $baseNotification;
379 $this->user = $user;
380
381 $this->link = $this->baseNotification->getLink();
382 $this->linktarget = $this->baseNotification->getLinktarget();
383 $this->handlerParams = $this->baseNotification->getHandlerParams();
384 }
385
386 public function __sleep()
387 {
388 return array('title', 'shortDescription', 'longDescription', 'iconPath', 'link', 'linktarget', 'handlerParams');
389 }
390
391}
392
398{
399
400 private $name;
401 private $parameters = array();
402 private $language_module = array();
403
404 public function __construct($name, $parameters = array(), $language_module = 'notification')
405 {
406 $this->name = $name;
407 $this->parameters = $parameters;
408 $this->language_module = $language_module;
409 }
410
411 public function getName()
412 {
413 return $this->name;
414 }
415
416 public function getParameters()
417 {
418 return $this->parameters;
419 }
420
421 public function getLanguageModule()
422 {
424 }
425}
Describes a notification and provides methods for publishing this notification.
getUserInstance(ilObjUser $user, $languageVars, $defaultLanguage)
setVisibleForSeconds($visibleForSeconds)
notifyByListeners($ref_id, $processAsync=false)
setLongDescriptionVar($name, $parameters=array(), $language_module='notification')
Sets the name of the language variable to use as long description text.
setTitleVar($name, $parameters=array(), $language_module='notification')
Sets the name of the language variable to use as title.
setShortDescriptionVar($name, $parameters=array(), $language_module='notification')
Sets the name of the language variable to use as short description text.
notifyByRoles(array $roles, $processAsync=false)
notifyByUsers(array $recipients, $processAsync=false)
sends this notification to a list of users
A concrete notification based on the ilNotificationConfiguration and returned by ilNotificationConfig...
__construct(ilNotificationConfig $baseNotification, ilObjUser $user)
description of a localized parameter this information is used locate translations while processing no...
__construct($name, $parameters=array(), $language_module='notification')
static sendNotificationToRoles(ilNotificationConfig $notification, array $roles, $processAsync=false)
static sendNotificationToListeners(ilNotificationConfig $notification, $ref_id, $processAsync=false)
static sendNotificationToUsers(ilNotificationConfig $notification, $users, $processAsync=false)
getLanguage()
returns a 2char-language-string @access public
$ref_id
Definition: sahs_server.php:39
$path
Definition: index.php:22