You are here

function cleantalk_node_presave in Anti Spam by CleanTalk 7.2

File

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

Code

function cleantalk_node_presave($node) {
  $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.
      $node->status = empty($ct_result['ct_result_comment']) ? NODE_PUBLISHED : NODE_NOT_PUBLISHED;
    }

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