You are here

function cleantalk_comment_publish in Anti Spam by CleanTalk 8

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

Implements hook_comment_publish().

File

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

Code

function cleantalk_comment_publish($comment) {
  $result = db_select('cleantalk_cids', 'c')
    ->fields('c', array(
    'ct_request_id',
    'ct_result_comment',
  ))
    ->condition('cid', $comment->cid, '=')
    ->range(0, 1)
    ->execute();
  if ($result
    ->rowCount() > 0) {
    $ct_result = $result
      ->fetchObject();

    // If ct_result_comment is not empty then comment is not approved by server.
    // But we publish it then comment is approved by admin.
    // We need to send positive feedback.
    _cleantalk_send_feedback($ct_result->ct_request_id, 1);
    db_delete('cleantalk_cids')
      ->condition('cid', $comment->cid, '=')
      ->execute();
  }
}