Hi,

When you add this filter to a view, it says "This allows you to filter by whether or not the logged in user has voted on the node."

But it only gives you this option "voted on by"+"currently logged in user"

Great module.

Comments

diegogers’s picture

And it also gives me this error when using the above filter.

user warning: Unknown column 'votingapi_vote.uid' in 'where clause' query: SELECT node.nid FROM node node WHERE (node.type IN ('foto')) AND (node.status = '1') AND (votingapi_vote.uid = 0) LIMIT 0, 1 in /home/.malcsi/banzai_bd/ultraviolentos.com.ar/includes/database.mysql.inc on line 172.

bpirkle’s picture

I'm also seeing an issue with this.

Using Fivestar 5.x-1.3.

I have a set of nodes (images, in my case) on which users can vote. That works fine.

I have a view that displays these nodes, along with the average vote. That works fine.

I'd like users to be able to filter the view based on:
1) current user has voted for the node
2) current user has not voted for the node
3) all nodes
It looks like only #1 and #3 are supported, but maybe I'm reading it wrong. In any case, that'd be a start. So I added an exposed filter, but it doesn't do any good. The filter controls are shown to the user, and the user can select between "All" and "Currently Logged In User". But they see exactly the same set of node (all) regardless of how they try to filter.

Details:
the corresponding line in "Filters" section of the view shows:
Field: "Fivestar: Current user has voted"
Operator: "voted on by" (that's the only choice in the drop-down)
Value: "Currently Logged In User" (that's the only choice in the drop-down)

the corresponding line in "Exposed Filters" section of the view shows:
Field: "Fivestar: Current user has voted"
Label: "Voted"
Optional: checked (all other boxes unchecked)

Thanks!

bpirkle’s picture

Hmmm, I'm still a Drupal newbie, so I may be way off. But it looks like the votingapi_vote table is not joined into the query. I'm guessing it should join in on the content_id field.

bpirkle’s picture

Here's what I did to fix the filter. In the file fivestar_views.inc, find the function:

fivestar_views_handler_filter_uid_has_voted

Now change the body to this:

$query->add_table($filterinfo['table']);
$query->add_where("fivestar_votes.uid = %d", $filter['value']);

Adding my desired "current user has not voted on" functionality looks a bit trickier, but I'll look into it to see if I can figure out a way.

bpirkle’s picture

I've come up with an initial implementation of "not voted on by". Warning: I'm a Drupal newbie. This code may be buggy, inefficient, or otherwise a terrible idea.

In the fivestar_views.inc file, change the line containing "voted on by" to:

'operator' => array('=' => "voted on by", '!=' => "not voted on by"),

In this same file, change the body of the fivestar_views_handler_filter_uid_has_voted function to this:

$query->add_table($filterinfo['table']);
$operator = $filter['operator'];
if ($operator == '=') {
$query->add_where("fivestar_votes.uid = %d", $filter['value']);
}
else {
$query->set_distinct();
$query->add_where("node.nid NOT IN (SELECT content_id FROM votingapi_vote WHERE uid = %d)", $filter['value']);
}

I've only tested with with five nodes and three users, and it may suffer from a variety of problems. I post it here more to stimulate discussion than for use as-is.

quicksketch’s picture

Project: Fivestar » Voting API
Version: 5.x-1.3 » 5.x-1.x-dev
Category: bug » feature

All views integration is now handled by the VotingAPI, so I'm moving over there. Not sure if this feature has yet been implemented.

eaton’s picture

Status: Active » Closed (won't fix)

Views integration in VotingAPI 5.x is fundamentally broken -- it works for a small number of cases but more complex cases like this are not supported, and this isn't being developed further. Views support was rewriten in the 2.x branch to fix these issues. If anyone wants to take a stab at rewriting the Views integration for D5, they're welcome to, but it's not on my radar at present.