2002-06-04 06:30:51 +00:00
|
|
|
<?PHP // $Id$
|
|
|
|
|
2002-06-19 15:42:49 +00:00
|
|
|
// Removes a student from a class
|
2002-06-04 06:30:51 +00:00
|
|
|
// This will not delete any of their data from the course,
|
|
|
|
// but will remove them from the student list and prevent
|
|
|
|
// any course email being sent to them.
|
|
|
|
|
2003-01-05 14:19:20 +00:00
|
|
|
require_once("../config.php");
|
|
|
|
require_once("lib.php");
|
2002-06-04 06:30:51 +00:00
|
|
|
|
2002-06-19 15:42:49 +00:00
|
|
|
require_variable($id); //course
|
|
|
|
optional_variable($user, $USER->id); //user
|
2002-06-04 06:30:51 +00:00
|
|
|
|
|
|
|
if (! $course = get_record("course", "id", $id) ) {
|
|
|
|
error("That's an invalid course id");
|
|
|
|
}
|
2002-06-19 15:42:49 +00:00
|
|
|
if (! $user = get_record("user", "id", $user) ) {
|
|
|
|
error("That's an invalid user id");
|
|
|
|
}
|
2002-06-04 06:30:51 +00:00
|
|
|
|
|
|
|
require_login($course->id);
|
|
|
|
|
2002-06-19 15:42:49 +00:00
|
|
|
if ($user->id != $USER->id and !isteacher($course->id)) {
|
|
|
|
error("You must be a teacher to do this");
|
|
|
|
}
|
|
|
|
|
2002-06-04 06:30:51 +00:00
|
|
|
if (isset($confirm)) {
|
2002-06-19 15:42:49 +00:00
|
|
|
|
2002-09-22 14:06:38 +00:00
|
|
|
if (! unenrol_student($user->id, $course->id)) {
|
2002-06-04 06:30:51 +00:00
|
|
|
error("An error occurred while trying to unenrol you.");
|
|
|
|
}
|
2002-06-05 16:39:45 +00:00
|
|
|
|
2002-06-19 15:42:49 +00:00
|
|
|
add_to_log($course->id, "course", "unenrol", "view.php?id=$course->id", "$user->id");
|
2002-06-04 06:30:51 +00:00
|
|
|
|
2002-06-19 15:42:49 +00:00
|
|
|
if ($user->id == $USER->id) {
|
|
|
|
unset($USER->student["$id"]);
|
2002-08-06 17:23:45 +00:00
|
|
|
save_session("USER");
|
2002-06-19 15:42:49 +00:00
|
|
|
redirect("$CFG->wwwroot");
|
|
|
|
}
|
2002-06-04 06:30:51 +00:00
|
|
|
|
2002-06-19 15:42:49 +00:00
|
|
|
redirect("$CFG->wwwroot/user/index.php?id=$course->id");
|
2002-06-04 06:30:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-11 15:41:54 +00:00
|
|
|
$strunenrol = get_string("unenrol");
|
|
|
|
|
|
|
|
print_header("$course->shortname: $strunenrol", "$course->fullname",
|
|
|
|
"<A HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</A> -> $strunenrol");
|
2002-06-04 06:30:51 +00:00
|
|
|
|
2002-06-19 15:42:49 +00:00
|
|
|
if ($user->id == $USER->id) {
|
2002-08-11 15:41:54 +00:00
|
|
|
$strunenrolsure = get_string("unenrolsure", "", get_string("yourself"));
|
2002-06-19 15:42:49 +00:00
|
|
|
} else {
|
2002-08-11 15:41:54 +00:00
|
|
|
$strunenrolsure = get_string("unenrolsure", "", "$user->firstname $user->lastname");
|
2002-06-19 15:42:49 +00:00
|
|
|
}
|
2002-06-04 06:30:51 +00:00
|
|
|
|
2002-08-11 15:41:54 +00:00
|
|
|
notice_yesno ($strunenrolsure, "unenrol.php?id=$id&user=$user->id&confirm=yes", "$HTTP_REFERER");
|
2002-06-04 06:30:51 +00:00
|
|
|
|
2002-08-11 15:41:54 +00:00
|
|
|
print_footer();
|
2002-06-04 06:30:51 +00:00
|
|
|
|
|
|
|
?>
|