I needed to be able to add additional conditions to determine whether voting should be allowed or not for a node - and I of course didn't like the idea of having to hack Plus1 to accomplish that.
I suggest adding a new hook, similar in design to hook_node_access(), that is used to determine when to show a widget and when to allow a vote.
That makes it possible for me to add extra conditions in my own module - I can for example say that all nodes not tagged with "Voting" shouldn't be voteable or say that all nodes contained added to a group should inherit a vote-setting from that group etc.
Attached is a patch that adds such a hook - "hook_plus1_access()".
Comments
Comment #1
voxpelli commentedFirst patch was missing the new plus1.api.php file - rerolling
Comment #2
voxpelli commentedHadn't tested the patch enough - sorry for that - reroll with fixes for typos etc.
Comment #3
nancydruVery interesting idea - I like it a lot. However, isn't the standard type of return from hooks like this TRUE/FALSE?
Comment #4
voxpelli commentedHmm - yes - can't remember right now why I didn't use that. Might be to avoid mixups between NULL and FALSE perhaps.
I'm currently a bit tied up in trying to get OAuth 3.x stable - due to that I may not give very good response in this issue queue right now.
Comment #5
nancydruThat's okay. I think I have a pretty good number of the fixes ready to go.
Comment #6
nancydruSee fivestar_fivestar_access().
Comment #7
nancydruThis is ready to go.
Comment #8
nancydruComment #9
nancydruCommitted to 6.x-2.x-dev.