3 require("../../config.php");
4 require_once("$CFG->dirroot/enrol/paypal/enrol.php");
6 $id = required_param('id', PARAM_INT);
8 if (!$course = $DB->get_record("course", array("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 (is_enrolled($context, NULL, '', true)) { // TODO: use real paypal check
29 redirect($destination, get_string('paymentthanks', '', $course->fullname));
31 } else { /// Somehow they aren't enrolled yet! :-(
32 $PAGE->set_url($destination);
33 echo $OUTPUT->header();
34 notice(get_string('paymentsorry', '', get_string('defaultcourseteacher')), $destination);