You are here

function fasttoggle_views_handler_field_node_link::render in Fasttoggle 6

File

views/fasttoggle_views_handler_field_node_link.inc, line 35
The field node link views handler for fasttoggle.

Class

fasttoggle_views_handler_field_node_link
@file The field node link views handler for fasttoggle.

Code

function render($values) {

  // ensure user has access to edit this node.
  $node = new stdClass();
  foreach (array(
    'nid',
    'uid',
    'type',
    'format',
  ) as $key) {
    $node->{$key} = $values->{$this->aliases[$key]};
  }

  // node_access() ignores access control for unpublished nodes. Since
  // this is a faked node object anyway, we can set status to 1 safely.
  $node->status = 1;
  if (!node_access('update', $node)) {
    return '';
  }

  // Now we set the status to the actual value so that we get the
  // correct labels.
  $node->status = $values->{$this->aliases['status']};
  $options = fasttoggle_get_options('node', $node);
  $key = $this->fasttoggle_key;
  if (!empty($options['status'][$key])) {
    $node->{$key} = $values->{$this->aliases[$key]};
    return fasttoggle($options['status'][$key]['label'][intval($node->{$key})], 'node/' . $node->nid . '/toggle/status/' . $key, FASTTOGGLE_FORMAT_HTML, 'status_' . $key . '_' . $node->nid, 'fasttoggle-status-node-status-' . $key . '-' . intval($node->{$key}));
  }
}