function publish_button_status in Publish button 7
Callback to publish/unpublish node, preferable used via Views.
1 string reference to 'publish_button_status'
- publish_button_menu in ./
publish_button.module - Implements hook_menu().
File
- ./
publish_button.module, line 305 - Functions to create a publish button. Real simple, but could be needed.
Code
function publish_button_status($nid) {
if (!isset($_GET['csrf_token']) || !drupal_valid_token($_GET['csrf_token'], 'publish_button_' . $nid)) {
drupal_access_denied();
return;
}
// Load the node in a object so we could use it.
$node = node_load($nid);
// If the node is published.
if ($node->status == 1) {
$node->status = 0;
node_save($node);
}
elseif ($node->status == 0) {
$node->status = 1;
node_save($node);
}
drupal_goto(drupal_get_destination());
}