function antispam_callback_set_spam_status in AntiSpam 6
Same name and namespace in other branches
- 7 antispam.module \antispam_callback_set_spam_status()
Menu callback; mark/unmark content as spam.
When content is marked as spam, it is also unpublished (if necessary) and vice-versa.
Parameters
string Content type; it can be 'node' or 'comment'.:
integer Content ID; can be either a nid or a cid.:
string Operation; it can be 'submit-spam' or 'submit-ham'.:
1 string reference to 'antispam_callback_set_spam_status'
File
- ./
antispam.module, line 699
Code
function antispam_callback_set_spam_status($content_type, $object, $op) {
// TODO: again passing object around and reloading the object with antispam_content_load.
if ($content_type == 'node') {
$is_spam = antispam_content_is_spam($content_type, $object->nid);
// Load the content (existence has been checked in hook_menu).
$content = antispam_content_load($content_type, $object->nid);
$is_published = $content->status ? TRUE : FALSE;
}
else {
// comment
$is_spam = antispam_content_is_spam($content_type, $object->cid);
// Load the content (existence has been checked in hook_menu).
$content = antispam_content_load($content_type, $object->cid);
$is_published = $content->status == COMMENT_PUBLISHED ? TRUE : FALSE;
}
// insert or remove the spam marker (publishing/unpublishing if necessary).
if ($op == 'submit-spam') {
if (!$is_spam) {
antispam_content_spam_operation($content_type, $content, 'submit-spam');
antispam_increase_counter(ANTISPAM_COUNT_FALSE_NEGATIVE);
}
if ($is_published) {
antispam_content_publish_operation($content_type, $content, 'unpublish');
}
}
else {
if ($op == 'submit-ham') {
if ($is_spam) {
antispam_content_spam_operation($content_type, $content, 'submit-ham');
antispam_increase_counter(ANTISPAM_COUNT_FALSE_POSITIVE);
}
if (!$is_published) {
antispam_content_publish_operation($content_type, $content, 'publish');
}
}
}
if ($content_type == 'node') {
drupal_goto('node/' . $content->nid);
}
else {
// comment
drupal_goto('node/' . $content->nid, NULL, 'comment-' . $content->cid);
}
}