You are here

function _invite_validate_emails in Invite 5

Same name and namespace in other branches
  1. 5.2 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 database query to execute. The query is expected to conatain one replacement variable, namely a <code>IN(%s)</code> construct, where the given list of e-mail addresses will be inserted.

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

Return value

The list of failed e-mail addresses.

1 call to _invite_validate_emails()
invite_form_validate in ./invite.module
Forms API callback; validates the incoming form data.

File

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

Code

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

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