mirror of
https://github.com/moodle/moodle.git
synced 2025-08-07 18:06:51 +02:00
MDL-23532 enrol - removed general handling of user enrolment editing/unenrolment plugins are now responsible for this
This commit is contained in:
parent
8c6e0ebebb
commit
12a52d7c6e
4 changed files with 4 additions and 120 deletions
|
@ -47,6 +47,7 @@ $PAGE->set_pagelayout('admin');
|
|||
$manager = new course_enrolment_manager($PAGE, $course, $filter);
|
||||
$table = new course_enrolment_users_table($manager, $PAGE);
|
||||
$PAGE->set_url('/enrol/users.php', $manager->get_url_params()+$table->get_url_params());
|
||||
navigation_node::override_active_url(new moodle_url('/enrol/users.php', array('id' => $id)));
|
||||
|
||||
// Check if there is an action to take
|
||||
if ($action) {
|
||||
|
@ -61,26 +62,6 @@ if ($action) {
|
|||
$pagecontent = null;
|
||||
|
||||
switch ($action) {
|
||||
/**
|
||||
* Unenrols a user from this course (includes removing all of their grades)
|
||||
*/
|
||||
case 'unenrol':
|
||||
$ue = $DB->get_record('user_enrolments', array('id'=>required_param('ue', PARAM_INT)), '*', MUST_EXIST);
|
||||
list ($instance, $plugin) = $manager->get_user_enrolment_components($ue);
|
||||
if ($instance && $plugin && $plugin->allow_unenrol($instance) && has_capability("enrol/$instance->enrol:unenrol", $manager->get_context())) {
|
||||
if ($confirm && $manager->unenrol_user($ue)) {
|
||||
redirect($PAGE->url);
|
||||
} else {
|
||||
$user = $DB->get_record('user', array('id'=>$ue->userid), '*', MUST_EXIST);
|
||||
$yesurl = new moodle_url($PAGE->url, array('action'=>'unenrol', 'ue'=>$ue->id, 'confirm'=>1, 'sesskey'=>sesskey()));
|
||||
|
||||
$message = get_string('unenrolconfirm', 'enrol', array('user'=>fullname($user, true), 'course'=>format_string($course->fullname)));
|
||||
$pagetitle = get_string('unenrol', 'enrol');
|
||||
$pagecontent = $OUTPUT->confirm($message, $yesurl, $PAGE->url);
|
||||
}
|
||||
$actiontaken = true;
|
||||
}
|
||||
break;
|
||||
/**
|
||||
* Removes a role from the user with this course
|
||||
*/
|
||||
|
@ -162,27 +143,6 @@ if ($action) {
|
|||
$actiontaken = true;
|
||||
}
|
||||
break;
|
||||
/**
|
||||
* Edits the details of a users enrolment in the course
|
||||
*/
|
||||
case 'edit':
|
||||
$ue = $DB->get_record('user_enrolments', array('id'=>required_param('ue', PARAM_INT)), '*', MUST_EXIST);
|
||||
|
||||
//Only show the edit form if the user has the appropriate capability
|
||||
list($instance, $plugin) = $manager->get_user_enrolment_components($ue);
|
||||
if ($instance && $plugin && $plugin->allow_manage($instance) && has_capability("enrol/$instance->enrol:manage", $manager->get_context())) {
|
||||
$user = $DB->get_record('user', array('id'=>$ue->userid), '*', MUST_EXIST);
|
||||
$mform = new enrol_users_edit_form(NULL, array('user'=>$user, 'course'=>$course, 'ue'=>$ue));
|
||||
$mform->set_data($PAGE->url->params());
|
||||
$data = $mform->get_data();
|
||||
if ($mform->is_cancelled() || ($data && $manager->edit_enrolment($ue, $data))) {
|
||||
redirect($PAGE->url);
|
||||
} else {
|
||||
$pagetitle = fullname($user);
|
||||
}
|
||||
$actiontaken = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// If we took an action display we need to display something special.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue