function user_edit_user_form_validate

7.x user.module user_edit_user_form_validate($form, $form_state)
6.x user.module user_edit_user_form_validate($form, $form_state)
4.x user.module user_edit_user_form_validate($form, $form_state)
5.x user.module user_edit_user_form_validate($form, $form_state)

Validate handler for editing faculty users.

File

modules/user/user.module, line 2169

Code

function user_edit_user_form_validate($form, $form_state) {

  $values = $form_state ["values"];

  // If a password was given, make sure it is appropriate.
  if (trim($values ["new_password"]) != "") {
    if (strlen(trim($values ["new_password"])) < 5) {
      form_error("new_password", t("Please enter a password that is at least 5 characters long."));
      return;
    }
  }

  // If creating a new user, make sure new_student_cwid and new_user_name are not
  // already in use.
  if ($values ["faculty_cwid"] == "new") {
    $new_cwid = trim($values ["new_faculty_cwid"]);
    $new_user_name = trim($values ["new_user_name"]);


    // Check that username is at least 4 characters
    if (strlen($new_user_name) < 4) {
      form_error("new_user_name", t("The username you entered is too short.  It must be at least 4 characters.
                                      Please select a different username."));
      return;

    }


    // Check cwid isn't already in use.
    $test = db_result(db_query("SELECT cwid FROM users WHERE cwid = ? AND is_faculty = '1'", $new_cwid));
    if ($test == $new_cwid) {
      form_error("new_faculty_cwid", t("The cwid you entered is already in use.  Please select a different cwid."));
      return;
    }

    // Check user_name isn't already in use.
    $test = db_result(db_query("SELECT user_name FROM users WHERE user_name = ? ", $new_user_name));
    if ($test == $new_user_name) {
      form_error("new_user_name", t("The username you entered is already in use.  Please select a different username."));
      return;
    }

  }


}