MDL-65796 message: improve content of contact request notifications.
authorPaul Holden <paulh@moodle.com>
Tue, 12 May 2020 22:17:27 +0000 (23:17 +0100)
committerPaul Holden <paulh@moodle.com>
Wed, 13 May 2020 14:40:17 +0000 (15:40 +0100)
lang/en/deprecated.txt
lang/en/message.php
message/classes/api.php

index 4bd15ab..280b3bd 100644 (file)
@@ -13,6 +13,8 @@ sitemessage,core
 coursemessage,core
 addedrecip,core
 addedrecips,core
+messagecontactrequestsnotification,core_message
+messagecontactrequestsnotificationsubject,core_message
 messagingdisabled,core_message
 messagedselectedcountusersfailed,core
 backtoparticipants,core
index 86b8085..61ed582 100644 (file)
@@ -101,8 +101,8 @@ $string['managemessageoutputs'] = 'Default notification preferences';
 $string['messageoutputs'] = 'Notification plugins';
 $string['messagepreferences'] = 'Message preferences';
 $string['message'] = 'Message';
-$string['messagecontactrequestsnotification'] = '{$a} is requesting to be added as a contact.';
-$string['messagecontactrequestsnotificationsubject'] = 'Contact request from {$a}';
+$string['messagecontactrequest'] = '{$a->user} is requesting to be added as a contact. Visit your <a href="{$a->url}">contact requests</a> page to respond to the request';
+$string['messagecontactrequestsubject'] = '{$a->sitename}: Contact request from {$a->user}';
 $string['messagecontentaudio'] = 'Audio';
 $string['messagecontentimage'] = 'Image';
 $string['messagecontentmultimediageneral'] = 'Other media';
@@ -289,3 +289,7 @@ $string['outputdoesnotexist'] = 'Message output does not exist';
 $string['outputenabled'] = 'Output enabled';
 $string['outputnotconfigured'] = 'Not configured';
 $string['canceledit'] = 'Cancel editing messages';
+
+// Deprecated since Moodle 3.9.
+$string['messagecontactrequestsnotification'] = '{$a} is requesting to be added as a contact.';
+$string['messagecontactrequestsnotificationsubject'] = 'Contact request from {$a}';
index c26fe8b..0055855 100644 (file)
@@ -2614,7 +2614,7 @@ class api {
      * @return \stdClass the request
      */
     public static function create_contact_request(int $userid, int $requesteduserid) : \stdClass {
-        global $DB, $PAGE;
+        global $DB, $PAGE, $SITE;
 
         $request = new \stdClass();
         $request->userid = $userid;
@@ -2627,10 +2627,16 @@ class api {
         $userfrom = \core_user::get_user($userid);
         $userfromfullname = fullname($userfrom);
         $userto = \core_user::get_user($requesteduserid);
-        $url = new \moodle_url('/message/pendingcontactrequests.php');
-
-        $subject = get_string('messagecontactrequestsnotificationsubject', 'core_message', $userfromfullname);
-        $fullmessage = get_string('messagecontactrequestsnotification', 'core_message', $userfromfullname);
+        $url = new \moodle_url('/message/index.php', ['view' => 'contactrequests']);
+
+        $subject = get_string('messagecontactrequestsubject', 'core_message', (object) [
+            'sitename' => format_string($SITE->fullname, true, ['context' => \context_system::instance()]),
+            'user' => $userfromfullname,
+        ]);
+        $fullmessage = get_string('messagecontactrequest', 'core_message', (object) [
+            'url' => $url->out(),
+            'user' => $userfromfullname,
+        ]);
 
         $message = new \core\message\message();
         $message->courseid = SITEID;