2004-09-12 12:21:27 +00:00
|
|
|
<?php // $Id$
|
2002-06-04 06:30:51 +00:00
|
|
|
|
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
|
|
|
|
2006-04-12 16:59:51 +00:00
|
|
|
$id = required_param('id', PARAM_INT); //course
|
|
|
|
$user = optional_param('user', $USER->id, PARAM_INT); //user
|
|
|
|
$confirm = optional_param('confirm', 0, PARAM_BOOL);
|
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);
|
|
|
|
|
2004-05-30 20:54:58 +00:00
|
|
|
if ($user->id != $USER->id and !isteacheredit($course->id)) {
|
|
|
|
error("You must be a teacher with editing rights to do this");
|
2002-06-19 15:42:49 +00:00
|
|
|
}
|
|
|
|
|
2005-11-15 21:55:13 +00:00
|
|
|
if ($user->id == $USER->id and !$CFG->allowunenroll or $course->metacourse) {
|
2003-10-12 18:03:50 +00:00
|
|
|
error("You are not allowed to unenroll");
|
|
|
|
}
|
|
|
|
|
2006-04-12 16:59:51 +00:00
|
|
|
if ($confirm and confirm_sesskey()) {
|
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"]);
|
2003-07-30 13:02:45 +00:00
|
|
|
redirect("$CFG->wwwroot/");
|
2002-06-19 15:42:49 +00:00
|
|
|
}
|
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",
|
2004-09-12 12:21:27 +00:00
|
|
|
"<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 {
|
2003-11-28 10:41:06 +00:00
|
|
|
$strunenrolsure = get_string("unenrolsure", "", fullname($user, true));
|
2002-06-19 15:42:49 +00:00
|
|
|
}
|
2002-06-04 06:30:51 +00:00
|
|
|
|
2005-06-15 09:39:26 +00:00
|
|
|
notice_yesno ($strunenrolsure, "unenrol.php?id=$id&user=$user->id&confirm=yes&sesskey=$USER->sesskey", $_SERVER['HTTP_REFERER']);
|
2002-06-04 06:30:51 +00:00
|
|
|
|
2005-03-17 15:12:07 +00:00
|
|
|
print_footer($course);
|
2002-06-04 06:30:51 +00:00
|
|
|
|
|
|
|
?>
|