function _revisioning_unpublish_node in Revisioning 7
Same name and namespace in other branches
- 8 revisioning_api.inc \_revisioning_unpublish_node()
- 6.4 revisioning_api.inc \_revisioning_unpublish_node()
- 6.3 revisioning_api.inc \_revisioning_unpublish_node()
Unpublish node, without calling node_save().
Parameters
object|int $nid_or_node: Target $node object or nid of target node
bool $clear_cache: Whether to clear the cache afterwards or not. Clearing the cache on every node during bulk operations can be time-consuming.
1 call to _revisioning_unpublish_node()
- _revisioning_unpublish_revision in ./
revisioning_api.inc - Unpublish revision (i.e. the node).
File
- ./
revisioning_api.inc, line 384 - API functions of Revisioning module
Code
function _revisioning_unpublish_node($nid_or_node, $clear_cache = TRUE) {
$node = is_object($nid_or_node) ? $nid_or_node : node_load($nid_or_node);
db_update('node')
->fields(array(
'changed' => time(),
'status' => NODE_NOT_PUBLISHED,
))
->condition('nid', $node->nid)
->execute();
db_update('node_revision')
->fields(array(
'status' => NODE_NOT_PUBLISHED,
))
->condition('vid', $node->vid)
->execute();
$node->status = NODE_NOT_PUBLISHED;
// Make sure the alias, if present, is not changed when unpublishing.
if (!isset($node->path['pathauto'])) {
$node->path = array(
// So that pathauto_node_update() does nothing.
'alias' => '',
// So that pathauto_node_update() does nothing.
'pathauto' => FALSE,
);
}
elseif (!isset($node->path['alias'])) {
// [#1328180], [#1576552]
$node->path['alias'] = '';
}
$node->original = clone $node;
$node->original->status = NODE_PUBLISHED;
module_invoke_all('node_update', $node);
module_invoke_all('entity_update', $node, 'node');
// Update node_access table.
node_access_acquire_grants($node);
if ($clear_cache) {
cache_clear_all();
}
}