--- invite.module 2008-10-06 09:03:08.000000000 -0400 +++ invite.module.new 2009-03-29 21:03:25.000000000 -0400 @@ -911,6 +911,16 @@ function invite_form_validate($form, &$f drupal_set_message($error, 'error'); } + if($emails) { + //check site wide access rules + $failed_emails = _invite_validate_emails_access($emails); + if (count($failed_emails)) { + $error = format_plural(count($failed_emails), 'The following recipient is disallowed based on site access rules:', 'The following recipients are disallowed based on site access rules:') .'
'; + $error .= implode(', ', array_map('check_plain', $failed_emails)); + drupal_set_message($error, 'error'); + } + } + // Check that there is at least one valid e-mail remaining after filtering // out dupes. if (count($emails) == 0) { @@ -977,6 +987,27 @@ function _invite_get_emails($string) { } /** + * Filter out e-mails based on site access rules + * + * @param &$emails + * The list of e-mail addresses to validate. When this function returns, all + * invalid e-mails have already been removed. + * @return + * An array of invalid e-mail addresses. + */ +function _invite_validate_emails_access(&$emails) { + $failed_emails = array(); + foreach($emails as $email) { + if (drupal_is_denied('mail', $email)) { + $failed_emails[] = $email; + } + } + // Keep only valid e-mails. + $emails = array_diff($emails, $failed_emails); + return $failed_emails; +} + +/** * Filter out e-mails based on a database query. * * @param $sql