You are here

function _user_edit_validate in Drupal 5

Same name and namespace in other branches
  1. 4 modules/user.module \_user_edit_validate()
  2. 6 modules/user/user.module \_user_edit_validate()
1 call to _user_edit_validate()
user_user in modules/user/user.module
Implementation of hook_user().

File

modules/user/user.module, line 1395
Enables the user registration and login system.

Code

function _user_edit_validate($uid, &$edit) {
  $user = user_load(array(
    'uid' => $uid,
  ));

  // Validate the username:
  if (user_access('change own username') || user_access('administer users') || arg(1) == 'register') {
    if ($error = user_validate_name($edit['name'])) {
      form_set_error('name', $error);
    }
    else {
      if (db_num_rows(db_query("SELECT uid FROM {users} WHERE uid != %d AND LOWER(name) = LOWER('%s')", $uid, $edit['name'])) > 0) {
        form_set_error('name', t('The name %name is already taken.', array(
          '%name' => $edit['name'],
        )));
      }
      else {
        if (drupal_is_denied('user', $edit['name'])) {
          form_set_error('name', t('The name %name has been denied access.', array(
            '%name' => $edit['name'],
          )));
        }
      }
    }
  }

  // Validate the e-mail address:
  if ($error = user_validate_mail($edit['mail'])) {
    form_set_error('mail', $error);
  }
  else {
    if (db_num_rows(db_query("SELECT uid FROM {users} WHERE uid != %d AND LOWER(mail) = LOWER('%s')", $uid, $edit['mail'])) > 0) {
      form_set_error('mail', t('The e-mail address %email is already registered. <a href="@password">Have you forgotten your password?</a>', array(
        '%email' => $edit['mail'],
        '@password' => url('user/password'),
      )));
    }
    else {
      if (drupal_is_denied('mail', $edit['mail'])) {
        form_set_error('mail', t('The e-mail address %email has been denied access.', array(
          '%email' => $edit['mail'],
        )));
      }
    }
  }

  // If required, validate the uploaded picture.
  if ($file = file_check_upload('picture_upload')) {
    user_validate_picture($file, $edit, $user);
  }
}