You are here

function vud_comment_handler_field_widget::render in Vote Up/Down 7

Same name and namespace in other branches
  1. 6.3 vud_comment/views/vud_comment_handler_field_widget.inc \vud_comment_handler_field_widget::render()
  2. 6.2 vud_comment/views/vud_comment_handler_field_widget.inc \vud_comment_handler_field_widget::render()

Render the field.

Parameters

array $values: The values retrieved from the database.

Overrides views_handler_field::render

File

vud_comment/views/vud_comment_handler_field_widget.inc, line 28
Provide a handler for Vote Up/down widget field for comments.

Class

vud_comment_handler_field_widget
A handler that provides a Vote Up/Down widget field for comments.

Code

function render($values) {
  $widget = '';
  $query = 'SELECT n.type FROM {comment} c LEFT JOIN {node} n ON c.nid = n.nid WHERE c.cid = :cid';
  $type = db_query($query, array(
    ':cid' => $values->cid,
  ))
    ->fetchField();
  $comment_allow = in_array($type, variable_get('vud_comment_node_types', array()), TRUE);
  $can_edit = user_access('use vote up/down on comments');
  if ($comment_allow && ($can_edit || user_access('view vote up/down count on comments'))) {
    $tag = variable_get('vud_tag', 'vote');
    $widget_theme = variable_get('vud_comment_widget', 'plain');
    $variables = array(
      'entity_id' => $values->cid,
      'type' => 'comment',
      'tag' => $tag,
      'widget_theme' => $widget_theme,
      'readonly' => !$can_edit,
    );
    $widget = theme('vud_widget', $variables);
  }
  return $widget;
}