You are here

function cleantalk_validate_contact_message in Anti Spam by CleanTalk 7.5

Same name and namespace in other branches
  1. 8.4 cleantalk.module \cleantalk_validate_contact_message()
  2. 8 cleantalk.module \cleantalk_validate_contact_message()
  3. 8.3 cleantalk.module \cleantalk_validate_contact_message()
  4. 7 cleantalk.module \cleantalk_validate_contact_message()
  5. 7.2 cleantalk.module \cleantalk_validate_contact_message()
  6. 7.4 cleantalk.module \cleantalk_validate_contact_message()
  7. 9.1.x cleantalk.module \cleantalk_validate_contact_message()

Cleantalk contact message validation function.

1 string reference to 'cleantalk_validate_contact_message'
_cleantalk_form_alter in ./cleantalk.module
Cleantalk inner function - alters needed form.

File

./cleantalk.module, line 105
Main CleanTalk integration module functions.

Code

function cleantalk_validate_contact_message(&$form, &$form_state) {
  if (variable_get('cleantalk_check_contact_forms', 0) && CleantalkFuncs::_cleantalk_check_form_submit_handlers($form_state['triggering_element']['#parents'])) {
    $spam_check = array();
    $spam_check['type'] = 'contact';
    $spam_check['sender_email'] = !empty($form_state['values']['mail']) ? $form_state['values']['mail'] : '';
    $spam_check['sender_nickname'] = !empty($form_state['values']['name']) ? $form_state['values']['name'] : '';
    $spam_check['message_title'] = !empty($form_state['values']['subject']) ? $form_state['values']['subject'] : '';
    $spam_check['message_body'] = !empty($form_state['values']['message']) ? $form_state['values']['message'] : '';
    $spam_result = CleantalkFuncs::_cleantalk_check_spam($spam_check, form_get_errors());
    if (isset($spam_result) && is_array($spam_result) && $spam_result['errno'] == 0 && $spam_result['allow'] != 1) {
      form_set_error('comment_body', $spam_result['ct_result_comment']);
    }
  }
}