diff --git a/email_verify.admin.inc b/email_verify.admin.inc index acb3bdc..40e19fa 100644 --- a/email_verify.admin.inc +++ b/email_verify.admin.inc @@ -16,36 +16,37 @@ function email_verify_admin_settings($form, &$form_state) { '#title' => t('Enable the Email Verify to verify email adresses'), '#default_value' => variable_get('email_verify_active', 0), '#description' => t('When enabled, Email Verify will check email addresses for validity.'), - ); + ); + + $form['email_verify_message'] = array( + '#type' => 'checkbox', + '#title' => t('Show a message that Email Verify is working on the form'), + '#default_value' => variable_get('email_verify_message', 0), + '#description' => t('When enabled, Email Verify will display a form on the + forms listed below to indicate whether or not it is being checked.'), + ); $form['email_verify_email'] = array( '#type' => 'fieldset', '#title' => t('Forms to check'), '#collapsible' => TRUE, - '#description' => t("Check the boxes for the forms you want to have this module check email addresses on."), - ); - $form['email_verify_email']['email_verify_user_registration'] = array( - '#type' => 'checkbox', - '#title' => t("User registration"), - '#default_value' => variable_get('email_verify_user_registration', 1), - ); - $form['email_verify_email']['email_verify_user_profile'] = array( - '#type' => 'checkbox', - '#title' => t("User profile"), - '#default_value' => variable_get('email_verify_user_profile', 1), - ); - - if (module_exists('contact')) { - $form['email_verify_email']['email_verify_site_contact'] = array( - '#type' => 'checkbox', - '#title' => t("Site-wide contact"), - '#default_value' => variable_get('email_verify_site_contact', 0), + '#collapsed' => FALSE, + '#description' => t("Check the boxes for the forms on which you want to have check email addresses."), ); - $form['email_verify_email']['email_verify_personal_contact'] = array( + + // Invoke the hook to get a list of forms to check. + // We expect an array with the form name as the key and the title for the form + // as the value. + $forms_to_check = module_invoke_all('email_verify_forms'); + asort($forms_to_check); + variable_set('email_verify_forms_to_check', $forms_to_check); + + foreach ($forms_to_check as $form_name => $form_title) { + $form['email_verify_email']['email_verify_' . $form_name] = array( '#type' => 'checkbox', - '#title' => t("Personal contact"), - '#default_value' => variable_get('email_verify_personal_contact', 0), - ); + '#title' => t($form_title), + '#default_value' => variable_get('email_verify_' . $form_name, 0), + ); } $form['#submit'] = array('email_verify_admin_settings_submit'); @@ -54,6 +55,23 @@ function email_verify_admin_settings($form, &$form_state) { } /** + * Implements hook_email_verify_forms(). + */ +function email_verify_email_verify_forms() { + $forms = array( + 'user_register_form' => "User registration", + 'user_profile_form' => "User profile", + ); + + if (module_exists('contact')) { + $forms['site_contact'] = "Site-wide contact"; + $forms['personal_contact'] = "Personal contact"; + } + + return $forms; +} + +/** * Form submit function. */ function email_verify_admin_settings_submit($form, &$form_state) { diff --git a/email_verify.check.inc b/email_verify.check.inc index a6dc352..9d89b99 100644 --- a/email_verify.check.inc +++ b/email_verify.check.inc @@ -27,5 +27,5 @@ function email_verify_checkall() { } } - return theme('table', array('header' => $header, 'rows'=> $rows)); + return theme('table', array('header' => $header, 'rows' => $rows)); } diff --git a/email_verify.module b/email_verify.module index d9a8bf6..faf8ddf 100644 --- a/email_verify.module +++ b/email_verify.module @@ -61,52 +61,29 @@ function email_verify_access_people_email_verify() { return FALSE; } - -/** - * Implements hook_form_FORM_ID_alter() for the user_register form. - */ -function email_verify_form_user_register_form_alter(&$form, &$form_state, $form_id) { - if (variable_get('email_verify_active', 0) && variable_get('email_verify_user_registration', 1)) { - $form['#validate'][] = 'email_verify_edit_validate'; - } -} - /** - * Implements hook_form_FORM_ID_alter() for the user_profile form. + * Implements hook_form_alter(). + * Inserts the validate function if needed. */ -function email_verify_form_user_profile_form_alter(&$form, &$form_state, $form_id) { - if (variable_get('email_verify_active', 0) && variable_get('email_verify_user_profile', 1)) { - $form['#validate'][] = 'email_verify_edit_validate'; - } -} +function email_verify_form_alter(&$form, &$form_state, $form_id) { + if (variable_get('email_verify_active', 0)) { + $forms_to_check = variable_get('email_verify_forms_to_check', array()); + $msg = variable_get('email_verify_message', 0); -/** - * Implements hook_form_FORM_ID_alter() for the contact_site form. - */ -function email_verify_form_contact_site_form_alter(&$form, &$form_state, $form_id) { - if (variable_get('email_verify_active', 0) && module_exists('contact') && variable_get('email_verify_site_contact', 0)) { - $form['#validate'][] = 'email_verify_edit_validate'; - } -} - -/** - * Implements hook_form_FORM_ID_alter() for the contact_personal form. - */ -function email_verify_form_contact_personal_form_alter(&$form, &$form_state, $form_id) { - if (variable_get('email_verify_active', 0) && module_exists('contact') && variable_get('email_verify_personal_contact', 0)) { - $form['#validate'][] = 'email_verify_edit_validate'; - } -} - -/** - * Implements hook_form_FORM_ID_alter(). - * - * For the Entity Registration module's Registration Form. - * https://www.drupal.org/project/registration - */ -function email_verify_form_registration_form_alter(&$form, &$form_state, $form_id) { - if (variable_get('email_verify_active', 0) && variable_get('email_verify_user_registration', 1)) { - $form['#validate'][] = 'email_verify_edit_validate'; + // Is this one of our forms? + if (isset($forms_to_check[$form_id])) { + if (variable_get('email_verify_' . $form_id, 0)) { + $form['#validate'][] = 'email_verify_edit_validate'; + if ($msg) { + drupal_set_message(t('This form is email_verified')); + } + } + } + else { + if ($msg) { + drupal_set_message(t('Email_verify is not checking this form.')); + } + } } }