Does Voting API have rules integration?

CommentFileSizeAuthor
#8 votingapi.rules_.txt883 bytesapaderno
#5 votingapi.rules_.zip461 bytesPGiro
#2 patch.diff3.01 KBPGiro
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

PGiro’s picture

Any news on this ? Has anyone done a votingapi integration of rules ?

PGiro’s picture

FileSize
3.01 KB

I've done a partial integration of votingapi with rules. It works enough for me to use it with the activity_log module. Here is the patch against rc2.
Included

  • "vote" content type for rules
  • tokens for the fields of the first element of the vote array
  • implementation of hook_votingapi_insert() to call the rules engine

Not done : update/delete of votes

Can I get some feedback and some indication from the maintainer as to how this could be merged into the D6 branch ?

PGiro’s picture

Status: Active » Needs review

Forgot to change the status

fago’s picture

Category: support » task
Status: Needs review » Needs work

I think your patch is missing the .rules.inc file.

PGiro’s picture

FileSize
461 bytes

Sorry about that. I've attached it directly to this reply

andypost’s picture

+1

mitchell’s picture

Title: Rules Integration? » Rules Integration with Voting API
Project: Voting API » Rules
Version: 6.x-2.x-dev » 6.x-1.x-dev
Component: Code » Provided module integration

This issue will likely be better served spending some time in the Rules issue queue.

apaderno’s picture

FileSize
883 bytes

The file attached to #5 uses the function prefix inconsistently; first it uses vote_, and then it uses votingapi_.

The attached file must be renamed votingapi.rules.inc.

apaderno’s picture

Status: Needs work » Needs review
apaderno’s picture

I don't understand why the issue is in the Rules issue queue; it should rather be in the Voting API queue.

mitchell’s picture

Title: Integration with Rules » Rules Integration with Voting API
Project: Voting API » Rules
Version: 6.x-2.x-dev » 6.x-1.x-dev
Component: Code » Provided module integration
Status: Needs work » Needs review
Issue tags: -rules integration

@Kiam: I agree it should be in the Voting API queue, however

It seems right that this issue should belong to the Rules developers, for now.

apaderno’s picture

+1 for the integration with Voting API.

fago’s picture

Status: Needs review » Needs work

Have a look at http://drupal.org/node/298639. You should set 'uses_input_form' to FALSE or add the default input form method to your class. If you keep your class empty, remove it and use just the usual class.

@token: I think you should use $type = 'all' when listing, not when generating values.

This should move back to votings api at least once it is ready, so it gets included there.

mitchell’s picture

Project: Rules » Voting API
Version: 6.x-1.x-dev » 6.x-2.x-dev
Component: Provided module integration » Code
Issue tags: +rules integration

Moving back to Voting API issue queue and tagging with taxonomy term 'rules integration.'

Other modules in the process of integrating with Rules can be found here: http://drupal.org/project/issues-term/750

patchak’s picture

Any news on this, are we able to replicate the voting actions module using rules??

thanks a lot!

RoboPhred’s picture

+1

mitchell’s picture

Marked #79266: Actions Integration as a duplicate of this issue, and marked #229869: Voting Actions: 6.x Port as won't fix.

As far as I can tell of what remains for this patch:

  • fago made two recommendations in #13
  • we need to add actions to update/delete votes.

Can I get... ...some indication from the maintainer as to how this could be merged into the D6 branch?

Let's cross that bridge when we get there. Eaton is very busy, but if we get patch to RTBC, several people can commit it.

kirkcaraway’s picture

subscribing

PGiro’s picture

can someone else take care of this ? I've moved on to something different and do not require making the recommended changes where I used this

bacchus101’s picture

subscribing

patchak’s picture

There is the Flag module that would allow you to build a Digg-like! Maybe something to look at for people that don't need Voting API specifically....

http://drupal.org/node/319491

I would still love to see Voting API integrated in rules module so that way we could build more advanced digg-like systems...

Patchak

lelizondo’s picture

+1 subscribing

apaderno’s picture

Title: Rules Integration with Voting API » Integration with Rules
Flying Drupalist’s picture

Title: Rules Integration with Voting API » Integration with Rules
Project: Rules » Voting API
Version: 6.x-1.x-dev » 6.x-2.x-dev
Component: Provided module integration » Code
Status: Needs review » Needs work
Issue tags: +rules integration

