You are here

function _revisioning_delete_revision in Revisioning 6.4

Same name and namespace in other branches
  1. 8 revisioning_api.inc \_revisioning_delete_revision()
  2. 6.3 revisioning_api.inc \_revisioning_delete_revision()
  3. 7 revisioning_api.inc \_revisioning_delete_revision()

Delete selected revision of node, provided it's not current.

This is same as node_revision_delete_confirm_submit() in node_pages.inc, except it doesn't put any messages on the screen. This way it becomes reusable (eg. in actions). Since we are calling nodeapi as in node_revision_delete_confirm_submit(), we invoke our "post delete" revisionapi hook in nodeapi. This way revisionapi hooks work the same way both with "delete revision" submit handler and when this function is called, and we don't invoke revisionapi "post delete" hook twice.

@TODO: Insert check to prevent deletion of current revision of node.

Parameters

$node: Target $node object (loaded with target revision) or nid of target node

$vid: optional vid of revision to delete, if provided $node is not object.

File

./revisioning_api.inc, line 236
API functions of Revisioning module

Code

function _revisioning_delete_revision(&$node, $vid = NULL) {
  $node_revision = is_object($node) ? $node : node_load($node, $vid);
  module_invoke_all('revisionapi', 'pre delete', $node_revision);
  db_query("DELETE FROM {node_revisions} WHERE nid = %d AND vid = %d", $node_revision->nid, $node_revision->vid);
  node_invoke_nodeapi($node_revision, 'delete revision');
  watchdog('content', '@type: deleted %title revision %revision.', array(
    '@type' => $node_revision->type,
    '%title' => $node_revision->title,
    '%revision' => $node_revision->vid,
  ));
}