views_handler_field_node_revision_link_delete.inc

  1. 3.x modules/node/views_handler_field_node_revision_link_delete.inc
  2. 2.x modules/node/views_handler_field_node_revision_link_delete.inc

Definition of views_handler_field_node_revision_link_delete.

File

modules/node/views_handler_field_node_revision_link_delete.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Definition of views_handler_field_node_revision_link_delete.
  5. */
  6. /**
  7. * Field handler to present link to delete a node revision.
  8. *
  9. * @ingroup views_field_handlers
  10. */
  11. class views_handler_field_node_revision_link_delete extends views_handler_field_node_revision_link {
  12. function access() {
  13. return user_access('delete revisions') || user_access('administer nodes');
  14. }
  15. function render_link($data, $values) {
  16. list($node, $vid) = $this->get_revision_entity($values, 'delete');
  17. if (!isset($vid)) {
  18. return;
  19. }
  20. // Current revision cannot be deleted.
  21. if ($node->vid == $vid) {
  22. return;
  23. }
  24. $this->options['alter']['make_link'] = TRUE;
  25. $this->options['alter']['path'] = 'node/' . $node->nid . "/revisions/$vid/delete";
  26. $this->options['alter']['query'] = drupal_get_destination();
  27. return !empty($this->options['text']) ? $this->options['text'] : t('delete');
  28. }
  29. }