Permalink
Browse files

get_teacher() to get_users_by_capability(). Merged with HEAD.

  • Loading branch information...
1 parent 9abc42b commit 0b06840128bfb744fb3978bb5937c54f4a48ac42 ethem committed Nov 3, 2006
Showing with 15 additions and 14 deletions.
  1. +8 −6 enrol/authorize/enrol.php
  2. +7 −8 enrol/authorize/localfuncs.php
View
@@ -205,7 +205,7 @@ function cc_submit($form, $course)
return;
}
- if ($an_review) { // review enabled, inform site payment managers and redirect the user who have paid to main page.
+ if ($an_review) { // 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;
@@ -236,12 +236,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));
@@ -259,16 +261,16 @@ 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) {
$destination = $SESSION->wantsurl; unset($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);
}
@@ -322,7 +322,7 @@ function send_welcome_messages($orderdata)
global $CFG, $SITE;
if (empty($orderdata)) {
- return;
+ return;
}
if (is_numeric($orderdata)) {
@@ -336,12 +336,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();
@@ -351,8 +350,8 @@ function send_welcome_messages($orderdata)
while ($ei !== false) {
$usercourses = array();
$lastuserid = $ei->userid;
- for ($current = $ei; $current !== false && $current->userid == $lastuserid; $current = next($emailinfo)) {
- $usercourses[] = $current->fullname;
+ for ($current = $ei; $current !== false && $current->userid == $lastuserid; $current = next($emailinfo)) {
+ $usercourses[] = $current->fullname;
}
$ei = $current;
$a = new stdClass;

0 comments on commit 0b06840

Please sign in to comment.