Skip to content

Commit

Permalink
Fix osd deactiviation and naming
Browse files Browse the repository at this point in the history
  • Loading branch information
iszmais authored and mjansenDatabay committed Jul 5, 2024
1 parent 0431129 commit 16b169b
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 35 deletions.
4 changes: 1 addition & 3 deletions Services/Notifications/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,14 @@ The use of the [Toast](../../src/GlobalScreen/Scope/Toast/README.md) is mandator

### General Settings

#### On-Screen Notifications
#### Toasts

If enabled, users will be notified of certain events by pop-up notifications in the form of toasts.

Further all numeric values have to be set and the sum of **Presentation Time** and **Presentation Delay** must be less than **Refreshinterval**.
Otherwise the setting will not be saved and an error will occur.
The **Play a Sound** will only be effective if it has not been disabled by the user in their personal settings.

![OSD Settings](./docu/images/settings_enable_osd_en.png)

If disabled, all sub.settings will be removed and all existing On-Screen Notifications will be cleared.

## Specifications
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,18 @@
use ILIAS\Badge\GlobalScreen\BadgeNotificationProvider;
use ILIAS\Chatroom\GlobalScreen\ChatInvitationNotificationProvider;
use ILIAS\Contact\Provider\ContactNotificationProvider;
use ILIAS\GlobalScreen\Identification\IdentificationInterface;
use ILIAS\GlobalScreen\Scope\Toast\Provider\AbstractToastProvider;
use ILIAS\Notifications\ilNotificationOSDHandler;
use ILIAS\Notifications\Repository\ilNotificationOSDRepository;
use ILIAS\UI\Implementation\Component\Symbol\Icon\Icon;
use ILIAS\UI\Implementation\Component\Symbol\Icon\Standard;
use ILIAS\UI\Implementation\Component\Toast\Toast;
use ilSetting;
use function Sabre\Xml\Deserializer\functionCaller;

