Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

get_teacher() to get_users_by_capability().

  • Loading branch information...
commit 726bf1ead282a66398b32c557eb83d69a91661eb 1 parent e22482a
ethem authored
Showing with 14 additions and 13 deletions.
  1. +8 −6 enrol/authorize/enrol.php
  2. +6 −7 enrol/authorize/localfuncs.php
View
14 enrol/authorize/enrol.php
@@ -215,7 +215,7 @@ function cc_submit($form, $course)
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;
@@ -246,12 +246,14 @@ function cc_submit($form, $course)
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));
@@ -269,8 +271,7 @@ function cc_submit($form, $course)
}
}
} 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) {
@@ -278,7 +279,8 @@ function cc_submit($form, $course)
} else {
$destination = "$CFG->wwwroot/course/view.php?id=$course->id";
}
- redirect($destination);
+ load_all_capabilities();
+ redirect($destination, get_string('paymentthanks', 'moodle', $course->fullname), 10);
}
View
13 enrol/authorize/localfuncs.php
@@ -325,7 +325,7 @@ function send_welcome_messages($orderdata)
global $CFG, $SITE;
if (empty($orderdata)) {
- return;
+ return;
}
if (is_numeric($orderdata)) {
@@ -339,12 +339,11 @@ function send_welcome_messages($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();
@@ -355,7 +354,7 @@ function send_welcome_messages($orderdata)
$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;
Please sign in to comment.
Something went wrong with that request. Please try again.