$PAGE->set_url($url); $PAGE->set_pagelayout('admin'); navigation_node::override_active_url($usersurl); list($instance, $plugin) = $manager->get_user_enrolment_components($ue); if (!$plugin->allow_manage($instance) || $instance->enrol != 'invitation' || !$plugin instanceof enrol_invitation_plugin) { print_error('erroreditenrolment', 'enrol'); } $mform = new enrol_invitation_user_enrolment_form($url, array('user' => $user, 'course' => $course, 'ue' => $ue)); $mform->set_data($PAGE->url->params()); // Check the form hasn't been cancelled. if ($mform->is_cancelled()) { redirect($returnurl); } else { if ($mform->is_submitted() && $mform->is_validated() && confirm_sesskey()) { // The forms been submit, validated and the sesskey has been checked ... edit the enrolment. $data = $mform->get_data(); if ($manager->edit_enrolment($ue, $data)) { redirect($returnurl); } } } $fullname = fullname($user); $title = get_string('editenrolment', 'enrol_invitation'); $PAGE->set_title($title); $PAGE->set_heading($title); $PAGE->navbar->add($title); $PAGE->navbar->add($fullname); echo $OUTPUT->header(); echo $OUTPUT->heading($fullname); $mform->display(); echo $OUTPUT->footer();
/** * Edits the details of a users enrolment in the course */ /** * 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. if ($actiontaken) { if (empty($pageheading)) { $pageheading = $pagetitle; } $PAGE->set_title($pagetitle); $PAGE->set_heading($pageheading);