/**
* @author Ingmar Szmais <[email protected]>
*/
class NotificationToastProvider extends AbstractToastProvider
class NotificationsToastProvider extends AbstractToastProvider
{
/**
* @inheritDoc
Expand All @@ -46,14 +44,6 @@ public function getToasts(): array
$settings = new ilSetting('notifications');
$toasts = [];

if (
$settings->get('enable_osd', '0') !== '1' ||
0 === $this->dic->user()->getId() ||
$this->dic->user()->isAnonymous()
) {
return $toasts;
}

$osd_repository = new ilNotificationOSDRepository($this->dic->database());
$osd_notification_handler = new ilNotificationOSDHandler($osd_repository);

Expand Down
34 changes: 18 additions & 16 deletions Services/Notifications/classes/ilNotificationOSDGUI.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php

declare(strict_types=1);

/**
* This file is part of ILIAS, a powerful learning management system
* published by ILIAS open source e-Learning e.V.
Expand All @@ -18,6 +16,8 @@
*
*********************************************************************/

declare(strict_types=1);

namespace ILIAS\Notifications;

use ilGlobalTemplateInterface;
Expand Down Expand Up @@ -57,22 +57,24 @@ public function populatePage(): void

$notificationSettings = new ilSetting('notifications');

$osdTemplate = new ilTemplate('tpl.osd_notifications.js', true, true, 'Services/Notifications');
if ($notificationSettings->get('enable_osd', '0') === '1') {
$osdTemplate = new ilTemplate('tpl.osd_notifications.js', true, true, 'Services/Notifications');

$osdTemplate->setVariable(
'OSD_INTERVAL',
$notificationSettings->get('osd_interval', (string) self::DEFAULT_POLLING_INTERVAL)
);
$osdTemplate->setVariable(
'OSD_PLAY_SOUND',
$notificationSettings->get('osd_play_sound') && $this->user->getPref('osd_play_sound') ? 'true' : 'false'
);
$osdTemplate->setVariable(
'OSD_INTERVAL',
$notificationSettings->get('osd_interval', (string) self::DEFAULT_POLLING_INTERVAL)
);
$osdTemplate->setVariable(
'OSD_PLAY_SOUND',
$notificationSettings->get('osd_play_sound') && $this->user->getPref('osd_play_sound') ? 'true' : 'false'
);

iljQueryUtil::initjQuery($this->page);
ilPlayerUtil::initMediaElementJs($this->page);
iljQueryUtil::initjQuery($this->page);
ilPlayerUtil::initMediaElementJs($this->page);

$this->page->addJavaScript('Services/Notifications/templates/default/notifications.js');
$this->page->addCSS('Services/Notifications/templates/default/osd.css');
$this->page->addOnLoadCode($osdTemplate->get());
$this->page->addJavaScript('Services/Notifications/templates/default/notifications.js');
$this->page->addCSS('Services/Notifications/templates/default/osd.css');
$this->page->addOnLoadCode($osdTemplate->get());
}
}
}
Binary file not shown.
4 changes: 2 additions & 2 deletions lang/ilias_de.lang
Original file line number Diff line number Diff line change
Expand Up @@ -12285,7 +12285,7 @@ noti#:#noti_activate_notification#:#Benachrichtigung aktivieren
noti#:#noti_deactivate_notification#:#Benachrichtigung deaktivieren
noti#:#noti_notification_activated#:#Benachrichtigungen sind aktiviert
noti#:#noti_notification_deactivated#:#Benachrichtigungen sind deaktiviert
notifications_adm#:#enable_osd#:#Pop-up-Benachrichtigungen aktivieren
notifications_adm#:#enable_osd#:#Pop-up Benachrichtigungen aktivieren
notifications_adm#:#enable_osd_desc#:#Wenn aktiviert, werden Benutzer durch ein Pop-up über neue Benachrichtigungen informiert.
notifications_adm#:#notification_settings#:#Benachrichtigungseinstellungen
notifications_adm#:#osd_delay#:#Anzeigeverzögerung
Expand All @@ -12297,7 +12297,7 @@ notifications_adm#:#osd_interval#:#Abfrageintervall
notifications_adm#:#osd_interval_desc#:#Abfrageintervall für Nachrichten in Millisekunden.Eine geringere Zeit ermöglicht zeitnähere Benachrichtigungen, erhöht aber die Serverlast.
notifications_adm#:#osd_play_sound#:#Ton abspielen
notifications_adm#:#osd_play_sound_desc#:#Ton abspielen bei Erhalt einer neuen Benachrichtigung.
notifications_adm#:#osd_settings#:#Popup Benachrichtigungen
notifications_adm#:#osd_settings#:#Pop-up Benachrichtigungen
notifications_adm#:#osd_vanish#:#Anzeigedauer
notifications_adm#:#osd_vanish_desc#:#Dauer der Anzeige von Benachrichtigungen in Millisekunden
obj#:#cont_filter_empty#:#Bitte nutzen Sie den Filter zur Anzeige von Objekten.
Expand Down
6 changes: 3 additions & 3 deletions lang/ilias_en.lang
Original file line number Diff line number Diff line change
Expand Up @@ -12285,8 +12285,8 @@ noti#:#noti_activate_notification#:#Activate Notification
noti#:#noti_deactivate_notification#:#Deactivate Notification
noti#:#noti_notification_activated#:#Notification Activated
noti#:#noti_notification_deactivated#:#Notification Deactivated
notifications_adm#:#enable_osd#:#Enable On-Screen Notifications
notifications_adm#:#enable_osd_desc#:#If enabled, users are notified by a popup about new notifications.
notifications_adm#:#enable_osd#:#Enable Toasts
notifications_adm#:#enable_osd_desc#:#If enabled, users are notified by a pop-up about new notifications.
notifications_adm#:#notification_settings#:#Notification Settings
notifications_adm#:#osd_delay#:#Presentation Delay
notifications_adm#:#osd_delay_desc#:#Delay of the visible presentation in milliseconds.
Expand All @@ -12297,7 +12297,7 @@ notifications_adm#:#osd_interval#:#Refreshinterval
notifications_adm#:#osd_interval_desc#:#Polling interval for checking of new notifications in miliseconds. A lower number will notify the user more quickly but increases the number of requests the web server must handle.
notifications_adm#:#osd_play_sound#:#Play a Sound
notifications_adm#:#osd_play_sound_desc#:#Play a sound when receiving a new notficiation.
notifications_adm#:#osd_settings#:#On-Screen Notifications
notifications_adm#:#osd_settings#:#Toasts
notifications_adm#:#osd_vanish#:#Presentation Time
notifications_adm#:#osd_vanish_desc#:#Visible time of a notification on the screen in miliseconds.
obj#:#cont_filter_empty#:#Please use the filter to see any objects.
Expand Down

0 comments on commit 16b169b

Please sign in to comment.