You are here

function pm_handler_field_operation::render in Drupal PM (Project Management) 7

Same name and namespace in other branches
  1. 8 includes/views/pm_handler_field_operation.inc \pm_handler_field_operation::render()
  2. 7.3 includes/views/pm_handler_field_operation.inc \pm_handler_field_operation::render()
  3. 7.2 includes/views/pm_handler_field_operation.inc \pm_handler_field_operation::render()

Renders field to show icon.

Overrides views_handler_field_node_link::render

File

./pm_handler_field_operation.inc, line 46
Field handler to present a link node edit.

Class

pm_handler_field_operation
@file Field handler to present a link node edit.

Code

function render($values) {

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

  // unpublished nodes ignore access control
  if ($this->options['display_icons']) {
    $value = "";
    $value .= pm_icon_edit_node($node, $_GET);
    if (!empty($value)) {
      $value .= ' ';
    }
    $value .= pm_icon_delete_node($node, $_GET);
    return $value;
  }
  else {
    $value = "";
    if (drupal_valid_path('node/' . $node->nid . 'edit')) {
      $value .= l(t('edit'), "node/{$node->nid}/edit", array(
        'query' => drupal_get_destination(),
      ));
    }
    if (!empty($value)) {
      $value .= ' | ';
    }
    if (drupal_valid_path('node/' . $node->nid . 'delete')) {
      $value .= l(t('delete'), "node/{$node->nid}/delete", array(
        'query' => drupal_get_destination(),
      ));
    }
    return $value;
  }
}