diff options
| author | Thomas Hackl <hackl@data-quest.de> | 2025-04-28 11:42:31 +0200 |
|---|---|---|
| committer | Thomas Hackl <hackl@data-quest.de> | 2025-04-28 11:43:09 +0200 |
| commit | 17fabb65570d6514acaab52d7a25da4209986a3c (patch) | |
| tree | 5c4f8af3973ba28cdf53b742fe9ee4f11acb467e | |
| parent | c1231362dbf7bc8a4ef863428b8482ca82337a47 (diff) | |
Resolve "Töne in den neuen Benachrichtigungen ausbauen"
Closes #5562
Merge request studip/studip!4186
| -rw-r--r-- | app/controllers/settings/general.php | 5 | ||||
| -rw-r--r-- | app/views/settings/general.php | 12 | ||||
| -rw-r--r-- | db/migrations/6.0.50_cleanup_audio_notification_settings.php | 46 | ||||
| -rw-r--r-- | lib/include/html_head.inc.php | 2 | ||||
| -rw-r--r-- | lib/models/PersonalNotifications.php | 42 | ||||
| -rw-r--r-- | public/assets/sounds/blubb.mp3 | bin | 43192 -> 0 bytes | |||
| -rw-r--r-- | public/assets/sounds/notify-bad.mp3 | bin | 28722 -> 0 bytes | |||
| -rw-r--r-- | public/assets/sounds/notify-good.mp3 | bin | 23459 -> 0 bytes | |||
| -rw-r--r-- | public/assets/sounds/notify-not-good.mp3 | bin | 19599 -> 0 bytes | |||
| -rw-r--r-- | public/assets/sounds/notify-ok.mp3 | bin | 24695 -> 0 bytes | |||
| -rw-r--r-- | resources/assets/javascripts/bootstrap/settings.js | 15 | ||||
| -rw-r--r-- | resources/vue/components/SystemNotification.vue | 28 | ||||
| -rw-r--r-- | templates/header.php | 5 | ||||
| -rw-r--r-- | templates/layouts/base.php | 2 |
14 files changed, 46 insertions, 111 deletions
diff --git a/app/controllers/settings/general.php b/app/controllers/settings/general.php index a4ab73c..0d1daa3 100644 --- a/app/controllers/settings/general.php +++ b/app/controllers/settings/general.php @@ -75,11 +75,6 @@ class Settings_GeneralController extends Settings_SettingsController } else { PersonalNotifications::deactivate($this->user->id); } - if (Request::int('personal_notifications_audio_activated')) { - PersonalNotifications::activateAudioFeedback($this->user->id); - } else { - PersonalNotifications::deactivateAudioFeedback($this->user->id); - } $this->config->store('SYSTEM_NOTIFICATIONS_PLACEMENT', Request::get('system_notifications_placement')); PageLayout::postSuccess(_('Die Einstellungen wurden gespeichert.')); diff --git a/app/views/settings/general.php b/app/views/settings/general.php index d762eb2..7d49a2f 100644 --- a/app/views/settings/general.php +++ b/app/views/settings/general.php @@ -84,18 +84,6 @@ $start_pages = [ </label> <label> - <input type="checkbox" name="personal_notifications_audio_activated" - aria-describedby="personal_notifications_audio_activated_description" value="1" - <? if (PersonalNotifications::isAudioActivated($user->user_id)) echo 'checked'; ?>> - <?= _('Audio-Feedback zu Benachrichtigungen') ?> - <?= tooltipIcon(_('Wenn Sie ein neue Benachrichtigung erhalten, kann Sie Stud.IP mittels eines ' . - 'Ton-Effekts drauf aufmerksam machen. Dies hilft, falls der aktuelle Browser-Tab gerade nicht ' . - 'Stud.IP zeigt oder eine Benachrichtigung aus anderen Gründen visuell nicht wahrgenommen ' . - 'werden kann. Ggf. müssen Sie Toneffekte in Ihrem Browser oder Betriebssystem noch aktivieren ' . - 'bzw. erlauben.')) ?> - </label> - - <label> <?= _('Platzierung von Systembenachrichtigungen im Browserfenster') ?> <?= tooltipIcon(_('Sie können entscheiden, an welcher Stelle Ihres Browserfensters ' . 'Systembenachrichtigungen erscheinen sollen: mittig am oberen Rand oder rechts unten.')) ?> diff --git a/db/migrations/6.0.50_cleanup_audio_notification_settings.php b/db/migrations/6.0.50_cleanup_audio_notification_settings.php new file mode 100644 index 0000000..111a336 --- /dev/null +++ b/db/migrations/6.0.50_cleanup_audio_notification_settings.php @@ -0,0 +1,46 @@ +<?php +final class CleanupAudioNotificationSettings extends Migration +{ + public function description() + { + return 'Cleans up the automatic setting of audio notifications done in migration 6.0.22'; + } + + public function up() + { + // Delete config setting for audio notifications. + DBManager::get()->exec("DELETE `config`, `config_values` + FROM `config` + LEFT JOIN `config_values` USING (`field`) + WHERE `field` = 'PERSONAL_NOTIFICATIONS_AUDIO_DEACTIVATED'"); + + // Delete all personal notifications generated by migration 6.0.22. + $texts = [ + 'Aus technischen Gründen wurde das Audio-Feedback zu Benachrichtigungen in Ihrem Konto deaktiviert. ' + . 'Bitte aktivieren Sie dieses erneut, wenn Sie es weiterhin nutzen möchten.', + 'For technical reasons, the audio feedback for notifications has been deactivated in your account. ' + . 'Please reactivate it if you wish to continue using it.' + ]; + DBManager::get()->execute( + "DELETE `personal_notifications`, `personal_notifications_user` + FROM `personal_notifications` + LEFT JOIN `personal_notifications_user` USING (`personal_notification_id`) + WHERE `text` IN (:texts);", + ['texts' => $texts] + ); + } + + public function down() + { + DBManager::get()->execute("INSERT IGNORE INTO `config` + (`field`, `value`, `type`, `range`, `mkdate`, `chdate`, `description`) + VALUES (:field, :value, 'boolean', 'user', UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), :description)", + [ + ':field' => 'PERSONAL_NOTIFICATIONS_AUDIO_DEACTIVATED', + ':value' => '0', + ':description' => 'Deaktiviert das Abspielen von Tönen für die persönlichen Benachrichtigungen', + ] + ); + } + +} diff --git a/lib/include/html_head.inc.php b/lib/include/html_head.inc.php index 18fc27e..f65ba14 100644 --- a/lib/include/html_head.inc.php +++ b/lib/include/html_head.inc.php @@ -68,8 +68,6 @@ $lang_attr = str_replace('_', '-', $_SESSION['_language']); 'ENTRIES_PER_PAGE' => Config::get()->ENTRIES_PER_PAGE, 'OPENGRAPH_ENABLE' => Config::get()->OPENGRAPH_ENABLE, 'COURSEWARE_CERTIFICATES_ENABLE' => Config::get()->COURSEWARE_CERTIFICATES_ENABLE, - 'PERSONAL_NOTIFICATIONS_AUDIO_DEACTIVATED' => - (bool) User::findCurrent()?->getConfiguration()->PERSONAL_NOTIFICATIONS_AUDIO_DEACTIVATED, 'ENABLE_COURSESET_FCFS' => (bool) Config::get()->ENABLE_COURSESET_FCFS ]) ?>, jsonapi_schemas: <?= json_encode($getJsonApiSchemas()) ?>, diff --git a/lib/models/PersonalNotifications.php b/lib/models/PersonalNotifications.php index 1b1c886..1d753eb 100644 --- a/lib/models/PersonalNotifications.php +++ b/lib/models/PersonalNotifications.php @@ -325,30 +325,6 @@ class PersonalNotifications extends SimpleORMap } /** - * Activates audio plopp for new personal notifications for a given user. - * @param string|null $user_id : ID of special user the notification should belong to or (default:) null for current user - */ - public static function activateAudioFeedback($user_id = null) - { - if (!$user_id) { - $user_id = $GLOBALS['user']->id; - } - UserConfig::get($user_id)->store("PERSONAL_NOTIFICATIONS_AUDIO_DEACTIVATED", "0"); - } - - /** - * Deactivates audio plopp for new personal notifications for a given user. - * @param string|null $user_id : ID of special user the notification should belong to or (default:) null for current user - */ - public static function deactivateAudioFeedback($user_id = null) - { - if (!$user_id) { - $user_id = $GLOBALS['user']->id; - } - UserConfig::get($user_id)->store("PERSONAL_NOTIFICATIONS_AUDIO_DEACTIVATED", "1"); - } - - /** * Checks if personal notifications are activated for the whole Stud.IP. This * could be false for performance issues. * @return boolean : true if activated else false @@ -379,24 +355,6 @@ class PersonalNotifications extends SimpleORMap } /** - * Checks if a given user should hear audio plopp for new personal notification. - * Either the Stud.IP or the user could deactivate personal notification or - * audio feedback. If neither is the case, this function returns true. - * @param string|null $user_id : ID of special user the notification should belong to or (default:) null for current user - * @return boolean : true if activated else false - */ - public static function isAudioActivated($user_id = null) - { - if (!PersonalNotifications::isGloballyActivated() || !self::isActivated($user_id)) { - return false; - } - if (!$user_id) { - $user_id = $GLOBALS['user']->id; - } - return ! UserConfig::get($user_id)->getValue("PERSONAL_NOTIFICATIONS_AUDIO_DEACTIVATED"); - } - - /** * Returns whether there are any new/unseen notifications for the given * user id. */ diff --git a/public/assets/sounds/blubb.mp3 b/public/assets/sounds/blubb.mp3 Binary files differdeleted file mode 100644 index c0bc0c2..0000000 --- a/public/assets/sounds/blubb.mp3 +++ /dev/null diff --git a/public/assets/sounds/notify-bad.mp3 b/public/assets/sounds/notify-bad.mp3 Binary files differdeleted file mode 100644 index 7050f6b..0000000 --- a/public/assets/sounds/notify-bad.mp3 +++ /dev/null diff --git a/public/assets/sounds/notify-good.mp3 b/public/assets/sounds/notify-good.mp3 Binary files differdeleted file mode 100644 index 40cd30f..0000000 --- a/public/assets/sounds/notify-good.mp3 +++ /dev/null diff --git a/public/assets/sounds/notify-not-good.mp3 b/public/assets/sounds/notify-not-good.mp3 Binary files differdeleted file mode 100644 index 5173b02..0000000 --- a/public/assets/sounds/notify-not-good.mp3 +++ /dev/null diff --git a/public/assets/sounds/notify-ok.mp3 b/public/assets/sounds/notify-ok.mp3 Binary files differdeleted file mode 100644 index 5e652f9..0000000 --- a/public/assets/sounds/notify-ok.mp3 +++ /dev/null diff --git a/resources/assets/javascripts/bootstrap/settings.js b/resources/assets/javascripts/bootstrap/settings.js index 2acaabe..1e47e39 100644 --- a/resources/assets/javascripts/bootstrap/settings.js +++ b/resources/assets/javascripts/bootstrap/settings.js @@ -15,21 +15,6 @@ STUDIP.domReady(() => { }); $('#edit_userdata .email-change-confirm').hide(); - - const audioActive = $('input[name="personal_notifications_audio_activated"]'); - audioActive.on('change', function() { - if (audioActive.is(':checked')) { - navigator.permissions.query({name: 'autoplay'}) - .then(result => { - if (result.state !== 'granted') { - navigator.mediaDevices.getUserMedia({video: false, audio: true}); - } - }) - .catch(() => { - navigator.mediaDevices.getUserMedia({video: false, audio: true}); - }); - } - }); }); $(document).on('input', '#new_password', function() { diff --git a/resources/vue/components/SystemNotification.vue b/resources/vue/components/SystemNotification.vue index 411f302..01e2551 100644 --- a/resources/vue/components/SystemNotification.vue +++ b/resources/vue/components/SystemNotification.vue @@ -148,34 +148,6 @@ export default { this.globalOn('disrupt-system-notifications', this.disruptTimeout); this.globalOn('resume-system-notifications', this.initTimeout); - - if (!STUDIP.config?.PERSONAL_NOTIFICATIONS_AUDIO_DEACTIVATED) { - let audio = null; - switch (this.notification.type) { - case 'info': - audio = new Audio(STUDIP.ASSETS_URL + '/sounds/notify-ok.mp3'); - break; - case 'success': - audio = new Audio(STUDIP.ASSETS_URL + '/sounds/notify-good.mp3'); - break; - case 'warning': - case 'error': - audio = new Audio(STUDIP.ASSETS_URL + '/sounds/notify-not-good.mp3'); - break; - case 'exception': - audio = new Audio(STUDIP.ASSETS_URL + '/sounds/notify-bad.mp3'); - break; - } - - let timing = 300; - if (this.placement === 'bottomright') { - timing = 750; - } - - setTimeout(() => { - audio.play().catch(() => {}); - }, timing); - } }, unmounted() { this.globalOff('disrupt-system-notifications', this.disruptTimeout); diff --git a/templates/header.php b/templates/header.php index 85efbda..c598b66 100644 --- a/templates/header.php +++ b/templates/header.php @@ -158,11 +158,6 @@ if ($navigation) { <? endforeach ?> </ul> </div> - <? if (PersonalNotifications::isAudioActivated()): ?> - <audio id="audio_notification" preload="none"> - <source src="<?= Assets::url('sounds/blubb.mp3') ?>" type="audio/mpeg"> - </audio> - <? endif; ?> </div> </li> <? endif; ?> diff --git a/templates/layouts/base.php b/templates/layouts/base.php index 26f6414..6f155b9 100644 --- a/templates/layouts/base.php +++ b/templates/layouts/base.php @@ -65,8 +65,6 @@ $lang_attr = str_replace('_', '-', $_SESSION['_language']); 'ENTRIES_PER_PAGE' => Config::get()->ENTRIES_PER_PAGE, 'OPENGRAPH_ENABLE' => Config::get()->OPENGRAPH_ENABLE, 'COURSEWARE_CERTIFICATES_ENABLE' => Config::get()->COURSEWARE_CERTIFICATES_ENABLE, - 'PERSONAL_NOTIFICATIONS_AUDIO_DEACTIVATED' => - (bool) User::findCurrent()?->getConfiguration()->PERSONAL_NOTIFICATIONS_AUDIO_DEACTIVATED, 'ENABLE_COURSESET_FCFS' => (bool) Config::get()->ENABLE_COURSESET_FCFS ]) ?>, jsonapi_schemas: <?= json_encode($getJsonApiSchemas()) ?>, |
