Please port this module to Drupal 5 please

CommentFileSizeAuthor
#5 plus1.tar_.gz10.23 KBbjacob

Comments

EgonO’s picture

+1

bjacob’s picture

I would also love to see it working on Drupal 5. How can we make it happen?

Chill35’s picture

I would also love to see it working on Drupal 5. How can we make it happen?

I would gladly do it for a small bounty, or I will do it, maybe, in October when I have more time.

Alternatively, you can give it a shot and submit a patch. Make sure to work on the second branch, which is in beta now but pretty much finalized.

bjacob’s picture

I've started backporting the module. So far I think it's not that difficult. But in plus1_get_votes() you're calling votingapi_select_votes(). This function is not available in voting.module for D5. It's only in the new version for D6. I'll see what we can do. If I can't solve the problem by myself it would be great if you could support me. You said "I would gladly do it for a small bounty". How does this "small bounty" look like ;) Maybe you can write me a short message so I can discuss it with my boss.

bjacob’s picture

Version: 6.x-2.2 » 6.x-1.3
Status: Needs review » Active
StatusFileSize
new10.23 KB

HI there,

I've found a solution to use plus1 with Drupal 5 and voting API for Drupal 5. The only problem is the JavaScript is not working as expected. I've added an extra line to the JavaScript. The alert doesn't come up. As far as I can see the code within getJSON() is not called. Therefore the vote is not refreshed. I need to refresh the page manually.

jQuery.getJSON(jQuery(this).attr('href'), function(json){
  alert("ajax said: " + json.score);
  plus1_widget.find('.'+ Drupal.settings.plus1.score_class).hide().fadeIn('slow').html(json.score);
  plus1_widget.find('.'+ Drupal.settings.plus1.message_class).html(json.voted);
});

So what can I do in order to make it work with D5? Do I need to update jQuery? Right now I'm using 1.1.2 with jquery update module. Thanks for any help.

EDIT: Maybe it's better to include what I've done so far. Perhaps not the JavaScript but the module call to JSON is not working. I don't know how to test it... And sorry for not sending a patch but a tar.gz.

EDIT: Okay, I've found the problem and now it's working. Anonymous voting is also possible (this is handled by voting API). Furthermore I had to change the naming of the permissions. Fivestars is using the same wording. Therefore I was not able to assign the appropriate rights. At https://www.ajaxpartner.de/startup/bendecho you can find a working version as example (every startup content type can be rated).

bjacob’s picture

Version: 6.x-1.3 » 6.x-2.2
Status: Active » Needs review

Changing the status so you can test what I've done. I've also integrated the latest changes of version 6.x-2.2.

dorien’s picture

Version: 6.x-1.3 » 6.x-2.2
Status: Active » Needs review

I'll start testing on this as well

Chill35’s picture

Thank you for the work on this.

I will test it too.

patchak’s picture

Cool! This seems like a great module, testing as well, thanks!
Patchak

dorien’s picture

Works good on my 5.10 site! Thanks!
Note: you need to use the jquery update module though. This might be added as a requirement?

Chill35’s picture

Status: Needs review » Needs work

This module should definitely work without having to install the jquery update module.

bjacob’s picture

Thanks for testing. Dorien, why do we need jquery update module? Is there any special function we're using which requires the update? I thought the update is only updating jquery from version 1.1 (which comes with Drupal 5.x) to the recent version (if installing jquery_update 5.2.x). I didn't change the JavaScript, did I? I'll have a closer look...

Edit: I've checked the JavaScript file. I didn't change it. I can't tell whether we need jquery_update or not. I've installed it anyway.

Chill35’s picture

Drupal 5 out of the box runs with jQuery 1.0.4. Was jQuery.getJSON() added afterwards ?

bjacob’s picture

I've found a problem. I've activated anonymous voting. Maybe I'm wrong but I think the voting API 5.x is not able to handle anonymous voting. An anonymous vote is only possible if the following query returns a value other than 0.

function plus1_get_votes($type, $nid, $uid) {
  $results = votingapi_get_user_votes($type, $nid, $uid);
  return count($results);
}

The uid of an anonymous user is 0. If someone anonymous voted on the node the query will return 1 and other anonymous users aren't able to vote. So we have to query the hostname and check it as well. I'll try and let you know how it works.

Edit: Right now it's to complex for me and I don't need anonymous votes. Maybe someone else wants to do it. And I've found another problem with anonymous votes. Google will follow this link and vote content. I had nearly 40 votes executed by Google (hostname was something like 66.249.71.161).

Chill35’s picture

Edit: Right now it's to complex for me and I don't need anonymous votes.

I would not worry about that. Most people prefer people to sign up to vote on content. Anonymous voting is far from an essential feature.
And yeah google spiders and spam bots would vote. Not worth it.

Firetracker’s picture

Hi,

Will there be an official Drupal 5 release for this?

This is the perfect voting module!

Cheers
Zap

bjacob’s picture

Hi there,

some days ago I've updated to D5.20. From time to time I'm porting the recent dev status of plus1 to D5. This morning I realized my port of plus1 is not running on D5.20. I've checked the release notes and everything but can't explain why it's not working. Any ideas of you guys? Every time you click the vote link an access denied entry is added to the log file.

Thanks.

nancydru’s picture

Status: Needs work » Closed (won't fix)

If someone can provide a fully working D5 version, I will consider creating a branch for it. Otherwise, I am disinclined to spend time on this.