You are here

function spam_mark_as_not_spam in Spam 6

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

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

7 calls to spam_mark_as_not_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_admin_feedback_form_submit in ./spam.module
Process spam feedback.
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_mark_as_not_spam_callback in ./spam.module
Menu callback that is used for the not spam mark links.
spam_mark_comment_as_not_spam_action in content/spam_content_comment.inc
Implementation of a Drupal action. Mark comment as not spam.

... See full list

File

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

Code

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

  // TODO: Fix this loop
  static $loop = array();
  if (isset($loop[$id])) {
    spam_log(SPAM_DEBUG, 'spam_mark_as_not_spam', t('FIX ME: looping'), $type, $id);
    return;
  }
  $loop[$id] = TRUE;
  _spam_update_statistics(t('@type marked as not 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 (!isset($extra['score'])) {
    $extra['score'] = 1;
  }
  spam_log(SPAM_VERBOSE, 'spam_mark_as_not_spam', t('marked as not 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 {
    if ($id) {
      $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));
    }
  }
  if (!isset($extra['content'])) {
    $extra['content'] = spam_invoke_module($type, 'load', $id);
  }
  $extra['id'] = $id;
  spam_invoke_api('mark_as_not_spam', $type, array(), array(), $extra);
  if ($id) {

    // We've already filtered the content
    $_SESSION['spam_bypass_spam_filter'] = TRUE;

    // For now, we're hard coding the actions...
    spam_publish($type, $id);
  }
  if (!empty($extra['redirect'])) {
    spam_invoke_module($type, 'redirect', $id);
  }
}