Posted by cpliakas on August 9, 2010 at 2:41am
7 followers
| Project: | Vote Up/Down |
| Version: | 7.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
It would be useful if Vote Up/Down defined a hook that allowed modules to alter the voting permissions. One use case would be for a contributed module to provide timed voting based on a node's CCK date fields.
Comments
#1
The attached patch adds a hook_vud_access() hook modeled after the Flag module's hook_flag_access(). There is also a hook implementation in the vud_node() module that allows for users to select "One time voting" restrictions so they cannot vote more than once.
#2
The last submitted patch, vote_up_down-877392-1.patch, failed testing.
#3
Committed an older patch in #1. The attached patch is the most recent and takes vud_comment and vud_term into account. Will work on unit tests.
#4
The patch is clean, but IMHO this is out of the scope of the module.
I would suggest to implement that functionality at the widget level, showing the voting control only when needed. I am willing to move more interaction to the widget in the future, but definitely not for the actual 2.x stable branch.
#5
Hi marvil07.
Thanks for the feedback. First, I should have patched this against 3.x, I agree with you that it shouldn't be in the 2.x stable branch since it is a significant change. Regarding preventing voting by the widget, my opinion is that it should not be handled on the display layer. The reason is that you should be denied access to vote as opposed to the widget just hiding the voting options. Furthermore, preventing voting via a universal access callback allows you to have the changes reflected across all widgets, so your logic isn't determined solely in the presentation layer. Looking at some of the voting features we want to implement in Drupal Commons, we would most likely have to override the menu callback and implement an access hook which is a viable solution, but it would be cool if we could get this code into the core module.
Thanks for a great project, big fan of the work you have done on it.
~Chris
#6
Thinking this a little more, I notice this could help to achieve #554360: Disallow Voting on Your Own Content from another module, so re-opening this.
In the other side, I think we only want the hook declaration, I mean, not the hook implementation inside any of the modules.
#7
Hi marvil07.
Sounds good, and thanks for taking the time to consider this further. Also, I agree with you that there probably shouldn't be any hook implementations inside of the module. Leaves room for contribs and custom mods to fill that space.
Thanks again,
Chris
#8
Accidentally reverted tags... changing back.
#9
Re-rolled patch against the 6.x-3.x-dev version of the module. As requested in #6, it includes only the hook definition and no implementations.
Thanks,
Chris
#10
The last submitted patch, vote_up_down-877392-9.patch, failed testing.
#11
#9: vote_up_down-877392-9.patch queued for re-testing.
#12
The last submitted patch, vote_up_down-877392-9.patch, failed testing.
#13
It would be really great to be able to prevent users from voting on own content, so I hope this patch passes the test soon 8o)
#14
+++ vud.module 17 Sep 2010 14:50:22 -0000@@ -108,6 +110,46 @@ function vud_menu() {
+function vud_access($perm, $type, $content_id, $value, $tag, $account = NULL) {
This accidentally implements hook_access(), so changing the name would be better.
+++ vud.module 17 Sep 2010 14:50:22 -0000@@ -108,6 +110,46 @@ function vud_menu() {
+ if (NULL === $user) {
minor bug here, the comparison if against $account variable.
Powered by Dreditor.
#15
Any update on this?
#16
Re-rolled patch based on comments in #14.
Thanks,
Chris
#17
I finally returned to this \o/. Committed to 6.x-3.x. Thanks for the patience here!
I have just changed the way of the hook, the behaviour now is deny access if:
In other case, allow. IMHO that's more clear to read.
I have also made some tweaks here and there. Attaching the patch I am going to commit and the interdiff patch for people here since the last patch ;-)
Moving status to port(not sure if in exactly the same way) it to the 7.x version when possible.
#18
sorry, forgot to attach the patches for convenience :-p
#19
Thanks for getting back to this and posting your modifications. I think this will help in building ideation solutions similar to ideascale and quora.
#20
...and if anyone manages to put something together based on this that solves #1201938: How To: Disallow voting on your own content (script or unofficial sub-module or whatever), please post it here or there so we can finally close that one too. Thanx.
#21
So, in Drupal 6 version, how can I deny voting on user's own content, can anyaone help me with this?
#22
@vonderro: You can do it using hook_vud_access().
#23
The attached patch is now on 7.x-1.x.
From commit message:
#24
Automatically closed -- issue fixed for 2 weeks with no activity.