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.

Files: 
CommentFileSizeAuthor
#23 0001-Issue-877392-by-cpliakas-marvil07-Add-a-hook-that-al.patch4.33 KBmarvil07
#18 0001-Issue-877392-by-cpliakas-marvil07-Add-a-hook-that-al.patch7.88 KBmarvil07
#18 interdiff.patch4.72 KBmarvil07
#16 vote_up_down-877392-16.patch8.01 KBcpliakas
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch vote_up_down-877392-16.patch. This may be a -p0 (old style) patch, which is no longer supported by the testbots.
[ View ]
#9 vote_up_down-877392-9.patch7.8 KBcpliakas
FAILED: [[SimpleTest]]: [MySQL] 107 pass(es), 8 fail(s), and 12 exception(es).
[ View ]
#3 vote_up_down-877392-3.patch9.29 KBcpliakas
FAILED: [[SimpleTest]]: [MySQL] 119 pass(es), 0 fail(s), and 2 exception(es).
[ View ]
#1 vote_up_down-877392-1.patch4.38 KBcpliakas
FAILED: [[SimpleTest]]: [MySQL] 107 pass(es), 8 fail(s), and 10 exception(es).
[ View ]

Comments

Status:Active» Needs review
StatusFileSize
new4.38 KB
FAILED: [[SimpleTest]]: [MySQL] 107 pass(es), 8 fail(s), and 10 exception(es).
[ View ]

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.

Status:Needs review» Needs work

The last submitted patch, vote_up_down-877392-1.patch, failed testing.

StatusFileSize
new9.29 KB
FAILED: [[SimpleTest]]: [MySQL] 119 pass(es), 0 fail(s), and 2 exception(es).
[ View ]

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.

Status:Needs work» Closed (works as designed)

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.

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

Version:6.x-2.x-dev» 6.x-3.x-dev
Status:Closed (works as designed)» Needs work

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.

Version:6.x-3.x-dev» 6.x-2.x-dev
Status:Needs work» Closed (works as designed)

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

Version:6.x-2.x-dev» 6.x-3.x-dev
Status:Closed (works as designed)» Needs work

Accidentally reverted tags... changing back.

Status:Needs work» Needs review
StatusFileSize
new7.8 KB
FAILED: [[SimpleTest]]: [MySQL] 107 pass(es), 8 fail(s), and 12 exception(es).
[ View ]

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

Status:Needs review» Needs work

The last submitted patch, vote_up_down-877392-9.patch, failed testing.

Status:Needs work» Needs review

#9: vote_up_down-877392-9.patch queued for re-testing.

Status:Needs review» Needs work

The last submitted patch, vote_up_down-877392-9.patch, failed testing.

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)

+++ 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.

Any update on this?

Status:Needs work» Needs review
StatusFileSize
new8.01 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch vote_up_down-877392-16.patch. This may be a -p0 (old style) patch, which is no longer supported by the testbots.
[ View ]

Re-rolled patch based on comments in #14.

Thanks,
Chris

Version:6.x-3.x-dev» 7.x-1.x-dev
Status:Needs review» Patch (to be ported)

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:

  • User do not have enough permissions to vote
  • Some module decide to deny access

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.

sorry, forgot to attach the patches for convenience :-p

Thanks for getting back to this and posting your modifications. I think this will help in building ideation solutions similar to ideascale and quora.

...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.

So, in Drupal 6 version, how can I deny voting on user's own content, can anyaone help me with this?

@vonderro: You can do it using hook_vud_access().

Status:Patch (to be ported)» Fixed
StatusFileSize
new4.33 KB

The attached patch is now on 7.x-1.x.

From commit message:

This is a backport of the original patch on #877392-18

The main difference here is that I am applying changes only on vud
module because of the plan(see #1360572).
The othe minor difference is about re-naming some variables to make it
D7-friendly.

Status:Fixed» Closed (fixed)

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