Skip to content

Commit

Permalink
Changed deprecated enrol_student() function to enrol_into_course().
Browse files Browse the repository at this point in the history
  • Loading branch information
ethem committed Sep 22, 2006
1 parent 0e3404a commit 16dbf42
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 20 deletions.
2 changes: 1 addition & 1 deletion enrol/authorize/index.php
Expand Up @@ -16,7 +16,7 @@
error("Guests cannot use this page.");
}

if (!$course = get_record('course', 'id', $courseid)) {
if (! $course = get_record('course', 'id', $courseid)) {
error('Could not find that course');
}

Expand Down
26 changes: 7 additions & 19 deletions enrol/authorize/locallib.php
Expand Up @@ -171,7 +171,7 @@ function authorize_print_order_details($orderno)
$table->size = array('30%', '70%');
$table->align = array('right', 'left');

$sql = "SELECT e.*, c.shortname, c.enrolperiod FROM {$CFG->prefix}enrol_authorize e " .
$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'";

Expand All @@ -181,7 +181,8 @@ function authorize_print_order_details($orderno)
return;
}

$coursecontext = get_context_instance(CONTEXT_COURSE, $order->courseid);
$course = get_record('course', 'id', $order->courseid);
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);

if ($USER->id != $order->userid) { // Current user viewing someone else's order
if (! has_capability('enrol/authorize:managepayments', $coursecontext)) {
Expand Down Expand Up @@ -240,26 +241,13 @@ function authorize_print_order_details($orderno)
}
else {
if (empty($CFG->an_test)) {
$timestart = $timeend = 0;
if ($order->enrolperiod) {
$timestart = time(); // early start
$timeend = $order->settletime + $order->enrolperiod; // lately end
}
if (enrol_student($order->userid, $order->courseid, $timestart, $timeend, 'manual')) {
$user = get_record('user', 'id', $order->userid);
$teacher = get_teacher($order->courseid);
$a = new stdClass;
$a->coursename = $order->shortname;
$a->profileurl = "$CFG->wwwroot/user/view.php?id=$user->id";
email_to_user($user,
$teacher,
get_string("enrolmentnew", '', $order->shortname),
get_string('welcometocoursetext', '', $a));
$user = get_record('user', 'id', $order->userid);
if (enrol_into_course($course, $user, 'manual')) {
redirect("index.php?order=$orderno");
}
else {
$table->data[] = array("<b><font color=red>$strs->error:</font></b>",
"Error while trying to enrol ".fullname($user)." in '$order->shortname'");
$table->data[] = array("<b><font color=red>$strs->error:</font></b>",
"Error while trying to enrol ".fullname($user)." in '$order->shortname'");
}
}
else {
Expand Down

0 comments on commit 16dbf42

Please sign in to comment.