コード例 #1
0
        $meta_enrols["{$enrol->id}"] = $enrol;
    }
}
// Deal breaker
if (!$meta_enrols) {
    print_error('ERR_NO_META_ENROL', local_userenrols_plugin::PLUGIN_NAME, $course_url);
}
// Fix up the form. Have not determined yet whether this is a
// GET or POST, but the form will be used in either case.
// Fix up our customdata object to pass to the form constructor
$data = new stdClass();
$data->course = $COURSE;
$data->context = $PAGE->context;
$data->meta_enrols = $meta_enrols;
$data->groups = groups_get_all_groups($course_id);
$data->group_prefs = local_userenrols_plugin::get_group_prefs($COURSE->id);
$formdata = null;
$mform = new local_userenrols_assign_form(local_userenrols_plugin::get_plugin_url('assign', $COURSE->id)->out(), array('data' => $data));
if ($mform->is_cancelled()) {
    // POST request, but cancel button clicked
    redirect($course_url);
} elseif (!$mform->is_submitted() || null == ($formdata = $mform->get_data())) {
    // GET request, or POST request where data did not
    // pass validation, either case display the form
    echo $OUTPUT->header();
    echo $OUTPUT->heading_with_help(get_string('LBL_ASSIGN_TITLE', local_userenrols_plugin::PLUGIN_NAME), 'HELP_PAGE_ASSIGN', local_userenrols_plugin::PLUGIN_NAME);
    $mform->display();
    echo $OUTPUT->footer();
} else {
    // POST request, submit button clicked and formdata
    // passed validation, first check session spoofing