You are here

function antispam_callback_set_published_status in AntiSpam 6

Same name and namespace in other branches
  1. 7 antispam.module \antispam_callback_set_published_status()

Menu callback; publish/unpublish content.

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 'publish' or 'unpublish'.:

1 string reference to 'antispam_callback_set_published_status'
antispam_load in ./antispam.module

File

./antispam.module, line 662

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 {

    // comment
    // 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');
  }
  else {
    if ($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, NULL, 'comment-' . $content->cid);
  }
}