• Main Page
  • Related Pages
  • Modules
  • Classes
  • Files
  • File List
  • File Members

modules/node/views_handler_field_node_revision_link_revert.inc

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     // ensure user has access to edit this node.
00019     $node = $this->get_value($values);
00020     $node->status = 1; // unpublished nodes ignore access control
00021     if (!node_access('update', $node)) {
00022       return;
00023     }
00024 
00025     // Current revision cannot be reverted.
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 }

Generated on Sun Feb 26 2012 12:52:51 for Views by  doxygen 1.7.1