You are here

function signup_validate_anon_email in Signup 5

Same name and namespace in other branches
  1. 5.2 signup.module \signup_validate_anon_email()
  2. 6.2 includes/signup_form.inc \signup_validate_anon_email()
  3. 6 includes/signup_form.inc \signup_validate_anon_email()
  4. 7 includes/signup_form.inc \signup_validate_anon_email()

Validates an anonymous signup email.

Parameters

$nid The node the user is signing up for.:

$anon_mail The anonymous email address to validate.:

$name Optional. The form element being validated.:

Return value

Boolean. TRUE if the address validates, FALSE otherwise.

1 call to signup_validate_anon_email()
signup_form_validate in ./signup.module
Validates the user signup form

File

./signup.module, line 1260

Code

function signup_validate_anon_email($nid, $anon_mail, $name = FALSE) {
  if (!valid_email_address($anon_mail)) {
    $message = t('Invalid email address entered for signup.');
  }
  elseif (db_num_rows(db_query("SELECT mail FROM {users} WHERE mail = '%s'", $anon_mail))) {
    $message = t('The email address entered belongs to a registered user.');
  }
  elseif (db_num_rows(db_query("SELECT anon_mail FROM {signup_log} WHERE anon_mail = '%s' AND nid = %d", $anon_mail, $nid))) {
    $message = t('The email address entered has already been used to sign up for this event.');
  }

  // If there's no message, it's a valid email, so return success.
  if (!isset($message)) {
    return TRUE;
  }

  // Depending on how we were called, propagate the error accordinly.
  if ($name) {
    form_set_error($name, $message);
  }
  else {
    drupal_set_message($message, 'error');
  }
  return FALSE;
}