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.
This commit is contained in:
Eloy Lafuente (stronk7) 2013-12-12 02:03:41 +01:00
parent d47d52d531
commit 32a8bcc4a7

View File

@ -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);