It'd be nice if Plus1 was able to allow other modules to alter the value of the vote source, especially for anonymous users, so that votes from users not logged into Drupal could be counted by a criteria other than IP address.

We often do integrations with Facebook that utilize the Plus1 module, and a common complaint is that users sharing an IP address are unable to vote on the same content.

I suspect combination with Facebook is a common use case (it's mine), and so I have a persons Facebook ID in mind as the vote source, but really anything is possible. If my patch can be committed, I'd like to create a small extension module for integration with FB.

On another train of thought: I believe I may have seen some requests to allow multiple votes and other sorts of shenanigans with plus1, and I could imagine that a contributed module could make use vote_source altering to create a convention for allowing this - i.e. vote_sources might in the database might look like [uid]-vote1, [uid]-vote2, [uid]-vote3, then the module implementing the hook would then stop altering the source after three votes to prevent further voting. I'm not thinking too deeply about this particular scenario, but I'm sure it could have it's uses.

Here's a patch against 7.x-1.x.

A module could use it like this:

/**
 * Implements hook_plus1_source_alter()
 *
 */
function custom_plus1_source_alter(&$source) {
  $source = 'myFacebookID';
}
CommentFileSizeAuthor
plus1-vote_source_alter.patch1.59 KBjustindodge
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

justindodge’s picture

Status: Active » Needs review
rogical’s picture

so this won't effect original functions, right? then I can commit this.

justindodge’s picture

Right - without another module implementing the hook, it'll be like this never happened :)

rogical’s picture

Can you re-roll the patch?

rogical@rogical-laptop:~/Desktop/drupal/plus1$ git apply -v plus1-vote_source_alter.patch
plus1-vote_source_alter.patch:9: trailing whitespace.

plus1-vote_source_alter.patch:12: trailing whitespace.

plus1-vote_source_alter.patch:29: trailing whitespace.

plus1-vote_source_alter.patch:32: trailing whitespace.

plus1-vote_source_alter.patch:40: trailing whitespace.

Checking patch plus1.module...
Applied patch plus1.module cleanly.
warning: squelched 1 whitespace error
warning: 6 lines add whitespace errors.

rogical’s picture

Status: Needs review » Needs work
rogical’s picture

Status: Needs work » Fixed

committed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.