function _cleantalk_form_alter in Anti Spam by CleanTalk 7.2
Same name and namespace in other branches
- 8.4 cleantalk.module \_cleantalk_form_alter()
- 8 cleantalk.module \_cleantalk_form_alter()
- 8.3 cleantalk.module \_cleantalk_form_alter()
- 7.5 cleantalk.module \_cleantalk_form_alter()
- 7 cleantalk.module \_cleantalk_form_alter()
- 7.4 cleantalk.module \_cleantalk_form_alter()
- 9.1.x cleantalk.module \_cleantalk_form_alter()
Cleantalk inner function - alters needed form.
6 calls to _cleantalk_form_alter()
- cleantalk_form_comment_form_alter in ./cleantalk.module 
- Implements hook_form_BASE_FORM_ID_alter().
- cleantalk_form_comment_node_webform_form_alter in ./cleantalk.module 
- Implements hook_form_BASE_FORM_ID_alter()
- cleantalk_form_contact_personal_form_alter in ./cleantalk.module 
- Implements hook_form_FORM_ID_alter().
- cleantalk_form_contact_site_form_alter in ./cleantalk.module 
- Implements hook_form_FORM_ID_alter().
- cleantalk_form_node_form_alter in ./cleantalk.module 
- Implements hook_form_BASE_FORM_ID_alter().
File
- ./cleantalk.module, line 1864 
- Main CleanTalk integration module functions.
Code
function _cleantalk_form_alter(&$form, &$form_state, $form_id) {
  static $js_cookie_added = FALSE;
  /*if ($js_cookie_added) {
      return;
    }*/
  $ct_link = variable_get('cleantalk_link', 0);
  if ($ct_link != 0) {
    $form['terms_of_use'] = array(
      '#type' => 'item',
      '#markup' => t("<a href='https://cleantalk.org/drupal-anti-spam-module-wo-captcha'>Drupal spam</a> blocked by CleanTalk."),
      '#required' => FALSE,
    );
  }
  $js_cookie_added = TRUE;
  if ($form_id == 'user_register_form') {
    $session_time_key = 'ct_submit_register_time';
    $form['#validate'][] = 'cleantalk_validate_register';
  }
  else {
    $session_time_key = 'ct_submit_comment_time';
    if ($form_id == 'contact_site_form' || $form_id == 'contact_personal_form') {
      $form['#validate'][] = 'cleantalk_validate_contact_message';
    }
    else {
      $form['#validate'][] = 'cleantalk_validate_comment';
    }
  }
  $field_name = 'ct_checkjs';
  $ct_check_def = '0';
  if (!isset($_COOKIE[$field_name])) {
    setcookie($field_name, $ct_check_def, 0, '/');
  }
}