Skip to content

Commit

Permalink
Merge branch 'MDL-70552-master' of git://github.com/ilyatregubov/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
stronk7 committed Feb 17, 2021
2 parents 243262d + 729688b commit a72ea10
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
4 changes: 4 additions & 0 deletions lib/classes/message/message.php
Expand Up @@ -132,6 +132,9 @@ class message {
/** @var mixed Custom data to be passed to the message processor. Must be serialisable using json_encode(). */
private $customdata;

/** @var boolean If message is anonymous. */
private $anonymous;

/** @var array a list of properties that is allowed for each message. */
private $properties = array(
'courseid',
Expand All @@ -158,6 +161,7 @@ class message {
'timecreated',
'fullmessagetrust',
'customdata',
'anonymous',
);

/** @var array property to store any additional message processor specific content */
Expand Down
15 changes: 9 additions & 6 deletions message/output/popup/message_output_popup.php
Expand Up @@ -49,12 +49,15 @@ public function send_message($eventdata) {
global $DB;

// Prevent users from getting popup notifications from themselves (happens with forum notifications).
if ($eventdata->userfrom->id != $eventdata->userto->id && $eventdata->notification) {
if (!$DB->record_exists('message_popup_notifications', ['notificationid' => $eventdata->savedmessageid])) {
$record = new stdClass();
$record->notificationid = $eventdata->savedmessageid;

$DB->insert_record('message_popup_notifications', $record);
if ($eventdata->notification) {
if (($eventdata->userfrom->id != $eventdata->userto->id) ||
(isset($eventdata->anonymous) && $eventdata->anonymous)) {
if (!$DB->record_exists('message_popup_notifications', ['notificationid' => $eventdata->savedmessageid])) {
$record = new stdClass();
$record->notificationid = $eventdata->savedmessageid;

$DB->insert_record('message_popup_notifications', $record);
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions mod/feedback/lib.php
Expand Up @@ -2639,6 +2639,7 @@ function feedback_send_email($cm, $feedback, $course, $user, $completed = null)
];
if ($feedback->anonymous == FEEDBACK_ANONYMOUS_NO) {
$eventdata = new \core\message\message();
$eventdata->anonymous = false;
$eventdata->courseid = $course->id;
$eventdata->name = 'submission';
$eventdata->component = 'mod_feedback';
Expand All @@ -2661,6 +2662,7 @@ function feedback_send_email($cm, $feedback, $course, $user, $completed = null)
message_send($eventdata);
} else {
$eventdata = new \core\message\message();
$eventdata->anonymous = true;
$eventdata->courseid = $course->id;
$eventdata->name = 'submission';
$eventdata->component = 'mod_feedback';
Expand Down Expand Up @@ -2726,6 +2728,7 @@ function feedback_send_email_anonym($cm, $feedback, $course) {
}

$eventdata = new \core\message\message();
$eventdata->anonymous = true;
$eventdata->courseid = $course->id;
$eventdata->name = 'submission';
$eventdata->component = 'mod_feedback';
Expand Down

0 comments on commit a72ea10

Please sign in to comment.