This commit is contained in:
Jun Pataleta 2020-05-22 11:50:53 +08:00
commit 87decf6e00
3 changed files with 18 additions and 6 deletions

View 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

View 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}';

View 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');
$url = new \moodle_url('/message/index.php', ['view' => 'contactrequests']);
$subject = get_string('messagecontactrequestsnotificationsubject', 'core_message', $userfromfullname);
$fullmessage = get_string('messagecontactrequestsnotification', 'core_message', $userfromfullname);
$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;