Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Stud.IP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jan-Hendrik Willms
Stud.IP
Commits
00d2a512
Commit
00d2a512
authored
5 months ago
by
Thomas Hackl
Browse files
Options
Downloads
Patches
Plain Diff
Resolve "Polishing: Töne für Notifications können nicht in allen Browsern abgespielt werden"
Closes #4684 Merge request
studip/studip!3485
parent
2ec89581
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
db/migrations/6.0.22_disable_audio_notifications_for_all.php
+82
-0
82 additions, 0 deletions
db/migrations/6.0.22_disable_audio_notifications_for_all.php
resources/assets/javascripts/bootstrap/settings.js
+15
-0
15 additions, 0 deletions
resources/assets/javascripts/bootstrap/settings.js
with
97 additions
and
0 deletions
db/migrations/6.0.22_disable_audio_notifications_for_all.php
0 → 100644
+
82
−
0
View file @
00d2a512
<?php
final
class
DisableAudioNotificationsForAll
extends
Migration
{
public
function
description
()
{
return
'Disable audio notifications for all users so that asking for audio permissions is triggered on re-activating'
;
}
protected
function
up
()
{
// Deactive audio feedback per default setting.
DBManager
::
get
()
->
execute
(
"INSERT IGNORE INTO `config`
(`field`, `value`, `type`, `range`, `mkdate`, `chdate`, `description`)
VALUES
(:field, :value, :type, :range, UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), :description)"
,
[
'field'
=>
'PERSONAL_NOTIFICATIONS_AUDIO_DEACTIVATED'
,
'value'
=>
1
,
'type'
=>
'boolean'
,
'range'
=>
'user'
,
'description'
=>
'Audio-Feedback zu Benachrichtigungen abschalten'
]
);
// Query default language
$query
=
"SELECT IFNULL(`config_values`.`value`, `config`.`value`)
FROM `config`
LEFT JOIN `config_values` USING (`field`)
WHERE `field` = 'DEFAULT_LANGUAGE'"
;
$default_language
=
DBManager
::
get
()
->
fetchColumn
(
$query
);
// Send notifications to users to inform of the change
$query
=
"SELECT IF(`user_info`.`preferred_language` = '', ?, `user_info`.`preferred_language`),
`user_id`
FROM `auth_user_md5`
JOIN `user_info` USING (`user_id`)
LEFT JOIN `config_values`
ON `range_id` = `user_id`
AND `field` = 'PERSONAL_NOTIFICATIONS_AUDIO_DEACTIVATED'
AND `value` = '1'
WHERE `config_values`.`range_id` IS NULL"
;
DBManager
::
get
()
->
fetchGroupedPairs
(
$query
,
[
$default_language
],
function
(
$user_ids
,
$language
)
{
$message
=
'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.'
;
if
(
str_starts_with
(
$language
,
'en'
))
{
$message
=
'For technical reasons, the audio feedback for '
.
'notifications has been deactivated in your account. '
.
'Please reactivate it if you wish to continue using it.'
;
}
// Create notification
$query
=
"INSERT INTO `personal_notifications`
(`url`, `text`, `avatar`, `mkdate`)
VALUES (?, ?, ?, UNIX_TIMESTAMP())"
;
DBManager
::
get
()
->
execute
(
$query
,
[
URLHelper
::
getURL
(
'dispatch.php/settings/general'
),
$message
,
Icon
::
create
(
'audio2'
)
->
asImagePath
()
]);
$id
=
DBManager
::
get
()
->
lastInsertId
();
// Assign users
$query
=
"INSERT INTO `personal_notifications_user`
(`personal_notification_id`, `user_id`)
VALUES (?, ?)"
;
foreach
(
$user_ids
as
$user_id
)
{
DBManager
::
get
()
->
execute
(
$query
,
[
$id
,
$user_id
]);
}
}
);
// Reset all users to default.
DBManager
::
get
()
->
exec
(
"DELETE FROM `config_values` WHERE `field` = 'PERSONAL_NOTIFICATIONS_AUDIO_DEACTIVATED'"
);
}
}
This diff is collapsed.
Click to expand it.
resources/assets/javascripts/bootstrap/settings.js
+
15
−
0
View file @
00d2a512
...
...
@@ -15,6 +15,21 @@ 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
(
error
=>
{
navigator
.
mediaDevices
.
getUserMedia
({
video
:
false
,
audio
:
true
});
});
}
});
});
//
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment