You are here

class vud_comment_handler_field_widget in Vote Up/Down 6.3

Same name and namespace in other branches
  1. 6.2 vud_comment/views/vud_comment_handler_field_widget.inc \vud_comment_handler_field_widget
  2. 7 vud_comment/views/vud_comment_handler_field_widget.inc \vud_comment_handler_field_widget

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

Hierarchy

Expanded class hierarchy of vud_comment_handler_field_widget

1 string reference to 'vud_comment_handler_field_widget'
vud_comment_views_data_alter in vud_comment/views/vud_comment.views.inc
Implementation of hook_views_data_alter().

File

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

View source
class vud_comment_handler_field_widget extends views_handler_field {
  function init(&$view, &$options) {
    parent::init($view, $options);
    $this->additional_fields['cid'] = array(
      'table' => 'comments',
      'field' => 'cid',
    );
  }
  function query() {

    // Not calling parent method on purpose.
    $this
      ->add_additional_fields();
  }
  function option_definition() {
    $options = parent::option_definition();
    return $options;
  }
  function options_form(&$form, &$form_state) {
    parent::options_form($form, $form_state);

    // It doesn't make sense to have the ability to alter the output.
    $form['alter']['#access'] = FALSE;
  }
  function render($values) {
    $widget = '';
    $cid = $values->{$this->aliases['cid']};
    $query = 'SELECT n.type FROM {comments} c LEFT JOIN {node} n ON c.nid = n.nid WHERE c.cid = %d';
    $type = db_result(db_query($query, $cid));
    $comment_allow = in_array($type, variable_get('vud_comment_node_types', array()), TRUE);
    if ($comment_allow && user_access('use vote up/down on comments')) {
      $tag = variable_get('vud_tag', 'vote');
      $widget_type = variable_get('vud_comment_widget', 'plain');
      $widget = theme('vud_widget', $cid, 'comment', $tag, $widget_type);
    }
    return $widget;
  }

}

Members