function user_student_edit_student_courses_form_validate

7.x user.student.inc user_student_edit_student_courses_form_validate($form, $form_state)
6.x user.student.inc user_student_edit_student_courses_form_validate($form, $form_state)
5.x user.student.inc user_student_edit_student_courses_form_validate($form, $form_state)

File

modules/user/user.student.inc, line 714
Keep track of functions dealing specifically with student user management

Code

function user_student_edit_student_courses_form_validate($form, $form_state) {
  // If the user requested it, check to see if the course exists (in the draft_courses table)

  if ($form_state ["values"]["warn_me"] === TRUE) {
    // Yes, the user wants to be warned if they entered a course which doesn't exist.
    $number_of_courses = intval($form_state ["values"]["number_of_courses"]);
    for ($t = 0; $t < $number_of_courses; $t++) {
      $course = trim($form_state ["values"]["course_$t"]);
      if ($course == "") {
        continue;
      }

      $temp = explode(" ", $course);
      $subject_id = trim($temp [0]);
      $course_num = trim($temp [1]);

      // Check to see that this course exists.
      $res = db_query("SELECT subject_id FROM draft_courses
                       WHERE subject_id = '?'
                       AND course_num = '?' ", $subject_id, $course_num);
      $cur = db_fetch_array($res);
      if ($cur ["subject_id"] != $subject_id) {
        form_error("course_$t", t("The course %subject_id %course_num could not be found in the draft_courses table.  A typo?  Your data has NOT been saved.", 
        array("%subject_id" => $subject_id, "%course_num" => $course_num)));
      }

    }
  }



}