. /** * Paypal utility script * * @package enrol_paypal * @copyright 2004 onwards Martin Dougiamas (http://dougiamas.com) * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ require("../../config.php"); require_once("$CFG->dirroot/enrol/paypal/lib.php"); $id = required_param('id', PARAM_INT); if (!$course = $DB->get_record("course", array("id"=>$id))) { redirect($CFG->wwwroot); } $context = context_course::instance($course->id, MUST_EXIST); $PAGE->set_context($context); require_login(); if (!empty($SESSION->wantsurl)) { $destination = $SESSION->wantsurl; unset($SESSION->wantsurl); } else { $destination = "$CFG->wwwroot/course/view.php?id=$course->id"; } $fullname = format_string($course->fullname, true, array('context' => $context)); if (is_enrolled($context, NULL, '', true)) { // TODO: use real paypal check redirect($destination, get_string('paymentthanks', '', $fullname)); } else { /// Somehow they aren't enrolled yet! :-( $PAGE->set_url($destination); echo $OUTPUT->header(); $a = new stdClass(); $a->teacher = get_string('defaultcourseteacher'); $a->fullname = $fullname; notice(get_string('paymentsorry', '', $a), $destination); }