aboutsummaryrefslogtreecommitdiff
path: root/db/migrations/6.0.50_cleanup_audio_notification_settings.php
blob: 111a336b6ed7375eb7d84e8c5af3517c024c5d4f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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',
            ]
        );
    }

}