You are here

function node_revision_delete in Drupal 4

Same name and namespace in other branches
  1. 8 core/modules/node/node.module \node_revision_delete()
  2. 5 modules/node/node.module \node_revision_delete()
  3. 7 modules/node/node.module \node_revision_delete()
  4. 9 core/modules/node/node.module \node_revision_delete()

Delete the revision with specified revision number. A "delete revision" nodeapi event is invoked when a revision is deleted.

1 call to node_revision_delete()
node_revisions in modules/node.module
Menu callback for revisions related activities.

File

modules/node.module, line 1374
The core that allows content to be submitted to the site.

Code

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();
}