You are here

function cleantalk_comment_insert in Anti Spam by CleanTalk 7

Same name and namespace in other branches
  1. 8 cleantalk.module \cleantalk_comment_insert()
  2. 7.2 cleantalk.module \cleantalk_comment_insert()

Implements hook_comment_insert().

File

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

Code

function cleantalk_comment_insert($comment) {
  $ct_result = _cleantalk_ct_result();
  if (!empty($ct_result['ct_request_id'])) {

    // Values of request_id and comment are stored in globals.
    // Store them in DB now.
    db_insert('cleantalk_cids')
      ->fields(array(
      'cid' => $comment->cid,
      'ct_request_id' => $ct_result['ct_request_id'],
      'ct_result_comment' => empty($ct_result['ct_result_comment']) ? '' : $ct_result['ct_result_comment'],
    ))
      ->execute();
    _cleantalk_ct_result('set');
  }
}