ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilNotificationOSDGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 namespace ILIAS\Notifications;
22 
24 use iljQueryUtil;
25 use ilLanguage;
26 use ilObjUser;
27 use ilPlayerUtil;
28 use ilSetting;
29 use ilTemplate;
30 
35 {
36  final public const DEFAULT_POLLING_INTERVAL = 60000;
37 
38  protected ilObjUser $user;
39 
40  public function __construct(protected ilGlobalTemplateInterface $page, protected ilLanguage $lng)
41  {
42  global $DIC;
43 
44  $this->user = $DIC->user();
45  }
46 
47  public function populatePage(): void
48  {
49  if ($this->user->isAnonymous() || 0 === $this->user->getId()) {
50  return;
51  }
52 
53  $notificationSettings = new ilSetting('notifications');
54 
55  if ($notificationSettings->get('enable_osd', '0') === '1') {
56  $osdTemplate = new ilTemplate('tpl.osd_notifications.js', true, true, 'Services/Notifications');
57 
58  $osdTemplate->setVariable(
59  'OSD_INTERVAL',
60  $notificationSettings->get('osd_interval', (string) self::DEFAULT_POLLING_INTERVAL)
61  );
62  $osdTemplate->setVariable(
63  'OSD_PLAY_SOUND',
64  $notificationSettings->get('osd_play_sound') && $this->user->getPref('osd_play_sound') ? 'true' : 'false'
65  );
66 
67  iljQueryUtil::initjQuery($this->page);
69 
70  $this->page->addJavaScript('Services/Notifications/templates/default/notifications.js');
71  $this->page->addCSS('Services/Notifications/templates/default/osd.css');
72  $this->page->addOnLoadCode($osdTemplate->get());
73  }
74  }
75 }
__construct(protected ilGlobalTemplateInterface $page, protected ilLanguage $lng)
global $DIC
Definition: feed.php:28
$lng
static initjQuery(ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
static initMediaElementJs(ilGlobalTemplateInterface $a_tpl=null)
Init mediaelement.js scripts.