From 726bf1ead282a66398b32c557eb83d69a91661eb Mon Sep 17 00:00:00 2001 From: ethem Date: Fri, 3 Nov 2006 11:20:13 +0000 Subject: [PATCH] get_teacher() to get_users_by_capability(). --- enrol/authorize/enrol.php | 14 ++++++++------ enrol/authorize/localfuncs.php | 13 ++++++------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/enrol/authorize/enrol.php b/enrol/authorize/enrol.php index d7f89d7260..27f11392ac 100755 --- a/enrol/authorize/enrol.php +++ b/enrol/authorize/enrol.php @@ -215,7 +215,7 @@ class enrolment_plugin_authorize 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 @@ class enrolment_plugin_authorize 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 @@ class enrolment_plugin_authorize } } } 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 @@ class enrolment_plugin_authorize } else { $destination = "$CFG->wwwroot/course/view.php?id=$course->id"; } - redirect($destination); + load_all_capabilities(); + redirect($destination, get_string('paymentthanks', 'moodle', $course->fullname), 10); } diff --git a/enrol/authorize/localfuncs.php b/enrol/authorize/localfuncs.php index b6c83f05cd..aa11e11cb5 100644 --- a/enrol/authorize/localfuncs.php +++ b/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; -- 2.39.5