function antispam_callback_set_published_status in AntiSpam 7
Same name and namespace in other branches
- 6 antispam.module \antispam_callback_set_published_status()
Menu callback; publish/unpublish content.
Parameters
string $content_type: Can be 'node' or 'comment'.
object $object: Can be either a nid or a cid.
string $op: The operation being performed, can be 'publish' or 'unpublish'.
1 string reference to 'antispam_callback_set_published_status'
- antispam_load in ./
antispam.module - Implements hook_load().
File
- ./
antispam.module, line 624 - Primary hook implementations for the Antispam module.
Code
function antispam_callback_set_published_status($content_type, $object, $op) {
// TODO: Should we be passing the object around or just the ID, or should we
// have antispam_content_load at all?
if ($content_type == 'node') {
// 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 {
// 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;
}
if ($op == 'publish' && !$is_published) {
antispam_content_publish_operation($content_type, $content, 'publish');
}
elseif ($op == 'unpublish' && $is_published) {
antispam_content_publish_operation($content_type, $content, 'unpublish');
}
if ($content_type == 'node') {
drupal_goto('node/' . $content->nid);
}
else {
// comment
drupal_goto('node/' . $content->nid, array(
'fragment' => 'comment-' . $content->cid,
));
}
}