Posted by Apollo610 on February 13, 2009 at 4:35am
| Project: | Vote Up/Down |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (won't fix) |
Issue Summary
Hi all,
I may be going crazy... but I swore a few weeks ago my vote up/down widget that I'm displaying on my comments was going towards the author's userpoints. Am I making this up, or is this a feature that was working but is no longer?
I'm manually outputting the widget on each comment with <?php print $vote_up_down_widget; ?>, and the votes themselves are being counted are stored properly, but they're not being calculated against the comment author's userpoints.
Thanks in advance for straightening me out -
Comments
#1
Just to add, this is in my template.php (which should be implied, since the voting is working, but I just want to be clear).
if (arg(1) != 'add' && arg(2) != 'edit') {$style = variable_get('vote_up_down_widget_style_node', 0) == 1 ? '_alt' : '';
$vars['vote_up_down_widget'] = theme("vote_up_down_widget$style", $vars['comment']->cid, 'comment');
$vars['vote_up_down_points'] = theme("vote_up_down_points$style", $vars['comment']->cid, 'comment');
}
#2
I haven't researched this thoroughly, but at least for me with Drupal 6.9 and most recent dev version of vote/up down and latest release of userpoints, I had to modify modules/vote_up_down/vote_up_down.module around #530 to look like:
$user_vote = votingapi_select_single_vote_value($criteria);
if ($user->uid && !$user_vote && ($node->uid != $user->uid) && ($vote['value'] != 0)) {
$givepoints = variable_get('userpoints_vote_up_down', 0);
$params = array (
'uid' => $user->uid,
'points' => $givepoints,
);
userpoints_userpointsapi($params);
}
}
I don't like to stay off-topic, but I wanted to award the author of the node with user points, and not the one voting, so I actually have this:
$user_vote = votingapi_select_single_vote_value($criteria);
if ($user->uid && !$user_vote && ($node->uid != $user->uid) && ($vote['value'] != 0)) {
$givepoints = variable_get('userpoints_vote_up_down', 0);
$params = array (
'uid' => $node->uid,
'points' => $givepoints,
'description' => 'You were awared '.$givepoints.' points because someone voted on an node you wrote',
'display' => false,
);
userpoints_userpointsapi($params);
}
}
I'm currently looking into giving the author positive points when his node gets voted up and negative when voted down. My first thought was just going:
$givepoints = $vote['value'] * variable_get('userpoints_vote_up_down', 0);But if a user changes his vote, it doesn't update the userpoints for the author.
#3
@eddanx - much thanks for the feedback... I'm just slightly confused about where you're placing your first block of code... are you placing it inside of the
function vote_up_down_vote($type, $cid, $value, $tag = NULL, $ajax = FALSE, $alt = FALSE)function?I've tried multiple placements and I can't get the aggregation of votes to be counted against the user's userpoints... if you don't mind can you paste the relevant block of code from .module that's working? I'd love to get this up and running on my site.
For what it's worth, your other suggestions (which are by no means off topic to this thread IMO) are fantastic. It would be nice to have all of these options built into Vote Up/Down to make it more robust. Any way you can work with the maintainer (lut4rp) to get them implemented? That would be wonderful.
#4
yes, he is. the code replaces this:
$user_vote = votingapi_select_single_vote_value($criteria);
if ($user->uid && !$user_vote && ($node->uid != $user->uid) && ($vote['value'] != 0))
{
userpoints_userpointsapi('points', variable_get('userpoints_vote_up_down', 0), $user->uid, 'Vote Up/Down points');
}
I'm looking into doing this as well.
#5
Hi,
I would like to give 1 pt to the voter and 1 pt to the commenter (or take off 2 if negative). Is the only way to do this by editing the module directly?
Thanks,
Paul.
#6
Hi all.
vote_up_down userpoints integration does not work, as stated in the comments above. Userpoints are never applied to a user when voting.
This is due to vote_up_down calling userpoints_userpointsapi() with incorrect parameters. It looks like vote_up_down is using an older argument format (perhaps from 5.x). userpoints_userpointsapi() now takes only one parameter, either an array or an integer. If an integer is supplied, that many points are added for the current user, which is what we want. See line 446 in userpoints.module for all the gory details.
The attached patch fixes this, adds a check for errors and adds a watchdog message on failure.
I think the discussion about giving more than one user points probably belongs in a different issue. The initial issue was basically reporting a bug, userpoints functionality doesn't work.
Malc
#7
Subscribing. Any updates? Thanks
#8
Subscribing
#9
malclocke: thanks for the clean update.
I'm not a user points module user, so can anyone confirm the new patch solves the problem?
#10
Since
6.x-1.xis not anymore maintained, I'm closing this.Please re-open if this happens on
6.x-2.x.#11
There is a way to integrate Vote Up/Down with Userpoints? When user vote it must give +1 or -1 to node creator.
I used Userpoints Karma but with this module it's inpossible to vote for annonymous users.
So, maybe I can do that with Vote Up/Down, Userpoints, Rules and Votingpoints (form userpoint_contib).
Any idea how I can do that?
Thanks!
#12
@superfedya: Please do not hijack issues. you want to integrate votingapi with userpoints.