views_handler_field_node_link_delete.inc

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

File

modules/node/views_handler_field_node_link_delete.inc
View source
  1. <?php
  2. /**
  3. * Field handler to present a link to delete a node.
  4. */
  5. class views_handler_field_node_link_delete extends views_handler_field_node_link {
  6. function construct() {
  7. parent::construct();
  8. $this->additional_fields['type'] = 'type';
  9. $this->additional_fields['uid'] = 'uid';
  10. $this->additional_fields['format'] = array('table' => 'node_revisions', 'field' => 'format');
  11. }
  12. function render($values) {
  13. // ensure user has access to edit this node.
  14. $node = new stdClass();
  15. $node->nid = $values->{$this->aliases['nid']};
  16. $node->uid = $values->{$this->aliases['uid']};
  17. $node->type = $values->{$this->aliases['type']};
  18. $node->format = $values->{$this->aliases['format']};
  19. $node->status = 1; // unpublished nodes ignore access control
  20. if (!node_access('delete', $node)) {
  21. return;
  22. }
  23. $text = !empty($this->options['text']) ? $this->options['text'] : t('delete');
  24. return l($text, "node/$node->nid/delete", array('query' => drupal_get_destination()));
  25. }
  26. }