You are here

function node_revision_delete in Drupal 5

Same name and namespace in other branches
  1. 8 core/modules/node/node.module \node_revision_delete()
  2. 4 modules/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 string reference to 'node_revision_delete'
node_menu in modules/node/node.module
Implementation of hook_menu().

File

modules/node/node.module, line 1808
The core that allows content to be submitted to the site. Modules and scripts may programmatically submit nodes using the usual form API pattern.

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) {
        if ($node = node_load($nid, $revision)) {
          return drupal_get_form('node_revision_delete_confirm', $node);
        }
        else {
          drupal_set_message(t('Deletion failed. You tried to delete a non-existing revision.'));
        }
      }
      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();
}