mirror of
https://github.com/moodle/moodle.git
synced 2025-08-07 18:06:51 +02:00
Merge branch 'MDL-44704_master' of git://github.com/markn86/moodle
This commit is contained in:
commit
3f4a4daa03
2 changed files with 8 additions and 10 deletions
|
@ -65,13 +65,13 @@ class message_sent extends base {
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function get_description() {
|
public function get_description() {
|
||||||
// Check that we are sending from a valid user.
|
// Check if we are sending from a valid user.
|
||||||
if ($this->userid > 0) {
|
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 \'' .
|
return 'The user with the id \'' . $this->userid . '\' sent a message to the user with the id \'' .
|
||||||
$this->relateduserid . '\'.';
|
$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() {
|
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
|
// 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.
|
// 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 .
|
return array(SITEID, 'message', 'write', 'index.php?user=' . $this->userid . '&id=' . $this->relateduserid .
|
||||||
'&history=1#m' . $this->other['messageid'], $this->userid);
|
'&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
|
// 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.
|
// Check if the userid is valid.
|
||||||
if ($eventdata->userfrom->id > 0) {
|
if (core_user::is_real_user($eventdata->userfrom->id)) {
|
||||||
$userfromid = $eventdata->userfrom->id;
|
$userfromid = $eventdata->userfrom->id;
|
||||||
$context = context_user::instance($eventdata->userfrom->id);
|
|
||||||
} else {
|
} else {
|
||||||
$userfromid = 0;
|
$userfromid = 0;
|
||||||
$context = context_system::instance();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Trigger event for sending a message.
|
// Trigger event for sending a message.
|
||||||
$event = \core\event\message_sent::create(array(
|
$event = \core\event\message_sent::create(array(
|
||||||
'userid' => $userfromid,
|
'userid' => $userfromid,
|
||||||
'context' => $context,
|
'context' => context_system::instance(),
|
||||||
'relateduserid' => $eventdata->userto->id,
|
'relateduserid' => $eventdata->userto->id,
|
||||||
'other' => array(
|
'other' => array(
|
||||||
'messageid' => $messageid // Can't use this as the objectid as it can either be the id in the 'message_read'
|
'messageid' => $messageid // Can't use this as the objectid as it can either be the id in the 'message_read'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue