You are here

function _user_edit_validate in Drupal 6

Same name and namespace in other branches
  1. 4 modules/user.module \_user_edit_validate()
  2. 5 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 1643
Enables the user registration and login system.

Code

function _user_edit_validate($uid, &$edit) {

  // Validate the username when: new user account; or user is editing own account and can change username; or an admin user.
  if (!$uid || $GLOBALS['user']->uid == $uid && user_access('change own username') || user_access('administer users')) {
    if ($error = user_validate_name($edit['name'])) {
      form_set_error('name', $error);
    }
    else {
      if (db_result(db_query("SELECT COUNT(*) 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_result(db_query("SELECT COUNT(*) 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'],
        )));
      }
    }
  }
}