Esempio n. 1
0
$usersurl = new moodle_url('/enrol/users.php', array('id' => $course->id));
// The URl to return the user too after this screen.
$returnurl = new moodle_url($usersurl, $manager->get_url_params() + $table->get_url_params());
// The URL of this page
$url = new moodle_url('/enrol/self/editenrolment.php', $returnurl->params());
$PAGE->set_url($url);
$PAGE->set_pagelayout('admin');
navigation_node::override_active_url($usersurl);
// Gets the compontents of the user enrolment
list($instance, $plugin) = $manager->get_user_enrolment_components($ue);
// Check that the user can manage this instance, and that the instance is of the correct type
if (!$plugin->allow_manage($instance) || $instance->enrol != 'self' || !$plugin instanceof enrol_self_plugin) {
    print_error('erroreditenrolment', 'enrol');
}
// Get the self enrolment edit form
$mform = new enrol_self_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_self');
Esempio n. 2
0
$usersurl = new moodle_url('/enrol/users.php', array('id' => $course->id));
// The URl to return the user too after this screen.
$returnurl = new moodle_url($usersurl, $manager->get_url_params() + $table->get_url_params());
// The URL of this page.
$url = new moodle_url('/enrol/self/editenrolment.php', $returnurl->params());
$PAGE->set_url($url);
$PAGE->set_pagelayout('admin');
navigation_node::override_active_url($usersurl);
// Gets the components of the user enrolment.
list($instance, $plugin) = $manager->get_user_enrolment_components($ue);
// Check that the user can manage this instance, and that the instance is of the correct type.
if (!$plugin->allow_manage($instance) || $instance->enrol != 'self' || !$plugin instanceof enrol_self_plugin) {
    print_error('erroreditenrolment', 'enrol');
}
// Get the self enrolment edit form.
$mform = new enrol_self_user_enrolment_form($url, array('user' => $user, 'course' => $course, 'ue' => $ue));
$mform->set_data($PAGE->url->params());
if ($mform->is_cancelled()) {
    redirect($returnurl);
} else {
    if ($data = $mform->get_data()) {
        if ($manager->edit_enrolment($ue, $data)) {
            redirect($returnurl);
        }
    }
}
$fullname = fullname($user);
$title = get_string('editenrolment', 'enrol_self');
$PAGE->set_title($title);
$PAGE->set_heading($title);
$PAGE->navbar->add($title);