You are here

function _invite_validate_emails in Invite 5.2

Same name and namespace in other branches
  1. 5 invite.module \_invite_validate_emails()
  2. 6.2 invite.module \_invite_validate_emails()
  3. 7.2 invite.module \_invite_validate_emails()

Filter out e-mails based on a database query.

Parameters

$sql: The query to execute.

&$emails: The list of e-mail addresses to validate. When this function returns, all invalid e-mails have already been removed.

...: More arguments.

Return value

The list of failed e-mail addresses.

1 call to _invite_validate_emails()
invite_form_validate in ./invite.module
Forms API callback; validate submitted form data.

File

./invite.module, line 962
Allows your users to send and track invitations to join your site.

Code

function _invite_validate_emails($sql, &$emails) {
  $failed_emails = array();
  $args = func_get_args();
  array_shift($args);
  array_shift($args);
  array_unshift($args, "'" . implode("','", array_map('db_escape_string', $emails)) . "'");
  $result = db_query(vsprintf($sql, $args));
  while ($row = db_fetch_object($result)) {
    $failed_emails[] = $row->email;
  }

  // Leave only valid emails.
  $emails = array_diff($emails, $failed_emails);
  return $failed_emails;
}