1 views_handler_field_comment_link_approve.inc views_handler_field_comment_link_approve::render_link($data, $values)

Overrides views_handler_field_comment_link::render_link

File

core/modules/comment/views/views_handler_field_comment_link_approve.inc, line 19
Definition of views_handler_field_comment_link_approve.

Class

views_handler_field_comment_link_approve
Field handler to present a link to approve a comment.

Code

function render_link($data, $values) {
  $status = $this->get_value($values, 'status');

  // Don't show an approve link on published nodes.
  if ($status == COMMENT_PUBLISHED) {
    return;
  }

  $text = !empty($this->options['text']) ? $this->options['text'] : t('approve');
  $cid = $this->get_value($values, 'cid');

  $this->options['alter']['make_link'] = TRUE;
  $this->options['alter']['path'] = "comment/" . $cid . "/approve";
  $this->options['alter']['query'] = backdrop_get_destination() + array('token' => backdrop_get_token("comment/$cid/approve"));

  return $text;
}