From 26f9407892b0da8a6b9bf863c48f4d68ea81dca3 Mon Sep 17 00:00:00 2001 From: "Eloy Lafuente (stronk7)" Date: Thu, 12 Dec 2013 02:03:41 +0100 Subject: [PATCH] MDL-31410 paypal: fix problem on notifications This commit fixes a PHP warning about using a unititialised variable and also the problems when notifications are enabled and there is not yet a teacher in the course, defaulting to admin for student notifications and preventing teacher notifications to happen. --- enrol/paypal/ipn.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/enrol/paypal/ipn.php b/enrol/paypal/ipn.php index 58b78939f24..e6d65821f23 100644 --- a/enrol/paypal/ipn.php +++ b/enrol/paypal/ipn.php @@ -243,6 +243,7 @@ if (strlen($result) > 0) { if (!empty($mailstudents)) { + $a = new stdClass(); $a->coursename = format_string($course->fullname, true, array('context' => $coursecontext)); $a->profileurl = "$CFG->wwwroot/user/view.php?id=$user->id"; @@ -250,7 +251,7 @@ if (strlen($result) > 0) { $eventdata->modulename = 'moodle'; $eventdata->component = 'enrol_paypal'; $eventdata->name = 'paypal_enrolment'; - $eventdata->userfrom = $teacher; + $eventdata->userfrom = empty($teacher) ? get_admin() : $teacher; $eventdata->userto = $user; $eventdata->subject = get_string("enrolmentnew", 'enrol', $shortname); $eventdata->fullmessage = get_string('welcometocoursetext', '', $a); @@ -261,7 +262,7 @@ if (strlen($result) > 0) { } - if (!empty($mailteachers)) { + if (!empty($mailteachers) && !empty($teacher)) { $a->course = format_string($course->fullname, true, array('context' => $coursecontext)); $a->user = fullname($user);