You are here

function spam_mark_as_spam in Spam 5.3

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

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

6 calls to spam_mark_as_spam()
comment_spamapi_form_alter in modules/spam_comment.inc
Form alter gets it's 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.)
duplicate_spam_filter in filters/duplicate/duplicate.module
Determine whether or not the content is spam.
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_is_spam in ./spam.module
API call to simply test if content is spam or not. No action is taken.

... See full list

1 string reference to 'spam_mark_as_spam'
spam_menu in ./spam.module
Drupal _menu() hook.

File

./spam.module, line 1660

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 = %d", $type, $id));
  if (!$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']);
    $extra['content'] = spam_invoke_module($type, 'load', $id);
  }
  else {
    $hostname = spam_invoke_module($type, 'hostname', $id);
    db_query("INSERT INTO {spam_tracker} (content_type, content_id, score, hostname, timestamp) VALUES('%s', %d, %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 = %d", $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...
    spam_unpublish($type, $id);
  }
  if ($extra['redirect']) {
    spam_invoke_module($type, 'redirect', $id);
  }
}