Does the patch in #8 still work with the latest 2.x? What about 2.0 RC-2 (which I'm using)?

andypost’s picture

This should be reworked into votingapi.rules.inc but where to put hooks for insert and delete votes?

patchak’s picture

Too bad we had a nice module voting actions that is abandonned... It's just impossible to have content promoted to the front page now in d6 expect using the flag module which does not seem ideal. :(

Hopefully I can find some funds to actually sponsor this as it seems badly needed!

kirkcaraway’s picture

I agree. I'll pitch in some funds to the effort. Anyone else?

patchak’s picture

@kirkcaraway : great, glad to hear it. Now we just need someone with the ability and the time to actually do a proper, working solution! Anyone in this thread interested in making an offer to finish this patch and make it work perfectly for d6??

Patchak

nsputnik’s picture

subscribing

davidseth’s picture

I am working on a project right now that needs Rules integration with VotingAPI.

Currently I am reviewing the patch and updating it so it works as expected.

Can anyone intersted in this patch offer some Use Cases? I am only added the event "User added a vote', but of course others are possible.

I will keep this thread up to date with my status.

Cheers,

David

Ron Williams’s picture

David a good use case would be "votes exceed #" and even better to make many modules have the same functions as digg is "votes exceed # within X period"

Richard Blackborder’s picture

My use case brainstorm:

Events

  • Vote added by user
  • Vote deleted by user
  • Vote changed by user

Conditions

  • Number of votes exceeds X
  • Average vote score is above X
  • Specific user has voted (with optional settings for what score that user gave)

Actions

  • Add vote by user (with an option whether to override an existing vote)
  • Remove vote by user

All that would be applicable to voting on anything, not just nodes.

SocialNicheGuru’s picture

subscribing

markspall’s picture

I'm interested in this but only as a way of notifying a user that thier content has been voted on. I wandered onto this thread because I couldn't see how notifications hooks up with voting.

Maybe someone can point me back to a notifications/voting api solution.

If rules/voting api is my best solution then I could well be interested in chipping in to get this working.

All the best,

Mark.

LeDucDuBleuet’s picture

Hello all!

The answer to the original question is YES!

I was looking for a way to announce a vote in the heartbeat module and I found out that the userpoint contrib module "votingpoints" available at http://drupal.org/project/userpoints_contrib was implementing an integration of voting to the rules as you can see:

votingpoints:
Adds a "rules" event for the votingapi "when user votes", and points are awarded accordingly.

I haven't look at the code yet but I can assure you it does the job!

Hope this helps!

LDdB

schvili’s picture

David, how does the development go?

Just let me know if you need any more use case.

hankp98072-’s picture

FYI we figured out how to emulate voting actions in v6.x here - http://drupal.org/node/592866

thekayra’s picture

@LDdB

Thanks for info mate. Was just looking for something similar. Going to give it a try straight away.

thekayra’s picture

http://drupal.org/project/userpoints_contrib generally works alright.

Unfortunately I coul not find an easy way of using the value of the vote. (Many tokens are available but non of them are related to the value.)

I will give a try to the custom token and/or php execution. Let's see...

thekayra’s picture

Has anyone any ideas or information about this?

gallamine’s picture

thekayra, I'm also looking for a way of accessing the vote value via a token. Let me know if you've found something out.

thekayra’s picture

I have used the following to create a custom token (Type=Node) via the custom token module. It keeps the vote of the logged-in user.

$criteria = array('content_type' => 'node', 'content_id' => $node->nid, 'uid' => $user->uid);
$user_vote = votingapi_select_single_vote_value($criteria)/10;
return $user_vote;

Looks like it is working for me. Let me know if you run into any issues.

thekayra’s picture

Actually adding global $user; makes it better.

<?php
global $user;
$criteria = array('content_type' => 'node', 'content_id' => $node->nid, 'uid' => $user->uid);
$user_vote = votingapi_select_single_vote_value($criteria)/10;
return $user_vote;
?>
BenK’s picture

Subscribing...

darioshanghai’s picture

+1

TheThumbPuppy’s picture

subscribing

OFF’s picture

Subscribing

jacobpov’s picture

jacobpov’s picture

Subscribing

