3 require("../../config.php");
4 require_once("$CFG->dirroot/enrol/paypal/enrol.php");
6 $id = required_param('id', PARAM_INT
);
8 if (!$course = get_record("course", "id", $id)) {
9 redirect($CFG->wwwroot
);
12 if (! $context = get_context_instance(CONTEXT_COURSE
, $course->id
)) {
13 redirect($CFG->wwwroot
);
18 /// Refreshing enrolment data in the USER session
19 load_all_capabilities();
21 if ($SESSION->wantsurl
) {
22 $destination = $SESSION->wantsurl
;
23 unset($SESSION->wantsurl
);
25 $destination = "$CFG->wwwroot/course/view.php?id=$course->id";
28 if (has_capability('moodle/course:view', $context)) {
29 redirect($destination, get_string('paymentthanks', '', $course->fullname
));
31 } else { /// Somehow they aren't enrolled yet! :-(
33 notice(get_string('paymentsorry', '', $course), $destination);