mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-47162 core_message: Add course id to message eventdata
This commit is contained in:
parent
577bd70d38
commit
cc350fd9c8
34 changed files with 345 additions and 76 deletions
|
@ -50,7 +50,7 @@ class manager {
|
|||
*
|
||||
* NOTE: to be used from message_send() only.
|
||||
*
|
||||
* @param \stdClass|\core\message\message $eventdata fully prepared event data for processors
|
||||
* @param \core\message\message $eventdata fully prepared event data for processors
|
||||
* @param \stdClass $savemessage the message saved in 'message' table
|
||||
* @param array $processorlist list of processors for target user
|
||||
* @return int $messageid the id from 'message' or 'message_read' table (false is not returned)
|
||||
|
@ -63,11 +63,24 @@ class manager {
|
|||
throw new \coding_exception('Message should be of type stdClass or \core\message\message');
|
||||
}
|
||||
|
||||
if ($eventdata instanceof \stdClass) {
|
||||
if (!isset($eventdata->courseid)) {
|
||||
$eventdata->courseid = null;
|
||||
}
|
||||
|
||||
debugging('eventdata as \stdClass is deprecated. Please use core\message\message instead.', DEBUG_DEVELOPER);
|
||||
}
|
||||
|
||||
require_once($CFG->dirroot.'/message/lib.php'); // This is most probably already included from messagelib.php file.
|
||||
|
||||
if (empty($processorlist)) {
|
||||
// Trigger event for sending a message - we need to do this before marking as read!
|
||||
\core\event\message_sent::create_from_ids($eventdata->userfrom->id, $eventdata->userto->id, $savemessage->id)->trigger();
|
||||
\core\event\message_sent::create_from_ids(
|
||||
$eventdata->userfrom->id,
|
||||
$eventdata->userto->id,
|
||||
$savemessage->id,
|
||||
$eventdata->courseid
|
||||
)->trigger();
|
||||
|
||||
if ($savemessage->notification or empty($CFG->messaging)) {
|
||||
// If they have deselected all processors and its a notification mark it read. The user doesn't want to be bothered.
|
||||
|
@ -132,7 +145,12 @@ class manager {
|
|||
}
|
||||
|
||||
// Trigger event for sending a message - must be done before marking as read.
|
||||
\core\event\message_sent::create_from_ids($eventdata->userfrom->id, $eventdata->userto->id, $savemessage->id)->trigger();
|
||||
\core\event\message_sent::create_from_ids(
|
||||
$eventdata->userfrom->id,
|
||||
$eventdata->userto->id,
|
||||
$savemessage->id,
|
||||
$eventdata->courseid
|
||||
)->trigger();
|
||||
|
||||
if (empty($CFG->messaging)) {
|
||||
// If messaging is disabled and they previously had forum notifications handled by the popup processor
|
||||
|
|
|
@ -56,6 +56,12 @@ defined('MOODLE_INTERNAL') || die();
|
|||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class message {
|
||||
/** @var int Course id. */
|
||||
private $courseid;
|
||||
|
||||
/** @var string Module name. */
|
||||
private $modulename;
|
||||
|
||||
/** @var string Component name. */
|
||||
private $component;
|
||||
|
||||
|
@ -104,10 +110,31 @@ class message {
|
|||
/** @var string Name of the attachment. Note:- not all processors support this.*/
|
||||
private $attachname;
|
||||
|
||||
/** @var int The time the message was created.*/
|
||||
private $timecreated;
|
||||
|
||||
/** @var array a list of properties that is allowed for each message. */
|
||||
private $properties = array('component', 'name', 'userfrom', 'userto', 'subject', 'fullmessage', 'fullmessageformat',
|
||||
'fullmessagehtml', 'smallmessage', 'notification', 'contexturl', 'contexturlname', 'savedmessageid',
|
||||
'replyto', 'attachment', 'attachname');
|
||||
private $properties = array(
|
||||
'courseid',
|
||||
'modulename',
|
||||
'component',
|
||||
'name',
|
||||
'userfrom',
|
||||
'userto',
|
||||
'subject',
|
||||
'fullmessage',
|
||||
'fullmessageformat',
|
||||
'fullmessagehtml',
|
||||
'smallmessage',
|
||||
'notification',
|
||||
'contexturl',
|
||||
'contexturlname',
|
||||
'replyto',
|
||||
'savedmessageid',
|
||||
'attachment',
|
||||
'attachname',
|
||||
'timecreated'
|
||||
);
|
||||
|
||||
/** @var array property to store any additional message processor specific content */
|
||||
private $additionalcontent = array();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue