From 9c59948e6302852f47b33d71486f513e6d55e357 Mon Sep 17 00:00:00 2001 From: ethem Date: Tue, 3 Oct 2006 18:00:48 +0000 Subject: [PATCH] * enrol_into_course() doesn't send welcome message unless $course->welcomemessage is set. This is actually good thing, because we can send our welcome message. * enrol_into_course() added in Moodle(2006091700), so authorize plugin requires this version. --- enrol/authorize/enrol.php | 15 ++++++++++++++- enrol/authorize/locallib.php | 20 ++++++++++---------- enrol/authorize/version.php | 2 +- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/enrol/authorize/enrol.php b/enrol/authorize/enrol.php index 1ab01e1f2b..a822d1f204 100755 --- a/enrol/authorize/enrol.php +++ b/enrol/authorize/enrol.php @@ -234,6 +234,13 @@ class enrolment_plugin_authorize } // Credit card captured, ENROL student now... + if (!empty($CFG->enrol_mailstudents)) { + $a = new stdClass; + $a->courses = $course->fullname; + $a->profileurl = "$CFG->wwwroot/user/view.php?id=$USER->id"; + $a->paymenturl = "$CFG->wwwroot/enrol/authorize/index.php?user=$USER->id"; + $course->welcomemessage = get_string('welcometocoursesemail', 'enrol_authorize', $a); + } if (enrol_into_course($course, $USER, 'manual')) { $teacher = get_teacher($course->id); if (!empty($CFG->enrol_mailteachers)) { @@ -342,6 +349,13 @@ class enrolment_plugin_authorize } // ENROL student now ... + if (!empty($CFG->enrol_mailstudents)) { + $a = new stdClass; + $a->courses = $course->fullname; + $a->profileurl = "$CFG->wwwroot/user/view.php?id=$USER->id"; + $a->paymenturl = "$CFG->wwwroot/enrol/authorize/index.php?user=$USER->id"; + $course->welcomemessage = get_string('welcometocoursesemail', 'enrol_authorize', $a); + } if (enrol_into_course($course, $USER, 'manual')) { $teacher = get_teacher($course->id); if (!empty($CFG->enrol_mailteachers)) { @@ -643,7 +657,6 @@ class enrolment_plugin_authorize } $user = get_record('user', 'id', $order->userid); if (role_assign($role->id, $user->id, 0, $context->id, $timestart, $timeend, 0, 'manual')) { - /// enrol_student($order->userid, $order->courseid, $timestart, $timeend, 'manual'); $this->log .= "User($user->id) has been enrolled to course($course->id).\n"; if (!empty($CFG->enrol_mailstudents)) { $sendem[] = $order->id; diff --git a/enrol/authorize/locallib.php b/enrol/authorize/locallib.php index d26c866ee3..47e160d677 100644 --- a/enrol/authorize/locallib.php +++ b/enrol/authorize/locallib.php @@ -171,11 +171,7 @@ function authorize_print_order_details($orderno) $table->size = array('30%', '70%'); $table->align = array('right', 'left'); - $sql = "SELECT e.*, c.shortname FROM {$CFG->prefix}enrol_authorize e " . - "INNER JOIN {$CFG->prefix}course c ON c.id = e.courseid " . - "WHERE e.id = '$orderno'"; - - $order = get_record_sql($sql); + $order = get_record('enrol_authorize', 'id', $orderno); if (!$order) { notice("Order $orderno not found.", "index.php"); return; @@ -204,7 +200,7 @@ function authorize_print_order_details($orderno) $table->data[] = array("$authstrs->amount:", "$order->currency $order->amount"); if (empty($cmdcapture) and empty($cmdrefund) and empty($cmdvoid) and empty($cmddelete)) { $color = authorize_get_status_color($status->status); - $table->data[] = array("$strs->course:", $order->shortname); + $table->data[] = array("$strs->course:", $course->shortname); $table->data[] = array("$strs->status:", "" . $authstrs->{$status->status} . ""); if ($order->paymentmethod == AN_METHOD_CC) { $table->data[] = array("$authstrs->nameoncard:", $order->ccname); @@ -242,12 +238,19 @@ function authorize_print_order_details($orderno) else { if (empty($CFG->an_test)) { $user = get_record('user', 'id', $order->userid); + if (!empty($CFG->enrol_mailstudents)) { + $a = new stdClass; + $a->courses = $course->fullname; + $a->profileurl = "$CFG->wwwroot/user/view.php?id=$user->id"; + $a->paymenturl = "$CFG->wwwroot/enrol/authorize/index.php?user=$user->id"; + $course->welcomemessage = get_string('welcometocoursesemail', 'enrol_authorize', $a); + } if (enrol_into_course($course, $user, 'manual')) { redirect("index.php?order=$orderno"); } else { $table->data[] = array("$strs->error:", - "Error while trying to enrol ".fullname($user)." in '$order->shortname'"); + "Error while trying to enrol ".fullname($user)." in '$course->shortname'"); } } else { @@ -305,7 +308,6 @@ function authorize_print_order_details($orderno) else { if (!empty($unenrol)) { role_unassign(0, $order->userid, 0, $coursecontext->id); - //unenrol_student($order->userid, $order->courseid); } redirect("index.php?order=$orderno"); } @@ -395,7 +397,6 @@ function authorize_print_order_details($orderno) if (empty($CFG->an_test)) { if (!empty($unenrol)) { role_unassign(0, $order->userid, 0, $coursecontext->id); - //unenrol_student($order->userid, $order->courseid); } redirect("index.php?order=$orderno"); } @@ -430,7 +431,6 @@ function authorize_print_order_details($orderno) else { if (!empty($unenrol)) { role_unassign(0, $order->userid, 0, $coursecontext->id); - //unenrol_student($order->userid, $order->courseid); } delete_records('enrol_authorize', 'id', $orderno); redirect("index.php"); diff --git a/enrol/authorize/version.php b/enrol/authorize/version.php index d038af9a37..abe785a660 100755 --- a/enrol/authorize/version.php +++ b/enrol/authorize/version.php @@ -1,6 +1,6 @@ version = 2006083100; -$plugin->requires = 2005072200; +$plugin->requires = 2006091700; ?> -- 2.39.5