function spam_comment in Spam 5
Same name and namespace in other branches
- 6 content/spam_content_comment.inc \spam_comment()
Drupal _comment hook. Passes new comments to the spam filter.
Parameters
$comment The text of the comment.:
$action Specifies the action affecting the current comment.:
File
- ./
spam.module, line 538
Code
function spam_comment($comment, $action) {
global $user;
$comment = (object) $comment;
/* Spam URLs can be embedded in the name, email adress or web address of
* anonymous comments, so we append this to the comment text. Note that
* this can have the negative affect of causing an artificially high number
* of URLs to appear in a comment.
*/
$local_comment->comment = "{$comment->comment} {$comment->name} {$comment->mail} {$comment->homepage}";
switch ($action) {
case 'view':
if ($comment->submit == t('Post comment')) {
// Previewing a new comment.
if (user_access('bypass filter')) {
spam_log(SPAM_DEBUG, t('spam_comment: skipping comment "%subject" for user "@name"', array(
'%subject' => $comment->subject,
'@name' => $user->name,
)), 'comment', $comment->cid);
}
else {
// Check if this IP has been blacklisted, if so we don't return...
spam_ip_filter('comment', $comment->cid);
}
}
break;
case 'insert':
case 'update':
if (user_access('bypass filter')) {
spam_log(SPAM_DEBUG, t('spam_comment: skipping comment "%subject" for user "@name"', array(
'%subject' => $comment->subject,
'@name' => $user->name,
)), 'comment', $comment->cid);
return;
}
if (variable_get('spam_filter_comments', 1)) {
spam_log(SPAM_LOG, t('spam_comment: @action action for comment "%subject"', array(
'@action' => $action,
'%subject' => $comment->subject,
)), 'comment', $comment->cid);
spam_content_filter('comment', $comment->cid, $comment->subject, $local_comment->comment);
}
break;
case 'delete':
spam_log(SPAM_LOG, t('spam_comment: deleting comment "%subject"', array(
'%subject' => $comment->subject,
)), 'comment', $comment->cid);
db_query("DELETE FROM {spam_tracker} WHERE id = %d AND source = '%s'", $comment->cid, 'comment');
db_query("DELETE FROM {spam_reported} WHERE id = %d AND source = '%s'", $comment->cid, 'comment');
break;
}
}