ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilNotificationOSDGUI.php
Go to the documentation of this file.
1 <?php
2 
7 {
9  protected $user;
11  protected $page;
13  protected $lng;
15  private $ui;
16 
22  public function __construct(\ilGlobalTemplateInterface $page, \ilLanguage $language)
23  {
24  global $DIC;
25 
26  $this->user = $DIC->user();
27  $this->page = $page;
28  $this->lng = $language;
29  $this->ui = $DIC->ui();
30  }
31 
35  public function populatePage() : void
36  {
37  if ($this->user->isAnonymous() || 0 === (int) $this->user->getId()) {
38  return;
39  }
40 
41  $notificationSettings = new \ilSetting('notifications');
42  $chatSettings = new \ilSetting('chatroom');
43 
44  $osdTemplate = new \ilTemplate('tpl.osd_notifications.js', true, true, 'Services/Notifications');
45 
46  $notifications = \ilNotificationOSDHandler::getNotificationsForUser($this->user->getId());
47  $osdTemplate->setVariable(
48  'NOTIFICATION_CLOSE_HTML',
49  json_encode($this->ui->renderer()->render($this->ui->factory()->symbol()->glyph()->close()))
50  );
51  $osdTemplate->setVariable('INITIAL_NOTIFICATIONS', json_encode($notifications));
52  $osdTemplate->setVariable(
53  'OSD_POLLING_INTERVALL',
54  $notificationSettings->get('osd_polling_intervall') ? $notificationSettings->get('osd_polling_intervall') : '60'
55  );
56  $osdTemplate->setVariable(
57  'OSD_PLAY_SOUND',
58  $chatSettings->get('play_invitation_sound') && $this->user->getPref('chat_play_invitation_sound') ? 'true' : 'false'
59  );
60 
61  iljQueryUtil::initjQuery($this->page);
63 
64  $this->page->addJavaScript('Services/Notifications/templates/default/notifications.js');
65  $this->page->addCSS('Services/Notifications/templates/default/osd.css');
66  $this->page->addOnLoadCode($osdTemplate->get());
67  }
68 }
Class ilNotificationOSDGUI.
user()
Definition: user.php:4
static initMediaElementJs($a_tpl=null)
Init mediaelement.js scripts.
ui()
Definition: ui.php:5
static getNotificationsForUser($user_id, $append_osd_id_to_link=true, $max_age_seconds=0)
static initjQuery(ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
$DIC
Definition: xapitoken.php:46
language handling
__construct(\ilGlobalTemplateInterface $page, \ilLanguage $language)
ilNotificationOSDGUI constructor.