joecanti’s picture

Hi all,

What stage is this at? Has there been any development on this functionality?

Many thanks, Joe

kompressaur’s picture

subscribing

joecanti’s picture

It looks like there is still quite a bit of interest in this happening - and no real solution for the kind of integration outlined in post #32 (which would be excellent by the way)

I'd be happy to chip in for this kind of integration - anyone know how complex this task might be and what it might cost for a developer to do?

cheers, joe

hankp98072-’s picture

Joe -

As I posted, there is a way to do it, laid out here - http://drupal.org/node/592866

We have it implemented at our site and it seems to work fine.

Hank

joecanti’s picture

Thanks for the reply Hank. I began looking at your method yesterday and gave it a quick try. Will continue testing more deeply today. What kind of functionality does this give you? Are you then able to have events, conditions and actions based around votingapi votes?

Many thanks, Joe

joecanti’s picture

Hi Hank,

I tested your fix more thoroughly but unfortunately I dont think it does what I'm after. Please let me know if I'm wrong (Im new to rules!)

I think Im looking for a system which allows rules to apply a vote to a node (Action) rather than tally votes already applied in order to perform a given Action.

Your Fix:

- Vote Up/Down adds vote to node >> votingAPI adds up the votes >> Rules + custom token grabs vote numbers per node >> if above the threshold node gets promoted to front page.

What I'm after (I think!)

- Given action performed on site (EG Flag added to node) >> Rules takes note and if conditions passed >> Applies vote to node through VotingAPI

- If Rules conditions fail >> return message to user like 'you've used up all your votes for the day'

This would allow any action on the site to become voting triggers, and in my case would integrate Flags into the mix. It would also allow conditions like limiting users votes per day by number or by Role.

I think i'm coming at it from a slightly different angle - this is why i sited post #32 - please let me know if i'm wrong or if you can think of a solution!

Many thanks, Joe

hankp98072-’s picture

Joe -

You're correct, our goal was merely to tally votes and promote to the front page based on total vote count (like the Voting Actions module in v5).

I think you could use custom tokens to do what you want, but I think you'd probably have to work with the Actions and Triggers modules and hook them in to however you flag content. That's beyond my abilities, I'm not good enough at PHP to custom code stuff. My goal was to replicate Voting Actions as easily as possible without custom changes that I'd have to worry about when doing an upgrade.

I wish you luck, not sure if I can be much more help.

Hank

marvil07’s picture

as a maintainer of a module depending on voting api module, I would really like to have this, since there are also ask for vote up/down to integrate with rules: #467220: Integration with rules

btw great feedback, hopefully I will be back in some days(after cleaning vote up/down queue) to try make this happen.

joecanti’s picture

Hi Hank and Marvil07,

Thanks for your replies...

Hank - thats sounds like a good idea - I might give it a go with custom tokens, but like you, i think it might be beyond my php abilities... I now have a better understanding of the differences between the voting actions module functionality, and that described here in post #32 so that may help with experimenting.

Marvil07 - thanks for the interest! There seems to be quite a lot of modules depending on votingAPI which have rules integration floating around in the issue queues so I guess it would make sense to integrate votingAPI. So a big thumbs up if you come up with a solution! I'll help out any way I can.

Thanks, Joe

scott859’s picture

subscribing

saulalbert’s picture

subscribing

j0nathan’s picture

subscribing

drupov’s picture

subscribe

Flying Drupalist’s picture

Project: Voting API » Voting Rules
Version: 6.x-2.x-dev » 6.x-1.0-alpha1
Status: Needs work » Fixed

Omg yay:

http://drupal.org/project/voting_rules

For specifics, make new issues on the new project.

joecanti’s picture

+ 1 thank you heydemo - this is great!!

Going to give it a try right now.

Joe

heydemo’s picture

Beat me to posting the link :)

It's still ALPHA of course and completely untested for users and comments, so don't go installing on production sites quite yet! Looking forward to your bug reports and feature requests.

fcedillo’s picture

we have tested "rules" integration with "voting api" through "voting rules".

our test was about creating a rule where a "user votes on a note" and the action "Show a configurable message on the site".

things were ok!

@heissen @fcedillo @marvil7

Status: Fixed » Closed (fixed)
Issue tags: -rules integration

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