function publishcontent_toggle_status in Publish Content 6
Same name and namespace in other branches
- 5.2 publishcontent.module \publishcontent_toggle_status()
- 5 publishcontent.module \publishcontent_toggle_status()
- 7 publishcontent.module \publishcontent_toggle_status()
Menu callback node/%/publish/% and node/%/unpublish/%
Parameters
$node a node object:
1 string reference to 'publishcontent_toggle_status'
- publishcontent_menu in ./
publishcontent.module - Implements of hook_menu().
File
- ./
publishcontent.module, line 157 - Add button to publish or unpublish a node, with access control based on the node type
Code
function publishcontent_toggle_status($node) {
// XOR the current status with 1 to get the opposite value.
$node->status = $node->status ^ 1;
// If this content type specifies that a new revision should be created on
// editing, then make sure to respect this option.
$node_options = variable_get('node_options_' . $node->type, array());
if (in_array('revision', $node_options)) {
$node->revision = 1;
}
node_save($node);
drupal_set_message(_publishcontent_get_message($node->nid, $node->title, $node->status));
drupal_goto('node/' . $node->nid);
}