mirror of
https://github.com/moodle/moodle.git
synced 2025-01-21 23:48:45 +01:00
58 lines
1.4 KiB
PHP
58 lines
1.4 KiB
PHP
<?PHP // $Id$
|
|
// Depending on the current enrolment method, this page
|
|
// presents the user with whatever they need to know when
|
|
// they try to enrol in a course.
|
|
|
|
require_once("../config.php");
|
|
require_once("lib.php");
|
|
require_once("$CFG->dirroot/enrol/$CFG->enrol/enrol.php");
|
|
|
|
require_variable($id);
|
|
|
|
require_login();
|
|
|
|
if (! $course = get_record("course", "id", $id) ) {
|
|
error("That's an invalid course id");
|
|
}
|
|
|
|
if (! $site = get_site()) {
|
|
error("Could not find a site!");
|
|
}
|
|
|
|
check_for_restricted_user($USER->username);
|
|
|
|
$enrol = new enrolment_plugin();
|
|
|
|
/// Refreshing enrolment data in the USER session
|
|
$enrol->get_student_courses($USER);
|
|
$enrol->get_teacher_courses($USER);
|
|
|
|
|
|
/// Double check just in case they are actually enrolled already
|
|
/// This might occur if they were enrolled during this session
|
|
|
|
if ( $USER->student[$course->id] or $USER->teacher[$course->id] ) {
|
|
|
|
if ($SESSION->wantsurl) {
|
|
$destination = $SESSION->wantsurl;
|
|
unset($SESSION->wantsurl);
|
|
} else {
|
|
$destination = "$CFG->wwwroot/course/view.php?id=$course->id";
|
|
}
|
|
|
|
redirect($destination);
|
|
}
|
|
|
|
|
|
/// Check the submitted enrollment key if there is one
|
|
|
|
if ($form = data_submitted()) {
|
|
$enrol->check_entry($form, $course);
|
|
}
|
|
|
|
$enrol->print_entry($course);
|
|
|
|
/// Easy!
|
|
|
|
?>
|