Sometimes known as "karma". In our case, we wanted storylink submitters to get more/less userpoints when someone up/down votes their submissions.

Described in this feature request for 4.7: http://drupal.org/node/101791

The attached patch adds to two functions:

1. vote_up_down_userpoints()

Adds an additional field at admin/settings/userpoints in the vote_up_down fieldset:

      $form['vote_updown_points']['userpoints_vote_up_down_karma'] = array(
        '#type' => 'textfield',
        '#title' => t('Points resulting from vote on a node user authored (requires the Vote up/down module)'),
        '#default_value' => variable_get('userpoints_vote_up_down_karma', 0),
        '#size' => 5,
        '#maxlength' => 5,
      );

2. vote_up_down_vote()

In the userpoints integration section... after giving the voter a userpoint, give the author a userpoint.

      // update userpoints based on the vote value
      if ($vote->value != 0) {
        if ( variable_get('userpoints_vote_up_down_karma', 0) ) {
          userpoints_userpointsapi('points', ($vote->value * variable_get('userpoints_vote_up_down_karma', 0)), $node->uid, 'Vote up/down karma');
        }
      }

Comments

ola90@drupal.ru’s picture

How does this code handle the case when a user first votes "up" and then changes his mind and votes "down"? It looks like author's karma will be reset to 0 while his node will have a negative score.

Greg Go’s picture

ola90, you're absolutely right. Thanks!

I took your code from http://drupal.org/node/101791, added configurable userpoints multipler and rolled another patch.

Anonymous’s picture

OMG, thanks so much for fixing that - was trying to figure this one out but it was making my brain hurt!

fyi - if you enable 'reset vote' it doesn't reset the points, but in my case I'm not going to enable that, just thought you might like to know...

Anonymous’s picture

Status: Needs review » Needs work

Just been wrapping my head around why this wasn't working as I had it working fine before - it's because the userpoints api has changed so now you need to pass an array of values:

http://drupal.org/node/206558

e.g.

$params = array (
'uid' => $node->uid,
'points' => ($vote->value * variable_get('userpoints_vote_up_down_content_rating', 0)),
'description' => 'Vote up/down karma',
);
userpoints_userpointsapi($params);

instead of:

userpoints_userpointsapi('points', ($vote->value * variable_get('userpoints_vote_up_down_content_rating', 0)), $node->uid, 'Vote up/down karma');

...so in other words, these patches don't work at the moment with the latest userpoints

chadchandler’s picture

Any updates on this?

Gekiboy’s picture

Version: 5.x-1.x-dev » 6.x-1.x-dev
Status: Needs work » Needs review
StatusFileSize
new2.31 KB

This, and other code in this module around the userpoints system is broken. As this module uses the votingapi module, all userpoint functionality base on voting should be taken care of by the userpoints_votingapi anyway. I am proposing this patch to remove the traces of userpoints functionality from this module as it is only detrimental at this point.

Gekiboy’s picture

StatusFileSize
new2.79 KB

Recreated the patch using CVS instead of SVN incase that matters

mrwhizkid’s picture

I am trying to follow this thread and I am confused. Is there a way in Drupal 6 to give points to the author when his/her node is voted up? Or the other way around?

ingo86’s picture

Assigned: Unassigned » ingo86

This thing is absolutely out of the range of features of vote up down.
This is just a voting module that interfaces with voting_api. Nothing else.

For what you need, I developed as part of this year google Summer of Code a set of modules that do just what you require. Everything is interfaced with user_karma. If you wanna taka a look go here:
http://drupal.org/project/peerreview

Everything needs work but the code should be good, for your needs you have to enable the user_karma plugin.

ingo86’s picture

Status: Needs review » Closed (works as designed)
DomDoze’s picture

Subscribe to read later