Index: email_verify.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/email_verify/email_verify.module,v retrieving revision 1.9.2.1 diff -u -r1.9.2.1 email_verify.module --- email_verify.module 11 Apr 2009 10:41:10 -0000 1.9.2.1 +++ email_verify.module 12 May 2010 18:48:28 -0000 @@ -14,8 +14,8 @@ */ function email_verify_help($path, $arg) { if ($path == 'admin/help#email_verify') { - $txt = 'This module verifies that email addresses are valid during account registration or edit.'; - return '

'. t($txt) .'

'; + $txt = t('This module verifies that email addresses are valid during account registration or edit.'); + return '

'. $txt .'

'; } } @@ -37,6 +37,47 @@ } /** + * Implementation of hook_form_alter(). + */ +function email_verify_form_alter(&$form, $form_state, $form_id) { + switch ($form_id) { + case 'node_type_form': + if (isset($form['comment']['comment_anonymous']) + && !$form['comment']['comment_anonymous']['#disabled']) { + $save = $form['comment']['comment_anonymous']; + $form['comment']['comment_anonymous'] = array('#type' => 'fieldset'); + $form['comment']['comment_anonymous']['comment_anonymous'] = $save; + $var_name = 'email_verify_check_' . $form['#node_type']->type; + $form['comment']['comment_anonymous']['email_verify_check'] = array( + '#type' => 'radios', + '#options' => array(0 => t('No'), 1 => t('Yes')), + '#attributes' => array('class' => 'container-inline'), + '#title' => t("Verify user's email address"), + '#description' => t('If this option is selected, then the email address that the user enters will be checked for validity.'), + '#default_value' => variable_get('email_verify_check_' . $form['#node_type']->type, 0), + ); + } + return; + + case 'comment_form': + // If the email field is present, we want to check it. + if (isset($form['mail'])) { + $form['#validate'][] = 'email_verify_comment_email'; + } + } +} + +/** + * Validation handler. + */ +function email_verify_comment_email($form, &$form_state) { + $validation = email_verify_check($form_state['values']['mail']); + if (!is_null($validation)) { + form_set_error('mail', check_plain($validation)); + } +} + +/** * Verifies whether the given mail address exists. * @param $mail * Email address to verify. @@ -56,7 +97,7 @@ 'title' => 'Email Verify', 'page callback' => 'email_verify_checkall', 'access arguments' => array('administer users'), - 'type' => MENU_LOCAL_TASK, + 'type' => MENU_LOCAL_TASK, 'file' => 'email_verify.check.inc', ); return $items;