ILIAS  trunk Revision v11.0_alpha-1753-gb21ca8c4367
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 ilSetting;
28 use ilTemplate;
29 
34 {
35  final public const DEFAULT_POLLING_INTERVAL = 60000;
36 
37  protected ilObjUser $user;
38 
39  public function __construct(protected ilGlobalTemplateInterface $page, protected ilLanguage $lng)
40  {
41  global $DIC;
42 
43  $this->user = $DIC->user();
44  }
45 
46  public function populatePage(): void
47  {
48  if ($this->user->isAnonymous() || 0 === $this->user->getId()) {
49  return;
50  }
51 
52  $notificationSettings = new ilSetting('notifications');
53  if ($notificationSettings->get('enable_osd', '0') !== '1') {
54  return;
55  }
56 
57  $osdTemplate = new ilTemplate('tpl.osd_notifications.js', true, true, 'components/ILIAS/Notifications');
58 
59  $osdTemplate->setVariable(
60  'OSD_INTERVAL',
61  $notificationSettings->get('osd_interval', (string) self::DEFAULT_POLLING_INTERVAL)
62  );
63  $osdTemplate->setVariable(
64  'OSD_PLAY_SOUND',
65  $notificationSettings->get('osd_play_sound') && $this->user->getPref('osd_play_sound') ? 'true' : 'false'
66  );
67 
68  iljQueryUtil::initjQuery($this->page);
69 
70  $this->page->addJavaScript('assets/js/notifications.js');
71  $this->page->addCSS('assets/css/osd.css');
72  $this->page->addOnLoadCode($osdTemplate->get());
73  }
74 }
__construct(protected ilGlobalTemplateInterface $page, protected ilLanguage $lng)
static initjQuery(?ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
global $DIC
Definition: shib_login.php:22
global $lng
Definition: privfeed.php:31