You are here

function drush_node_revision_delete_nrd_delete_prior_revisions in Node Revision Delete 7.3

Same name and namespace in other branches
  1. 8 node_revision_delete.drush.inc \drush_node_revision_delete_nrd_delete_prior_revisions()

Callback for nrd-delete-prior-revisions command.

File

./node_revision_delete.drush.inc, line 463

Code

function drush_node_revision_delete_nrd_delete_prior_revisions() {
  $args = func_get_args();
  if (drush_confirm(dt("Additionally, do you want to delete the revision @vid?", array(
    '@vid' => $args[1],
  )))) {
    node_revision_delete($args[1]);
    drush_print(dt('The revision @vid was sucessfully deleted.', array(
      '@vid' => $args[1],
    )));
  }

  // Get a list of revisions to delete.
  $revisions_before = array_keys(_node_revision_delete_get_previous_revisions($args[0], $args[1]));

  // Loop through the list of revisions, then delete them one by one.
  foreach ($revisions_before as $revision) {
    node_revision_delete($revision);
  }

  // Print out success message.
  $singular = 'One revision of node @nid was successfully deleted.';
  $plural = 'Successfully deleted @count revisions of node @nid.';
  $message = _node_revision_delete_drush_plural(count($revisions_before), $singular, $plural, array(
    '@count' => count($revisions_before),
    '@nid' => $args[0],
  ));
  drush_print($message);
}