function user_edit_user_advisees_form_validate

6.x user.module user_edit_user_advisees_form_validate($form, $form_state)
5.x user.module user_edit_user_advisees_form_validate($form, $form_state)

Check to see if we entered a CWID which doesn't exist in students table.

File

modules/user/user.module, line 675

Code

function user_edit_user_advisees_form_validate($form, $form_state) {

  if ($form_state ["values"]["warn_me"] === TRUE) {
    $students = trim($form_state ["values"]["students"]);
    $lines = explode("\n", $students);
    foreach ($lines as $line) {
      $temp = explode("#", $line);
      $line = trim($temp [0]);
      if ($line == "") {
        continue;
      }

      // $line should now contain the CWID

      // Otherwise, check that it exists.
      $uid = db_get_user_id_from_cwid($line, "student");
      if ($uid < 2 || !$uid) {
        form_error("students", t("The CWID %cwid could not be found in the users table as a student.  Your data has NOT been saved.", array("%cwid" => $line)));
      }

    }
  }

}