MDL-65219 message: default disable contact request notifications for web
authorRyan Wyllie <ryan@moodle.com>
Mon, 15 Jul 2019 06:30:58 +0000 (14:30 +0800)
committerRyan Wyllie <ryan@moodle.com>
Tue, 23 Jul 2019 05:24:09 +0000 (13:24 +0800)
Set the default state to disabled for message contact request
notifications for the web process. The user is notified about contact
requests in the message drawer so it's unnecessary to also generate
a notification in the notification popover for them.

lib/db/messages.php
lib/db/upgrade.php
version.php

index d3473bb..3ae3810 100644 (file)
@@ -121,7 +121,8 @@ $messageproviders = array (
     // Message contact requests.
     'messagecontactrequests' => [
         'defaults' => [
     // Message contact requests.
     'messagecontactrequests' => [
         'defaults' => [
-            'popup' => MESSAGE_PERMITTED + MESSAGE_DEFAULT_LOGGEDIN + MESSAGE_DEFAULT_LOGGEDOFF,
+            // We don't need to notify in the popup output here because the message drawer
+            // already notifies users of contact requests.
             'email' => MESSAGE_PERMITTED + MESSAGE_DEFAULT_LOGGEDOFF,
             'airnotifier' => MESSAGE_PERMITTED + MESSAGE_DEFAULT_LOGGEDIN + MESSAGE_DEFAULT_LOGGEDOFF,
         ]
             'email' => MESSAGE_PERMITTED + MESSAGE_DEFAULT_LOGGEDOFF,
             'airnotifier' => MESSAGE_PERMITTED + MESSAGE_DEFAULT_LOGGEDIN + MESSAGE_DEFAULT_LOGGEDOFF,
         ]
index 048ae58..0998df7 100644 (file)
@@ -3416,5 +3416,21 @@ function xmldb_main_upgrade($oldversion) {
         upgrade_main_savepoint(true, 2019070400.01);
     }
 
         upgrade_main_savepoint(true, 2019070400.01);
     }
 
+    if ($oldversion < 2019071800.01) {
+        // Remove the "popup" processor from the list of default processors for the messagecontactrequests notification.
+        $oldloggedinconfig = get_config('message', 'message_provider_moodle_messagecontactrequests_loggedin');
+        $oldloggedoffconfig = get_config('message', 'message_provider_moodle_messagecontactrequests_loggedoff');
+        $newloggedinconfig = implode(',', array_filter(explode(',', $oldloggedinconfig), function($value) {
+            return $value != 'popup';
+        }));
+        $newloggedoffconfig = implode(',', array_filter(explode(',', $oldloggedoffconfig), function($value) {
+            return $value != 'popup';
+        }));
+        set_config('message_provider_moodle_messagecontactrequests_loggedin', $newloggedinconfig, 'message');
+        set_config('message_provider_moodle_messagecontactrequests_loggedoff', $newloggedoffconfig, 'message');
+
+        upgrade_main_savepoint(true, 2019071800.01);
+    }
+
     return true;
 }
     return true;
 }
index 572c371..a3edfce 100644 (file)
@@ -29,7 +29,7 @@
 
 defined('MOODLE_INTERNAL') || die();
 
 
 defined('MOODLE_INTERNAL') || die();
 
-$version  = 2019071800.00;              // YYYYMMDD      = weekly release date of this DEV branch.
+$version  = 2019071800.01;              // YYYYMMDD      = weekly release date of this DEV branch.
                                         //         RR    = release increments - 00 in DEV branches.
                                         //           .XX = incremental changes.
 
                                         //         RR    = release increments - 00 in DEV branches.
                                         //           .XX = incremental changes.