function bayesian_spamapi in Spam 5.3
Spam API Hook
File
- filters/
bayesian/ bayesian.module, line 15
Code
function bayesian_spamapi($op, $type = NULL, $content = array(), $fields = array(), $extra = NULL) {
switch ($op) {
case 'filter':
if (!module_invoke('spam', 'filter_enabled', 'bayesian', $type, $content, $fields, $extra)) {
return;
}
return bayesian_spam_filter($content, $type, $fields, $extra);
case 'filter_module':
return 'bayesian';
break;
case 'filter_info':
return array(
'name' => t('Bayesian filter'),
'module' => t('bayesian'),
'description' => t('A bayesian spam filter.'),
'help' => t('The bayesian filter can learn to tell the difference between valid content spam content.'),
);
break;
case 'filter_install':
return array(
'status' => SPAM_FILTER_ENABLED,
);
case 'mark_as_spam':
case 'mark_as_not_spam':
if (!module_invoke('spam', 'filter_enabled', 'bayesian', $type, $content, $fields, $extra)) {
return;
}
spam_log(SPAM_DEBUG, 'bayesian_spamapi', t('@op', array(
'@op' => $op,
)), $type, $extra['id']);
$fields = spam_invoke_module($type, 'filter_fields', $extra['content']);
$tokenizer = variable_get('bayesian_tokenizer', 'bayesian_tokenize');
$tokens = $tokenizer($extra['content'], $type, $fields, $extra);
bayesian_tokens_update('spam', $tokens, $op == 'mark_as_spam' ? TRUE : FALSE, $type, $extra['id']);
break;
}
}