Is anonymous voting possible
PGiro - November 17, 2008 - 22:53
| Project: | Extra Voting Forms |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | PGiro |
| Status: | active |
Description
Hi merc,
Currently, EVF doesn't allow anonymous voting. The vote_up_down module offers a voting mechanism that can be used in place of EVF (I've done it on a site). However, I would rather stay with EVF.
I looked at vote_up_down's method of handling anonymous voters and would like to know if you think it would be compatible with EVF+UK. Basically, it boils down to faking a user ID if there is no logged-in user, in the following way
// Fake uid for anonymous users.
// If the IP is valid turn it into a integer and add the number of the current day.
// The current day is what limit anonymous voting to one vote per day and IP address.
$hostname = (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : ip_address();
if ($long = ip2long($hostname)) {
$uid = abs($long) + date('z');
}If doing something like does not break the way things work in EVF & UK, I'll be glad to submit a 6.x patch

#1
Hi,
I would much rather not allow EVF to have anonymous voting. Just WAY to much can go wrong with it.
A patch that allows anonymous voting should be _extremely_ well thought-out, and tested by the community.
I don't think faking a user-id is the way to go though.
Marking this as won't fix. But, if you feel courageous,
* Look into the 5star code and see what they do
* Hint: the new VotingPI should make anonymous voting easier
* Submit a patch, making sure that there is a parameter to enable this
* Let's get a few people to test it
I don't mean to be difficult, but this might turn very ugly if we are not careful. I am personally against this feature, but I will definitely commit a well done patch.
Bye,
Merc.
#2
Ok, will submit a patch after I get drigg_external up. I have it working on my test site.
I have implemented it as in vote_up_down which seems to be failry used so I guess it's ok...
If I have more time, I'll look into votingapi
#3
Hi,
OK, leaving this issue open for a while.
Merc.
#4
Here is my patch to evf.module.
It works for me, it's based on the anonymous voting of project vote_up_down
It could be made to work with votingAPI's new handling of anonymous voters although I'm not sure how to do it, don't have the time to do it just now and maybe the query in extra_voting_forms_too_many_votes_total() will be an issue
I now Jordan was waiting for it so here it is.
#5
For some reason, I can't apply the patch, can you upload a tarball for the patched evf mod?
#6
Merc, could you roll the patch into a SNAPSHOT version ?
#7
Hi,
My apologies, I don't have time to chase this one up...
However, this one looks a little scary:
"It could be made to work with votingAPI's new handling of anonymous voters although I'm not sure how to do it, don't have the time to do it just now and maybe the query in extra_voting_forms_too_many_votes_total() will be an issue"
...is this really ready to be rolled...?!?
Merc.
#8
it is if you trust the way vote_up_down module has been doing it for months/years
#9
Hi,
Hasn't vote_up_down been discontinued?
I reallyy trust the way 5star does it, since it's written by core Drupal developers...
Merc.
#10
ok, I'll look at fivestar and do it their way
#11
Hi,
Thank you!!!
That would be awesome.
Merc.
#12
Yeah.. I've got it coded but I have an issue where votes are disappearing on the site that's currently using (Recipe blogs). I'm 99% sure it's not related to my changes and rather a votingapi/feedapi module mishap.
I will provide the (small) patch to EVF (and UK if I remember correctly) as soon as it works
#13
Hi,
Looking forward to it!
Merc.
#14
Hi, I made some change based on PGiro's patch to remove the dependence on vote_up_down module.
Just drop the new patch, and set extra_voting_forms_anonymous_url to anonymous_vote, you are ready to go!
#15
#16
Has this been reviewed?
#17
I've applied this, and it spew error at me at first
I changed
'#default_value' => variable_get('extra_voting_forms_anonymous_url', ''),
to
'#default_value' => variable_get('extra_voting_forms_anonymous_url', 'anonymous_vote'),
then it worked. anonymous users can vote at least once. still testing though...
#18
Hi,
I reviewed this patch, and it actually seems to make a lot of sense...
Has anybody else reviewed it/tested it thoroughly? Do you think it's actually good to go?
Bye,
Merc.
#19
Hi,
Sorry people, I am not really happy with the current patches.
I want to do something that is in line with VotingAPI's way of doing things, rather than "masking" the UID with the IP address.
I opened an issue in VotingAPI: #482780: How to enable anonymous voting in my module
Let's see if we get any help. If somebody contributes a patch that really works with VotingAPI, I will most welcome it.
Merc.
#20
#21
Merc, I have done it the voting api way but I haven't done a patch. How about I just send you the code ? It requires changes in evb AND karma.
You sent me an email but my reply bounced so please write me again with the right address.
#22
Hi,
The address is right. My server was down for 3 days (!).
User Karma _really_ should be untouched by this -- karma is never calculated for anonymous users anyway.
Ah I see your point. I guess if you are not careful Karma might end up assigned to IP address?
Anyhow, from my understanding the "votingAPI way" is to basically have 0 in the uid that gives/receives the vote, but then making sure you reset the votes based on the IP address. Please have a look here:
http://drupal.org/node/482780
Bye,
Merc
#23
email resent and files attached
#24
Hi,
I looked at the code you sent me by email, and no, I am afraid that's not the "VotingAPI" way of doing it.
Please attach things to the issue queue rather than emailing... so that everything is logged properly.
Please keep in mind that getting whole modules files by email and diffing figuring things out is time consuming and I can't rally do it...
The link above in #22 is handy to get what the "right way" of doing this is.
Bye,
Merc.
#25
Merc, that is the right way to do it and I have taken into account the vote deleting issue since I was bitten by the bug.
It would be better that you be more cooperative if you want contributions; I find "That's not how you do it" too short an answer for my liking. Especially since I am the one lacking time right now with a four month old baby to take care of; if getting the full files from a working site and diffing them is too much for you then so be it. And unfortunately full files .module cannot be attached.
#26
Hi,
We are all busy, and we are all trying to save time. Keep in mind that for this very reason most module developers will ignore emails will full .module files to diff.
I don't think putting full IP addresses in the uid field is the way to do it. Fivestar, which is comaintained by eaton (who wrote the voring API), doesn't do it that way.
Whatever code goes in the module will have to be maintained by me and whichever mistake a patch includes will eventually bite me -- hard -- in terms of time etc.
I will accept patches that keep the UID as 0 (therefore not influencing Karma).
I will try to work on it myself as time permits...
Merc.
#27
I'm using the patch from #14
The bug I encounter is connected somehow to user avatars. If I enable user avatars and anonymous voting, I recieve following error while trying to view "who voted" tab with anonymous entries:
* warning: array_fill() [function.array-fill]: Number of elements must be positive in /home/infuzor/www/publica.by/includes/database.inc on line 241.* warning: implode() [function.implode]: Invalid arguments passed in /home/infuzor/www/publica.by/includes/database.inc on line 241.
* warning: array_keys() [function.array-keys]: The first argument should be an array in /home/infuzor/www/publica.by/modules/user/user.module on line 502.
* user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1 query: SELECT p.perm FROM role r INNER JOIN permission p ON p.rid = r.rid WHERE r.rid IN () in /home/infuzor/www/publica.by/modules/user/user.module on line 502.
I should note, that the anonimous user default avatar is shown ok for scoop lists and scoop nodes, but not in "who voted" list. I'm using default drigg_theme
Similar errors happen when viewing /karma_users page
I'd really like to try the PGiro patch... Also, in some other thread you wanted to write a tutorial for user_karma-free voting for drigg. That would be nice to have as a last resort
Anonymous voting is good for low-traffic drigg-clones, it makes much more sense then Autovoting, and I'd be happy to see this feature finally implemented
#28
Hi,
That's precisely why I didn't accept the patch.
If feels wrong. ALL other modules assume a user ID in the UID field (surprise surprise!) and they are getting an IP address. Avatars go bananas, karma goes bananas... if I had committed it, people would have had anonymous votes based on the IP address and it would have been a disaster to go back.
Bye,
Merc.
#29
My second attempt doesn't pass the ip in the uid, it passes it in the vote source
#30
Please post it, I'd test and review it