You are here

function cleantalk_validate_webform in Anti Spam by CleanTalk 7.4

Same name and namespace in other branches
  1. 8.4 cleantalk.module \cleantalk_validate_webform()
  2. 8.3 cleantalk.module \cleantalk_validate_webform()
  3. 7.5 cleantalk.module \cleantalk_validate_webform()
  4. 9.1.x cleantalk.module \cleantalk_validate_webform()

Cleantalk webform validation function.

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

File

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

Code

function cleantalk_validate_webform(&$form, &$form_state) {
  if (variable_get('cleantalk_check_webforms', 0) && CleantalkFuncs::_cleantalk_check_form_submit_handlers($form_state['triggering_element']['#parents'])) {
    $spam_check = array();
    $ct_temp_msg_data = CleantalkFuncs::_cleantalk_get_fields_any($_POST);
    $spam_check['type'] = 'webform';
    $spam_check['sender_email'] = $ct_temp_msg_data['email'] ? $ct_temp_msg_data['email'] : '';
    $spam_check['sender_nickname'] = $ct_temp_msg_data['nickname'] ? $ct_temp_msg_data['nickname'] : '';
    $spam_check['message_title'] = $ct_temp_msg_data['subject'] ? $ct_temp_msg_data['subject'] : '';
    $spam_check['message_body'] = $ct_temp_msg_data['message'] ? $ct_temp_msg_data['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']);
    }
  }
}