I'm using the thumbs up widget to act as a counter. Authenticated users can "thumbs up" any node once per day until a node reaches a certain threshold.
Unfortunately, by default, the rate module only allows one "thumbs up" per node per user... ever. Per the votingapi documentation, if the second parameter ($criteria) to votingapi_set_votes() is left off, it assumes you want to delete all previous votes for this node+user before counting the current vote.
I modified rate_save_vote() in rate.module to pass an empty array() as the second parameter which allows any user to "thumbs up" as many times as they want.
I believe this should be user configurable, maybe in the widget configuration? If you can provide direction, I'm glad to provide a patch.
Thanks
Comment | File | Size | Author |
---|---|---|---|
#4 | allow_multiple_votes-1224150-1.patch | 719 bytes | rocketeerbkw |
Comments
Comment #1
mauritsl CreditAttribution: mauritsl commentedThe widget configuration is stored in a $widget object. You may add the configuration option to the form in rate_widget_form() (in rate.admin.inc). The call to votingapi_set_votes() is made in rate_save_vote() (rate.module). The $widget object is available in that function.
Comment #2
rocketeerbkw CreditAttribution: rocketeerbkw commentedI noticed there is no 6.x-1.x branch in git, should I work on master, 6.x-2.x or a 7.x branch and do a backport?
Comment #3
mauritsl CreditAttribution: mauritsl commentedThe master branch is used for 6.x-1.x, so please use that version.
Most new features still go in 6.x and get ported to 7.x later. Ignore the 2.x branch for now, it's not coming soon, but will contain a rewrite of the admin interface.
Comment #4
rocketeerbkw CreditAttribution: rocketeerbkw commentedHere's a patch that allows the $criteria variable to modified in hook_rate_vote_alter functions. By default, the functionality is the same as it is right now, authenticated users can only vote once.
This will at least allow me to not hack this module on my production site. I'll work on the UI for this in the widget settings next.
Comment #5
mauritsl CreditAttribution: mauritsl commentedI've committed this to GIT. Thanks!
For reference; the following code can now be used to allow endless voting (on all widgets):
Looking forward to the admin section.
Comment #6
emergencyofstate CreditAttribution: emergencyofstate commentedDesperately need this functionality however I am using the 7.x-1.2 version.
I don't suppose this has made it to 7? If not, could anybody help me with a patch that would work in 7?
Comment #7
mauritsl CreditAttribution: mauritsl commentedThis hook can be implemented in both D6 and D7.
Comment #8
emergencyofstate CreditAttribution: emergencyofstate commentedAh beautiful! So, all I need to do is employ a custom module that utilizes the hook listed above and all widget's can have endless voting?
-edit-
I've created/enabled a module with the hook and don't see any change in behavior. I'm currently using the thumbs up widget as a counter as well. I want to make sure I know how to make multiple votes per node, per user work.
Comment #9
emergencyofstate CreditAttribution: emergencyofstate commentedSo after a few days of scratching my head, I decided to look in rate.module and the patch listed above in #4, Absolutely did not make it into the 7 release.
I added (as per the patch in #4):
$criteria = NULL; //added
and
and now it works.
Comment #10
mauritsl CreditAttribution: mauritsl commentedYou're right. I've now put it in GIT for 7.x-1.x, thanks!
Comment #12
rawkode CreditAttribution: rawkode commentedPatch still doesn't appear to have been commited properly. The following changes still need applied:
- votingapi_set_votes($votes);
+ votingapi_set_votes($votes, $criteria);
Comment #13
rawkode CreditAttribution: rawkode commentedForgot to change the status
Comment #14
mauritsl CreditAttribution: mauritsl commentedIt has been committed finally:
http://drupalcode.org/project/rate.git/commit/3274946
Thanks again for the investigation!
Comment #15
bdone CreditAttribution: bdone commentedA semi-related patch awaits review at #1333172: Show the authenticated user their most recent vote, not their first.
Comment #17
Energyblazar CreditAttribution: Energyblazar commentedIs the patch ready yet ?
Comment #18
Energyblazar CreditAttribution: Energyblazar commentedTo enable multiple votes by authenticated users i just edited the votingapi.module (/sites/all/modules/votingapi/votingapi.module)
From Line 132 to Line 153 added " // " infront of all codes which disables clearing out old votes if they exist and therefore members can cast multiple votes
this is how it looks after i add " // "
Note : This worked with fivestar module not tested and tried on other modules using voting api
Comment #19
lihygaasd CreditAttribution: lihygaasd commentedWorks perfect in rate module for drupal 7 , Thanks !! Energyblazar
Comment #20
kojow7 CreditAttribution: kojow7 commentedIn regards to #18, it does work, but the problem is that someone could just sit there hitting the vote button thousands of times. Is there a way I can do the following:
1) Allow Multiple votes on the same node, but ...
2) Only allow one vote (across the entire site) per 24 hour period.
Comment #21
edison_doulos CreditAttribution: edison_doulos commentedComment #18 works for me too on Drupal 7 and Rate module. Thanks @Energyblazar