return;
}
- if ($revieworder) { // review enabled, inform site payment managers and redirect the user who have paid to main page.
+ if ($revieworder) { // review enabled, inform payment managers and redirect the user who have paid to main page.
$a = new stdClass;
$a->url = "$CFG->wwwroot/enrol/authorize/index.php?order=$order->id";
$a->orderid = $order->id;
if (!empty($CFG->enrol_mailstudents)) {
send_welcome_messages($order->id);
}
- $teacher = get_teacher($course->id);
if (!empty($CFG->enrol_mailteachers)) {
+ $context = get_context_instance(CONTEXT_COURSE, $course->id);
+ $paymentmanagers = get_users_by_capability($context, 'enrol/authorize:managepayments', '', '', '0', '1');
+ $paymentmanager = array_shift($paymentmanagers);
$a = new stdClass;
$a->course = "$course->fullname";
$a->user = fullname($USER);
- email_to_user($teacher,
+ email_to_user($paymentmanager,
$USER,
get_string("enrolmentnew", '', $course->shortname),
get_string('enrolmentnewuser', '', $a));
}
}
} else {
- email_to_admin("Error while trying to enrol " .
- fullname($USER) . " in '$course->fullname'", $order);
+ email_to_admin("Error while trying to enrol " . fullname($USER) . " in '$course->fullname'", $order);
}
if ($SESSION->wantsurl) {
} else {
$destination = "$CFG->wwwroot/course/view.php?id=$course->id";
}
- redirect($destination);
+ load_all_capabilities();
+ redirect($destination, get_string('paymentthanks', 'moodle', $course->fullname), 10);
}
global $CFG, $SITE;
if (empty($orderdata)) {
- return;
+ return;
}
if (is_numeric($orderdata)) {
ORDER BY e.userid";
$emailinfo = get_records_sql($select);
- $emailcount = count($emailinfo);
- if ($emailcount == 1) {
+ if (1 == count($emailinfo)) {
$ei = reset($emailinfo);
- if (!$sender = get_teacher($ei->courseid)) {
- $sender = get_admin();
- }
+ $context = get_context_instance(CONTEXT_COURSE, $ei->courseid);
+ $paymentmanagers = get_users_by_capability($context, 'enrol/authorize:managepayments', '', '', '0', '1');
+ $sender = array_shift($paymentmanagers);
}
else {
$sender = get_admin();
$usercourses = array();
$lastuserid = $ei->userid;
for ($current = $ei; $current !== false && $current->userid == $lastuserid; $current = next($emailinfo)) {
- $usercourses[] = $current->fullname;
+ $usercourses[] = $current->fullname;
}
$ei = $current;
$a = new stdClass;