mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 12:40:01 +01:00
Merge branch 'MDL-44704_master' of git://github.com/markn86/moodle
This commit is contained in:
commit
3f4a4daa03
@ -65,13 +65,13 @@ class message_sent extends base {
|
||||
* @return string
|
||||
*/
|
||||
public function get_description() {
|
||||
// Check that we are sending from a valid user.
|
||||
if ($this->userid > 0) {
|
||||
// Check if we are sending from a valid user.
|
||||
if (\core_user::is_real_user($this->userid)) {
|
||||
return 'The user with the id \'' . $this->userid . '\' sent a message to the user with the id \'' .
|
||||
$this->relateduserid . '\'.';
|
||||
} else {
|
||||
return 'A message was sent by the system to the user with the id \'' . $this->relateduserid . '\'.';
|
||||
}
|
||||
|
||||
return 'A message was sent by the system to the user with the id \'' . $this->relateduserid . '\'.';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -82,7 +82,7 @@ class message_sent extends base {
|
||||
protected function get_legacy_logdata() {
|
||||
// The add_to_log function was only ever called when we sent a message from one user to another. We do not want
|
||||
// to return the legacy log data if we are sending a system message, so check that the userid is valid.
|
||||
if ($this->userid > 0) {
|
||||
if (\core_user::is_real_user($this->userid)) {
|
||||
return array(SITEID, 'message', 'write', 'index.php?user=' . $this->userid . '&id=' . $this->relateduserid .
|
||||
'&history=1#m' . $this->other['messageid'], $this->userid);
|
||||
}
|
||||
|
@ -248,20 +248,18 @@ function message_send($eventdata) {
|
||||
}
|
||||
|
||||
// We may be sending a message from the 'noreply' address, which means we are not actually sending a
|
||||
// message from a valid user. In this case, we will set the userid to 0 and the context to system.
|
||||
// message from a valid user. In this case, we will set the userid to 0.
|
||||
// Check if the userid is valid.
|
||||
if ($eventdata->userfrom->id > 0) {
|
||||
if (core_user::is_real_user($eventdata->userfrom->id)) {
|
||||
$userfromid = $eventdata->userfrom->id;
|
||||
$context = context_user::instance($eventdata->userfrom->id);
|
||||
} else {
|
||||
$userfromid = 0;
|
||||
$context = context_system::instance();
|
||||
}
|
||||
|
||||
// Trigger event for sending a message.
|
||||
$event = \core\event\message_sent::create(array(
|
||||
'userid' => $userfromid,
|
||||
'context' => $context,
|
||||
'context' => context_system::instance(),
|
||||
'relateduserid' => $eventdata->userto->id,
|
||||
'other' => array(
|
||||
'messageid' => $messageid // Can't use this as the objectid as it can either be the id in the 'message_read'
|
||||
|
Loading…
x
Reference in New Issue
Block a user