コード例 #1
0
 function validation($data, $files)
 {
     $errors = parent::validation($data, $files);
     // Ensure we don't miss errors from any higher-level validation
     if ($data['lastname'] == '') {
         $errors['lastname'] = get_string('value_required', 'local_obu_application');
     } else {
         $applicants = get_applicants_by_name($data['lastname']);
         if (count($applicants) == 0) {
             $errors['lastname'] = get_string('user_not_found', 'local_obu_application');
         }
     }
     return $errors;
 }
コード例 #2
0
$dir = $home . 'local/obu_application/';
$program = $dir . 'mdl_list.php';
$heading = get_string('list_applications', 'local_obu_application');
$PAGE->set_url($program);
$PAGE->set_pagelayout('standard');
$PAGE->set_context($context);
$PAGE->set_heading($SITE->fullname);
$PAGE->set_title($heading);
$message = '';
$applicants = null;
$mform = new mdl_list_form(null, array());
if ($mform->is_cancelled()) {
    redirect($home);
} else {
    if ($mform_data = $mform->get_data()) {
        $applicants = get_applicants_by_name($mform_data->lastname);
        if (count($applicants) == 1) {
            $url = $dir . 'mdl_applications.php?userid=' . array_values($applicants)[0]->userid;
            redirect($url);
        }
    }
}
echo $OUTPUT->header();
echo $OUTPUT->heading($heading);
if ($message) {
    notice($message, $url);
} else {
    $mform->display();
    if ($applicants != null) {
        foreach ($applicants as $applicant) {
            $url = $dir . 'mdl_applications.php?userid=' . $applicant->userid;