node_revision_delete
- Versions
- 4.6 – 5
node_revision_delete($nid,$revision)- 7
node_revision_delete($revision_id)
Delete the revision with specified revision number.
Code
modules/node.module, line 1071
<?php
function node_revision_delete($nid, $revision) {
if (user_access('administer nodes')) {
$node = node_load(array('nid' => $nid));
if ($_POST['edit']['confirm']) {
unset($node->revisions[$revision]);
// If the array is empty, replace the array by an empty string, or
// else we'll generate an SQL warning when we try to save the node.
if (count($node->revisions) == 0) {
$node->revisions = '';
}
node_save($node, array('nid', 'revisions'));
drupal_set_message(t('Deleted revision %revision of %title', array('%revision' => "<em>#$revision</em>", '%title' => theme('placeholder', $node->title))));
drupal_goto('node/'. $nid . (count($node->revisions) ? '/revisions' : ''));
}
else {
$output = theme('confirm',
t('Are you sure you want to delete the revision of %title from %revision-date?', array('%title' => theme('placeholder', $node->title), '%revision-date' => theme('placeholder', format_date($node->revisions[$revision]['timestamp'])))),
'node/'. $nid .'/revisions',
t('This action cannot be undone.'),
t('Delete revision'));
print theme('page', $output);
}
}
}
?>Login or register to post comments 