00001 <?php
00007 class views_handler_field_node_revision_link_revert extends views_handler_field_node_link {
00008 function construct() {
00009 parent::construct();
00010 $this->additional_fields['node_vid'] = array('table' => 'node', 'field' => 'vid');
00011 }
00012
00013 function access() {
00014 return user_access('revert revisions') || user_access('administer nodes');
00015 }
00016
00017 function render_link($data, $values) {
00018
00019 $node = $this->get_value($values);
00020 $node->status = 1;
00021 if (!node_access('update', $node)) {
00022 return;
00023 }
00024
00025
00026 if ($node->vid == $this->get_value($values, 'node_vid')) {
00027 return;
00028 }
00029
00030 $text = !empty($this->options['text']) ? $this->options['text'] : t('revert');
00031
00032 $this->options['alter']['make_link'] = TRUE;
00033 $this->options['alter']['path'] = "node/$node->nid/revisions/$node->vid/revert";
00034 $this->options['alter']['query'] = drupal_get_destination();
00035
00036 return $text;
00037 }
00038 }