function antispam_content_spam_operation in AntiSpam 6
Same name and namespace in other branches
- 7 antispam.module \antispam_content_spam_operation()
Mark content as spam or remove the mark.
Parameters
string Content type; can be either 'node' or 'comment'.:
object Content object.:
string Operation; it can be 'submit-spam' or 'submit-ham'.:
boolean TRUE to log action (default); FALSE otherwise (ie. the caller logs the action).:
string Signature; Currently DEFENSIO is the only one that returns this.:
float Spaminess; Currently DEFENSIO is the only one that returns this.:
4 calls to antispam_content_spam_operation()
- antispam_callback_set_spam_status in ./
antispam.module - Menu callback; mark/unmark content as spam.
- antispam_confirm_multiple_operation_submit in ./
antispam.admin.inc - confirm_form callback; perform the actual operation against selected content.
- antispam_nodeapi in ./
antispam.module - Implementation of hook_nodeapi().
- _antispam_comment_form_submit in ./
antispam.module - Comment form submit callback; check for spam.
File
- ./
antispam.module, line 1757
Code
function antispam_content_spam_operation($content_type, $content, $op, $log_action = TRUE) {
if ($content_type == 'node') {
global $user;
$content_id = $content->nid;
$content_title = $content->title;
$content_link = l(t('view'), 'node/' . $content->nid);
$user_mail = isset($user->mail) ? $user->mail : '';
}
else {
// comment
$content_id = $content->cid;
$content_title = $content->subject;
$content_link = l(t('view'), 'node/' . $content->nid, array(
'fragment' => 'comment-' . $content->cid,
));
$user_mail = $content->mail;
}
if ($op == 'submit-spam') {
if (variable_get('antispam_connection_enabled', 1)) {
if (antispam_get_service_provider() == DEFENSIO_SERVICE) {
// DEFENSIO
if ($content->signature == '') {
// In we do not have the content signature, then we first need to
// audit the comment and obtain the signature
$api_result = antispam_api_cmd_comment_check($content_type, $content);
$content->signature = $api_result[1];
$content->spaminess = $api_result[2];
}
}
antispam_api_cmd_submit_spam($content_type, $content);
$action = $content_type == 'node' ? t('Content submitted as spam') : t('Comment submitted as spam');
}
else {
$action = $content_type == 'node' ? t('Content marked as spam') : t('Comment marked as spam');
}
$hostname = !empty($content->hostname) ? $content->hostname : ip_address();
db_query('INSERT INTO {antispam_spam_marks} (content_type, content_id, spam_created, hostname, mail, signature, spaminess) VALUES (\'%s\', %d, %d, \'%s\', \'%s\', \'%s\', %f)', $content_type, $content_id, time(), $hostname, $user_mail, $content->signature, $content->spaminess);
}
else {
// submit-ham
if (variable_get('antispam_connection_enabled', 1)) {
if (antispam_get_service_provider() == DEFENSIO_SERVICE) {
// DEFENSIO
if ($content->signature == '') {
// In we do not have the content signature, then we first need to
// audit the comment and obtain the signature
$api_result = antispam_api_cmd_comment_check($content_type, $content);
$content->signature = $api_result[1];
$content->spaminess = $api_result[2];
}
}
antispam_api_cmd_submit_ham($content_type, $content);
$action = $content_type == 'node' ? t('Content submitted as ham') : t('Comment submitted as ham');
}
else {
$action = $content_type == 'node' ? t('Content marked as ham') : t('Comment marked as ham');
}
db_query('DELETE FROM {antispam_spam_marks} WHERE content_type = \'%s\' AND content_id = %d', $content_type, $content_id);
}
if ($log_action) {
watchdog('content', '@action: @title', array(
'@action' => $action,
'@title' => $content_title,
), WATCHDOG_NOTICE, $content_link);
}
antispam_clear_cache();
}