diff -ruN email_verify-6.x-1.x-2010_03_10-with-comment-patch/email_verify.module email_verify-6.x-1.x-2010_03_10-working/email_verify.module --- email_verify-6.x-1.x-2010_03_10-with-comment-patch/email_verify.module 2010-06-20 13:58:12.000000000 +0100 +++ email_verify-6.x-1.x-2010_03_10-working/email_verify.module 2010-06-20 16:07:56.000000000 +0100 @@ -14,7 +14,7 @@ */ function email_verify_help($path, $arg) { if ($path == 'admin/help#email_verify') { - $txt = t('This module verifies that email addresses are valid during account registration or edit and when an anonymous user posts a comment with contact information.'); + $txt = t('This module verifies that email addresses are valid during account registration or edit, and when a user has to provide contact information on comment and contact forms.'); return '

'. $txt .'

'; } } @@ -63,22 +63,54 @@ if (isset($form['mail'])) { $type = db_result(db_query('SELECT type FROM {node} WHERE nid = %d', $form['nid']['#value'])); if (variable_get("email_verify_check_$type", 0)) { - $form['#validate'][] = 'email_verify_comment_email'; + $form['#validate'][] = 'email_verify_comment_and_contact_email'; } } + return; + + case 'contact_mail_page': + if (isset($form['mail'])) { + $form['#validate'][] = 'email_verify_comment_and_contact_email'; + } + return; + + case 'userplus_add_users': + $form['#validate'][] = 'email_verify_userplus_add_users'; + return; } } /** - * Validation handler. + * Validation handlers. */ -function email_verify_comment_email($form, &$form_state) { +function email_verify_comment_and_contact_email($form, &$form_state) { + if (isset($form['mail']['#access']) && !$form['mail']['#access']) return; $validation = email_verify_check($form_state['values']['mail']); if (!is_null($validation)) { form_set_error('mail', $validation); } } +function email_verify_userplus_add_users($form, &$form_state) { + foreach($form_state['values']['user'] as $index => $user) { + if ($user['mail']) { + // Do an explicit syntax check, because email_verify doesn't report an error in this situation, under the + // assumption that the existing userplus code does the syntax check. Although it does, the way in which + // userplus works means that syntax errors won't be reported until all other email_verify errors have been + // fixed. Doing the syntax check here allows all email-address-related errors to appear at once, which is + // nicer for the user. + $validation = user_validate_mail($user['mail']); + if (is_null($validation)) { + $validation = email_verify_check($user['mail']); + } + if (!is_null($validation)) { + // userplus doesn't highlight errors on the form, hence the non-standard "name" parameter to form_set_error + form_set_error('email_verify_'.$index, $validation); + } + } + } +} + /** * Verifies whether the given mail address exists. * @param $mail