You are here

function username_check_mail_callback in Username originality AJAX check 7

Same name and namespace in other branches
  1. 8 username_check.unique.inc \username_check_mail_callback()

Main AJAX function: originality check menu callback for email.

1 string reference to 'username_check_mail_callback'
username_check_menu in ./username_check.module
Implementation of hook_menu().

File

./username_check.unique.inc, line 116
AJAX callbacks for the username_check module.

Code

function username_check_mail_callback() {
  $output = array();
  $mail = $_GET['mail'];
  $ret = user_validate_mail($mail);
  if ($ret) {
    $output['allowed'] = FALSE;
    $output['msg'] = $ret;
  }
  else {
    $ret = user_is_blocked($mail);
    if ($ret) {
      $output['allowed'] = FALSE;
      $output['msg'] = t('The e-mail address %mail is not allowed.', array(
        '%mail' => $mail,
      ));
    }
    else {
      $mail = check_plain($mail);
      $ret = _username_check_is_mail_exists($mail);
      if ($ret) {
        $output['allowed'] = FALSE;
        $output['msg'] = t('The e-mail address %mail is already in the system, you have an account here. Please ' . l('login,', 'user') . ' or if you\'ve forgotten your password, ' . l('request a new password', 'user/password') . '.', array(
          '%mail' => $mail,
        ));
      }
      else {
        $output['allowed'] = TRUE;
      }
    }
  }
  drupal_json_output($output);
}