You are here

function spam_comment in Spam 6

Same name and namespace in other branches
  1. 5 spam.module \spam_comment()

Drupal _comment() hook.

File

content/spam_content_comment.inc, line 13
Include file for integration with comments.

Code

function spam_comment(&$comment, $op) {
  switch ($op) {
    case 'update':
      if (!spam_bypass_filters()) {
        spam_content_update($comment, 'comment');
        $spam = spam_content_is_spam($comment, 'comment', $comment->cid);
        if (isset($spam['is_spam']) && $spam['is_spam']) {
          $comment['is_spam'] = TRUE;
        }
      }
      break;
    case 'insert':
      if (!spam_bypass_filters()) {
        spam_content_insert($comment, 'comment');
        $spam = spam_content_is_spam($comment, 'comment', $comment->cid);
        if (isset($spam['is_spam']) && $spam['is_spam']) {
          $comment['is_spam'] = TRUE;
        }
      }
      break;
    case 'delete':
      spam_content_delete($comment, 'comment');
      break;
    case 'form':
      if (is_array($comment['cid'])) {
        _spam_content_comment_cid($comment['cid']['#value']);
      }
      break;
    case 'view':
      $comment->is_spam = FALSE;
      if (spam_score_is_spam(_spam_content_comment_score($comment->cid))) {
        drupal_add_css(drupal_get_path('module', 'spam') . '/content/spam-comment.css');
        $comment->is_spam = TRUE;
      }
      break;
  }
}