diff --git a/advpoll.module b/advpoll.module index 80fb369..f51553f 100644 --- a/advpoll.module +++ b/advpoll.module @@ -1706,3 +1691,17 @@ function advpoll_views_api() { 'path' => drupal_get_path('module', 'advpoll') .'/views', ); } + + +/** + * Implementation of hook_votingapi_relationships(). + */ +function advpoll_votingapi_relationships() { + $relationships[] = array( + 'description' => t('Advanced Poll'), + 'content_type' => 'advpoll', + 'base_table' => 'node', + 'content_id_column' => 'nid', + ); + return $relationships; +} diff --git a/all/modules/advpoll/modes/binary.inc b/all/modules/advpoll/modes/binary.inc index 46d253f..199ed6d 100644 --- a/modes/binary.inc +++ b/modes/binary.inc @@ -348,3 +347,21 @@ function advpoll_cancel_binary($node, $user_vote) { } } } + + +function advpoll_votingapi_views_formatters($field = array()) { + if ($field->field == 'value') { + return array( + 'advpoll_binary_views_tags_formatter' => t('Advpoll Binary: choice label'), + ); + } +} + +// Display the name of the candidate, not the value of the vote +function advpoll_binary_views_tags_formatter($value, $field, $columns) { + $node_type = isset($columns->node_type) ? $columns->node_type : db_result(db_query("SELECT type FROM {node} WHERE nid = %d", $columns->nid)); + $result = ""; + if ($node_type == 'advpoll_binary') + $result = db_result(db_query("SELECT label FROM {advpoll_choices} WHERE nid = %d AND cid = %d", $columns->nid, $columns->votingapi_vote_node_tag)); + return $result; +} \ No newline at end of file