function cleantalk_validate_forum in Anti Spam by CleanTalk 7.5
Same name and namespace in other branches
- 7.4 cleantalk.module \cleantalk_validate_forum()
Cleantalk forum validation function.
1 string reference to 'cleantalk_validate_forum'
- _cleantalk_form_alter in ./
cleantalk.module - Cleantalk inner function - alters needed form.
File
- ./
cleantalk.module, line 148 - Main CleanTalk integration module functions.
Code
function cleantalk_validate_forum(&$form, &$form_state) {
global $user;
if (variable_get('cleantalk_check_forum_topics', 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'] = 'comment';
if (isset($user->mail)) {
$spam_check['sender_email'] = $user->mail;
}
else {
if (empty($form_state['values']['e_mail'])) {
$spam_check['sender_email'] = $ct_temp_msg_data['email'] ? $ct_temp_msg_data['email'] : '';
}
else {
$spam_check['sender_email'] = $form_state['values']['e_mail'];
}
}
if (empty($form_state['values']['name'])) {
$spam_check['sender_nickname'] = $ct_temp_msg_data['nickname'] ? $ct_temp_msg_data['nickname'] : '';
}
else {
$spam_check['sender_nickname'] = $form_state['values']['name'];
}
if (empty($form_state['values']['title'])) {
$spam_check['message_title'] = $ct_temp_msg_data['subject'] ? $ct_temp_msg_data['subject'] : '';
}
else {
$spam_check['message_title'] = $form_state['values']['title'];
}
if (empty($form_state['values']['body']['und'][0]['value'])) {
$spam_check['message_body'] = $ct_temp_msg_data['message'] ? $ct_temp_msg_data['message'] : '';
}
else {
$spam_check['message_body'] = $form_state['values']['body']['und'][0]['value'];
}
$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']);
}
}
}