function spam_nodeapi in Spam 5
Same name and namespace in other branches
- 6 content/spam_content_node.inc \spam_nodeapi()
Drupal _nodeapi hook. Passes new node content through the spam filter.
Parameters
$node The text of the node.:
$op Specifies the current operation.:
$arg Optional argument.:
Return value
None.
File
- ./
spam.module, line 589
Code
function spam_nodeapi(&$node, $op, $arg = 0) {
global $user;
switch ($op) {
case 'view':
if ($arg === 0) {
if (user_access('bypass filter')) {
spam_log(SPAM_DEBUG, t('spam_nodeapi: skipping node "%title" for user "@name"', array(
'%title' => $node->title,
'@name' => $user->name,
)), 'node', $node->nid);
return;
}
// check if this is a blacklisted spammer IP
spam_ip_filter('node', $node->nid);
}
break;
case 'insert':
case 'update':
if (user_access('bypass filter')) {
spam_log(SPAM_DEBUG, t('spam_nodeapi: skipping node "%title" for user "@name"', array(
'%title' => $node->title,
'%name' => $user->name,
)), 'node', $node->nid);
return;
}
if (variable_get("spam_filter_{$node->type}", 0)) {
spam_log(SPAM_LOG, t('spam_nodeapi: %action action for node "%title"', array(
'%action' => $op,
'%title' => $node->title,
)), 'node', $node->nid);
spam_content_filter('node', $node->nid, $node->title, $node->body);
}
break;
case 'delete':
spam_log(SPAM_LOG, t('spam_nodeapi: deleting node "%title"', array(
'%title' => $node->title,
)), 'node', $node->nid);
db_query("DELETE FROM {spam_tracker} WHERE id = %d AND source = '%s'", $node->nid, 'node');
db_query("DELETE FROM {spam_reported} WHERE id = %d AND source = '%s'", $node->nid, 'node');
break;
}
}