You are here

function cleantalk_comment_presave in Anti Spam by CleanTalk 7.2

Same name and namespace in other branches
  1. 8.4 cleantalk.module \cleantalk_comment_presave()
  2. 8 cleantalk.module \cleantalk_comment_presave()
  3. 8.3 cleantalk.module \cleantalk_comment_presave()
  4. 7.5 cleantalk.module \cleantalk_comment_presave()
  5. 7 cleantalk.module \cleantalk_comment_presave()
  6. 7.4 cleantalk.module \cleantalk_comment_presave()
  7. 9.1.x cleantalk.module \cleantalk_comment_presave()

Implements hook_comment_presave().

File

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

Code

function cleantalk_comment_presave($comment) {
  $ct_result = _cleantalk_ct_result();
  if (!empty($ct_result['ct_request_id'])) {
    $ct_automod = variable_get('cleantalk_automod', 1);
    if ($ct_automod == 1) {

      // Automoderation enabled - change comment status.
      // Not empty 'ct_result_comment' means bad comment, set status = 0.
      // Empty 'ct_result_comment' means good comment, set status = 1.
      $comment->status = empty($ct_result['ct_result_comment']) ? COMMENT_PUBLISHED : COMMENT_NOT_PUBLISHED;
    }

    // Don't clear 'ct_request_id', use it in cleantalk_comment_insert().
  }
}