You are here

public function StateFlow::set_unpublished in State Machine 7.2

Same name and namespace in other branches
  1. 6 modules/state_flow/plugins/state_flow.inc \StateFlow::set_unpublished()
  2. 7 modules/state_flow/plugins/state_flow.inc \StateFlow::set_unpublished()
1 call to StateFlow::set_unpublished()
StateFlow::on_exit_published in modules/state_flow/plugins/state_flow.inc

File

modules/state_flow/plugins/state_flow.inc, line 289

Class

StateFlow

Code

public function set_unpublished() {
  $this->object->status = 0;

  // Set the unpublished status on the node_revision record for this revision
  $res = db_update('node_revision')
    ->fields(array(
    'status' => $this->object->status,
  ))
    ->condition('vid', $this->object->vid)
    ->execute();

  // If the revision to unpublish is the latest published revision for the
  // node, then unpublish the node itself
  if ($this->object->vid == $this
    ->get_latest_revision($this->object->nid)) {

    // Set the published status on the node record for this node
    $res = db_update('node')
      ->fields(array(
      'status' => $this->object->status,
    ))
      ->condition('nid', $this->object->nid)
      ->execute();
  }

  // Update the node access table for this node.
  $node = node_load($this->object->nid, $this->object->vid, TRUE);
  node_access_acquire_grants($node);
}