Skip to content

Commit 880fc15

Browse files
committedOct 31, 2016
MDL-47162 core_message: Updating all uses of messaging to add courseid
1 parent a29bcf7 commit 880fc15

File tree

18 files changed

+41
-10
lines changed

18 files changed

+41
-10
lines changed
 

‎admin/tool/messageinbound/classes/manager.php

+3
Original file line numberDiff line numberDiff line change
@@ -930,6 +930,7 @@ private function handle_verification_failure(
930930
$userfrom->customheaders[] = 'In-Reply-To: ' . $messageid;
931931

932932
// The message will be sent from the intended user.
933+
$eventdata->courseid = SITEID;
933934
$eventdata->userfrom = \core_user::get_support_user();
934935
$eventdata->userto = $USER;
935936
$eventdata->subject = $this->get_reply_subject($this->currentmessagedata->envelope->subject);
@@ -971,6 +972,7 @@ private function inform_user_of_error($error) {
971972
$messagedata->error = $error;
972973

973974
$eventdata = new \core\message\message();
975+
$eventdata->courseid = SITEID;
974976
$eventdata->component = 'tool_messageinbound';
975977
$eventdata->name = 'messageprocessingerror';
976978
$eventdata->userfrom = $userfrom;
@@ -1030,6 +1032,7 @@ private function inform_user_of_success(\stdClass $messagedata, $handlerresult)
10301032
$messagedata->subject = $this->currentmessagedata->envelope->subject;
10311033

10321034
$eventdata = new \core\message\message();
1035+
$eventdata->courseid = SITEID;
10331036
$eventdata->component = 'tool_messageinbound';
10341037
$eventdata->name = 'messageprocessingsuccess';
10351038
$eventdata->userfrom = $userfrom;

‎admin/tool/monitor/classes/notification_task.php

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ protected function generate_message($subscriptionid, \stdClass $eventobj) {
8484
$template = $this->replace_placeholders($template, $subscription, $eventobj, $context);
8585
$htmlmessage = format_text($template, $subscription->templateformat, array('context' => $context));
8686
$msgdata = new \core\message\message();
87+
$msgdata->courseid = empty($subscription->courseid) ? SITEID : $subscription->courseid;
8788
$msgdata->component = 'tool_monitor'; // Your component name.
8889
$msgdata->name = 'notification'; // This is the message name from messages.php.
8990
$msgdata->userfrom = \core_user::get_noreply_user();

‎backup/util/helper/backup_cron_helper.class.php

+1
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ public static function run_automated_backup($rundirective = self::RUN_ON_SCHEDUL
265265

266266
//Send the message
267267
$eventdata = new \core\message\message();
268+
$eventdata->courseid = SITEID;
268269
$eventdata->modulename = 'moodle';
269270
$eventdata->userfrom = $admin;
270271
$eventdata->userto = $admin;

‎badges/cron.php

+1
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ function badge_assemble_notification(stdClass $badge) {
141141

142142
// Create a message object.
143143
$eventdata = new \core\message\message();
144+
$eventdata->courseid = SITEID;
144145
$eventdata->component = 'moodle';
145146
$eventdata->name = 'badgecreatornotice';
146147
$eventdata->userfrom = $userfrom;

‎course/lib.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -2636,7 +2636,7 @@ public function approve() {
26362636
$a = new stdClass();
26372637
$a->name = format_string($course->fullname, true, array('context' => context_course::instance($course->id)));
26382638
$a->url = $CFG->wwwroot.'/course/view.php?id=' . $course->id;
2639-
$this->notify($user, $USER, 'courserequestapproved', get_string('courseapprovedsubject'), get_string('courseapprovedemail2', 'moodle', $a));
2639+
$this->notify($user, $USER, 'courserequestapproved', get_string('courseapprovedsubject'), get_string('courseapprovedemail2', 'moodle', $a), $course->id);
26402640

26412641
return $course->id;
26422642
}
@@ -2672,9 +2672,11 @@ public function delete() {
26722672
* @param string $name
26732673
* @param string $subject
26742674
* @param string $message
2675+
* @param int|null $courseid
26752676
*/
2676-
protected function notify($touser, $fromuser, $name='courserequested', $subject, $message) {
2677+
protected function notify($touser, $fromuser, $name='courserequested', $subject, $message, $courseid = null) {
26772678
$eventdata = new \core\message\message();
2679+
$eventdata->courseid = empty($courseid) ? SITEID : $courseid;
26782680
$eventdata->component = 'moodle';
26792681
$eventdata->name = $name;
26802682
$eventdata->userfrom = $fromuser;

‎enrol/flatfile/lib.php

+4
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ public function sync(progress_trace $trace) {
187187
if ($processed and $mailadmins) {
188188
if ($log = $buffer->get_buffer()) {
189189
$eventdata = new \core\message\message();
190+
$eventdata->courseid = SITEID;
190191
$eventdata->modulename = 'moodle';
191192
$eventdata->component = 'enrol_flatfile';
192193
$eventdata->name = 'flatfile_enrolment';
@@ -341,6 +342,7 @@ protected function process_file(progress_trace $trace) {
341342

342343
if (!unlink($filelocation)) {
343344
$eventdata = new \core\message\message();
345+
$eventdata->courseid = SITEID;
344346
$eventdata->modulename = 'moodle';
345347
$eventdata->component = 'enrol_flatfile';
346348
$eventdata->name = 'flatfile_enrolment';
@@ -464,6 +466,7 @@ protected function process_records(progress_trace $trace, $action, $roleid, $use
464466
$subject = get_string('enrolmentnew', 'enrol', format_string($course->shortname, true, array('context' => $context)));
465467

466468
$eventdata = new \core\message\message();
469+
$eventdata->courseid = $course->id;
467470
$eventdata->modulename = 'moodle';
468471
$eventdata->component = 'enrol_flatfile';
469472
$eventdata->name = 'flatfile_enrolment';
@@ -495,6 +498,7 @@ protected function process_records(progress_trace $trace, $action, $roleid, $use
495498
$subject = get_string('enrolmentnew', 'enrol', format_string($course->shortname, true, array('context' => $context)));
496499

497500
$eventdata = new \core\message\message();
501+
$eventdata->courseid = $course->id;
498502
$eventdata->modulename = 'moodle';
499503
$eventdata->component = 'enrol_flatfile';
500504
$eventdata->name = 'flatfile_enrolment';

‎enrol/imsenterprise/lib.php

+1
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ public function cron() {
223223
}
224224

225225
$eventdata = new \core\message\message();
226+
$eventdata->courseid = SITEID;
226227
$eventdata->modulename = 'moodle';
227228
$eventdata->component = 'enrol_imsenterprise';
228229
$eventdata->name = 'imsenterprise_enrolment';

‎enrol/paypal/classes/util.php

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public static function message_paypal_error_to_admin($subject, $data) {
5252
}
5353

5454
$eventdata = new \core\message\message();
55+
$eventdata->courseid = empty($data->courseid) ? SITEID : $data->courseid;
5556
$eventdata->modulename = 'moodle';
5657
$eventdata->component = 'enrol_paypal';
5758
$eventdata->name = 'paypal_enrolment';

‎enrol/paypal/ipn.php

+4
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@
153153

154154
if ($data->payment_status == "Pending" and $data->pending_reason != "echeck") {
155155
$eventdata = new \core\message\message();
156+
$eventdata->courseid = empty($data->courseid) ? SITEID : $data->courseid;
156157
$eventdata->modulename = 'moodle';
157158
$eventdata->component = 'enrol_paypal';
158159
$eventdata->name = 'paypal_enrolment';
@@ -260,6 +261,7 @@
260261
$a->profileurl = "$CFG->wwwroot/user/view.php?id=$user->id";
261262

262263
$eventdata = new \core\message\message();
264+
$eventdata->courseid = $course->id;
263265
$eventdata->modulename = 'moodle';
264266
$eventdata->component = 'enrol_paypal';
265267
$eventdata->name = 'paypal_enrolment';
@@ -279,6 +281,7 @@
279281
$a->user = fullname($user);
280282

281283
$eventdata = new \core\message\message();
284+
$eventdata->courseid = $course->id;
282285
$eventdata->modulename = 'moodle';
283286
$eventdata->component = 'enrol_paypal';
284287
$eventdata->name = 'paypal_enrolment';
@@ -298,6 +301,7 @@
298301
$admins = get_admins();
299302
foreach ($admins as $admin) {
300303
$eventdata = new \core\message\message();
304+
$eventdata->courseid = $course->id;
301305
$eventdata->modulename = 'moodle';
302306
$eventdata->component = 'enrol_paypal';
303307
$eventdata->name = 'paypal_enrolment';

‎error/index.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
}
1212

1313
// Send the message and redirect.
14-
$eventdata = new stdClass();
14+
$eventdata = new \core\message\message();
15+
$eventdata->courseid = SITEID;
1516
$eventdata->component = 'moodle';
1617
$eventdata->name = 'errors';
1718
$eventdata->userfrom = $USER;

‎lib/classes/antivirus/scanner.php

+1
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ public function message_admins($notice) {
123123
$admins = get_admins();
124124
foreach ($admins as $admin) {
125125
$eventdata = new \core\message\message();
126+
$eventdata->courseid = SITEID;
126127
$eventdata->component = 'moodle';
127128
$eventdata->name = 'errors';
128129
$eventdata->userfrom = get_admin();

‎lib/classes/update/checker.php

+1
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,7 @@ protected function cron_notify(array $notifications) {
799799

800800
foreach ($admins as $admin) {
801801
$message = new \core\message\message();
802+
$message->courseid = SITEID;
802803
$message->component = 'moodle';
803804
$message->name = 'availableupdate';
804805
$message->userfrom = get_admin();

‎lib/enrollib.php

+2
Original file line numberDiff line numberDiff line change
@@ -2656,6 +2656,7 @@ protected function notify_expiry_enrolled($user, $ue, progress_trace $trace) {
26562656
$body = get_string('expirymessageenrolledbody', 'enrol_'.$name, $a);
26572657

26582658
$message = new \core\message\message();
2659+
$message->courseid = $ue->courseid;
26592660
$message->notification = 1;
26602661
$message->component = 'enrol_'.$name;
26612662
$message->name = 'expiry_notification';
@@ -2717,6 +2718,7 @@ protected function notify_expiry_enroller($eid, $users, progress_trace $trace) {
27172718
$body = get_string('expirymessageenrollerbody', 'enrol_'.$name, $a);
27182719

27192720
$message = new \core\message\message();
2721+
$message->courseid = $course->id;
27202722
$message->notification = 1;
27212723
$message->component = 'enrol_'.$name;
27222724
$message->name = 'expiry_notification';

‎lib/portfoliolib.php

+1
Original file line numberDiff line numberDiff line change
@@ -1110,6 +1110,7 @@ function portfolio_insane_notify_admins($insane, $instances=false) {
11101110

11111111
foreach ($admins as $admin) {
11121112
$eventdata = new \core\message\message();
1113+
$eventdata->courseid = SITEID;
11131114
$eventdata->modulename = 'portfolio';
11141115
$eventdata->component = 'portfolio';
11151116
$eventdata->name = 'notices';

‎message/tests/externallib_test.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ public function test_get_messages() {
507507
message_send($eventdata);
508508

509509
$message = new \core\message\message();
510-
$message->courseid = $course->id;
510+
$message->courseid = $course->id;
511511
$message->notification = 1;
512512
$message->component = 'enrol_manual';
513513
$message->name = 'expiry_notification';

‎message/tests/search_test_received.php

+6-3
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ public function test_message_received_indexing() {
7272
$this->preventResetByRollback();
7373
$sink = $this->redirectMessages();
7474

75-
$message = new StdClass();
75+
$message = new \core\message\message();
76+
$message->courseid = SITEID;
7677
$message->userfrom = $user1;
7778
$message->userto = $user2;
7879
$message->subject = "Test Subject";
@@ -129,7 +130,8 @@ public function test_message_received_document() {
129130
$this->preventResetByRollback();
130131
$sink = $this->redirectMessages();
131132

132-
$message = new StdClass();
133+
$message = new \core\message\message();
134+
$message->courseid = SITEID;
133135
$message->userfrom = $user1;
134136
$message->userto = $user2;
135137
$message->subject = "Test Subject";
@@ -175,7 +177,8 @@ public function test_message_received_access() {
175177
$this->preventResetByRollback();
176178
$sink = $this->redirectMessages();
177179

178-
$message = new StdClass();
180+
$message = new \core\message\message();
181+
$message->courseid = SITEID;
179182
$message->userfrom = $user1;
180183
$message->userto = $user2;
181184
$message->subject = "Test Subject";

‎message/tests/search_test_sent.php

+6-3
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ public function test_message_sent_indexing() {
7272
$this->preventResetByRollback();
7373
$sink = $this->redirectMessages();
7474

75-
$message = new StdClass();
75+
$message = new \core\message\message();
76+
$message->courseid = SITEID;
7677
$message->userfrom = $user1;
7778
$message->userto = $user2;
7879
$message->subject = "Test Subject";
@@ -129,7 +130,8 @@ public function test_message_sent_document() {
129130
$this->preventResetByRollback();
130131
$sink = $this->redirectMessages();
131132

132-
$message = new StdClass();
133+
$message = new \core\message\message();
134+
$message->courseid = SITEID;
133135
$message->userfrom = $user1;
134136
$message->userto = $user2;
135137
$message->subject = "Test Subject";
@@ -175,7 +177,8 @@ public function test_message_sent_access() {
175177
$this->preventResetByRollback();
176178
$sink = $this->redirectMessages();
177179

178-
$message = new StdClass();
180+
$message = new \core\message\message();
181+
$message->courseid = SITEID;
179182
$message->userfrom = $user1;
180183
$message->userto = $user2;
181184
$message->subject = "Test Subject";

‎mod/forum/lib.php

+1
Original file line numberDiff line numberDiff line change
@@ -1186,6 +1186,7 @@ function forum_cron() {
11861186
}
11871187

11881188
$eventdata = new \core\message\message();
1189+
$eventdata->courseid = SITEID;
11891190
$eventdata->component = 'mod_forum';
11901191
$eventdata->name = 'digests';
11911192
$eventdata->userfrom = core_user::get_noreply_user();

0 commit comments

Comments
 (0)
Please sign in to comment.