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. A "delete revision" nodeapi event is invoked when a revision is deleted.

Code

modules/node.module, line 1374

<?php
function node_revision_delete($nid, $revision) {
  if (user_access('administer nodes')) {
    $node = node_load($nid);
    if (node_access('delete', $node)) {
      // Don't delete the current revision
      if ($revision != $node->vid) {
        $node = node_load($nid, $revision);
        $form = array();
        $form['nid'] = array('#type' => 'value', '#value' => $nid);
        $form['vid'] = array('#type' => 'value', '#value' => $revision);
        return confirm_form('node_revision_delete_confirm', $form, 
                     t('Are you sure you want to delete %title revision %revision?', array('%title' => theme('placeholder', $node->title), '%revision' => theme('placeholder', $revision))),
                     "node/$nid/revisions", '', t('Delete'), t('Cancel'));
      }
      else {
        drupal_set_message(t('Deletion failed. You tried to delete the current revision.'));
      }
      if (db_result(db_query('SELECT COUNT(vid) FROM {node_revisions} WHERE nid = %d', $nid)) > 1) {
        drupal_goto("node/$nid/revisions");
      }
      else {
        drupal_goto("node/$nid");
      }
    }
  }
  drupal_access_denied();
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.