2 // $Id: views_handler_field_node_revision_link_revert.inc,v 1.1 2008/09/03 19:21:29 merlinofchaos Exp $
4 * Field handler to present a link to revert a node to a revision
6 class views_handler_field_node_revision_link_revert extends views_handler_field_node_link {
9 $this->additional_fields['uid'] = array('table' => 'node', 'field' => 'uid');
10 $this->additional_fields['node_vid'] = array('table' => 'node', 'field' => 'vid');
11 $this->additional_fields['vid'] = 'vid';
12 $this->additional_fields['format'] = 'format';
16 return user_access('revert revisions') || user_access('administer nodes');
19 function render($values) {
20 // ensure user has access to edit this node.
21 $node = new stdClass();
22 $node->nid = $values->{$this->aliases['nid']};
23 $node->vid = $values->{$this->aliases['vid']};
24 $node->uid = $values->{$this->aliases['uid']};
25 $node->format = $values->{$this->aliases['format']};
26 $node->status = 1; // unpublished nodes ignore access control
27 if (!node_access('update', $node)) {
31 // Current revision cannot be reverted.
32 if ($node->vid == $values->{$this->aliases['node_vid']}) {
36 $text = !empty($this->options['text']) ? $this->options['text'] : t('revert');
37 return l($text, "node/$node->nid/revisions/$node->vid/revert", array('query' => drupal_get_destination()));