You are here

function spam_mark_as_spam in Spam 6

Same name and namespace in other branches
  1. 5.3 spam.module \spam_mark_as_spam()

Invoke appropriate actions for marking content as spam. TODO: Integrate with the Actions module, making actions fully configurable.

9 calls to spam_mark_as_spam()
comment_spamapi_form_alter in content/spam_content_comment.inc
Form alter gets its own function so we can reference &$form without causing errors in PHP4 installations. (If we use spamapi, we have to set a default, which PHP4 doesn't support.)
spam_content_filter in ./spam.module
API call to determine the likeliness that a given piece of content is spam, returning a rating from 1% likelihood to 99% likelihood. It is unlikely that you want to call this function directly.
spam_content_insert in ./spam.module
This function is called when new content is first posted to your website.
spam_content_update in ./spam.module
This function is called when content on your website is updated.
spam_filter_duplicate_spam_filter in filters/spam_filter_duplicate/spam_filter_duplicate.module
Determine whether or not the content is spam.

... See full list

File

./spam.module, line 1774
Spam module, v3 Copyright(c) 2006-2008 Jeremy Andrews <jeremy@tag1consulting.com>. All rights reserved.

Code

function spam_mark_as_spam($type, $id, $extra = array()) {

  // TODO: Fix this loop
  static $loop = array();
  if (isset($loop[$id])) {
    spam_log(SPAM_DEBUG, 'spam_mark_as_spam', t('FIX ME: looping'), $type, $id);
    return;
  }
  $loop[$id] = TRUE;
  _spam_update_statistics(t('@type marked as spam', array(
    '@type' => $type,
  )));
  $extra['sid'] = db_result(db_query("SELECT sid FROM {spam_tracker} WHERE content_type = '%s' AND content_id = '%s'", $type, $id));
  if (empty($extra['score'])) {
    $extra['score'] = 99;
  }
  spam_log(SPAM_VERBOSE, 'spam_mark_as_spam', t('marked as spam, score(@score)', array(
    '@score' => $extra['score'],
  )), $type, $id);
  if ($extra['sid']) {
    db_query('UPDATE {spam_tracker} SET score = %d WHERE sid = %d', $extra['score'], $extra['sid']);
  }
  else {
    $hostname = spam_invoke_module($type, 'hostname', $id);
    db_query("INSERT INTO {spam_tracker} (content_type, content_id, score, hostname, timestamp) VALUES('%s', '%s', %d, '%s', %d)", $type, $id, $extra['score'], $hostname, time());
    $extra['sid'] = db_result(db_query("SELECT sid FROM {spam_tracker} WHERE content_type = '%s' AND content_id = '%s'", $type, $id));
  }
  $extra['content'] = spam_invoke_module($type, 'load', $id);
  $extra['id'] = $id;
  spam_invoke_api('mark_as_spam', $type, array(), array(), $extra);
  if ($id) {

    // For now, we're hard coding the actions...
    if (!in_array(variable_get('spam_visitor_action', SPAM_ACTION_PREVENT), array(
      SPAM_ACTION_HOLD,
    ))) {
      spam_unpublish($type, $id);
    }
  }
  if (!empty($extra['redirect'])) {
    spam_invoke_module($type, 'redirect', $id);
  }
}