Current system allows for voting on your own content. I had a request to disable this and I'm sure others have had the same. Here is a patch based on the current version to put an option in the Advanced Settings section to disable this.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Gekiboy’s picture

FileSize
4.92 KB

The patch also involves a previous patch I did to remove some defunct and no longer utilized code from this module. I would separate the patch out, but I don't want to toy with the contents of the patch file.

lut4rp’s picture

Status: Active » Needs work

No more features are being added to 1.x
Needs re-roll for 2.x

Gekiboy’s picture

This patch was for the 6-2.x branch. Does it not patch correctly?

Gekiboy’s picture

Nm, my mistake, this is using 6-1.x. I'll wait until 6-2.x has a stable release before doing anything.

drupov’s picture

subscribe

drupov’s picture

@Gekiboy: Hi, do you have any plans on making this work for the 6.x-2.x version? Thanks!

Edit: sorry, forget this post, I thought the 2.x version had the beta release, but it is not appendable to the latest beta6 release.

ManyNancy’s picture

Is this patch already part of 2.x? I can't vote on my own content.

ManyNancy’s picture

Status: Needs work » Fixed

Uh nevermind, I had userpoint karma enabled, which has this feature.

I suggest everyone who needs this feature to install that module.

Oleksa-1’s picture

FileSize
2.57 KB
27.88 KB

@Minqensan thx for idea. I do not use "userpoint karma" but applied its code for vud.module.

Just replace vud.module file with attached file.

How it works see picture attached.

Oleksa-1’s picture

FileSize
2.56 KB

this one is better )

drupov’s picture

I can confirm that #10 is working for me. I use the latest 2.x-dev version and apply replace the "vud.module" file inside it with the one provided by Oleksa.

@Minqensan: Thanks for the idea!!! The community has been waiting for ages for a solution to not be able to vote on own contents.

@Oleksa: Thanks for adding this feature directly to vud! It's always better to have such a functionality directly in the module itself. Can you please still provide the solution as a patch or specify which rows have been affected by the change? Thanks!!!

Oleksa-1’s picture

FileSize
2.4 KB

@mitkoru please try this patch

drupov’s picture

I can confirm that patch from #12 is working!

Thanks Oleksa!

azwildcat’s picture

This is a nice patch. There’s a problem however, in that my anonymous users cannot vote now. I made sure this wasn’t a permissions issue and sure enough anonymous users are allowed to use the module. I then placed the original vud.module back in the folder and it allowed anonymous users to use the module. As such, there’s an issue with this patch. If you can provide a solution, I’d appreciate it.

Oleksa-1’s picture

pls remove this lines from the patch from #12

+ if (!$user->uid) {
+ // Anonymous users can't do karma
+ exit();
+ }
+

marvil07’s picture

Status: Fixed » Active

marking as active as it was not applied on CVS

gausarts’s picture

Subscribing. Thanks

Alcaparra’s picture

I have the last version 6.x-2.x-dev 2010-Mar-12 and I want to disallow Voting on Your Own Content. How to? thanks

marvil07’s picture

Status: Active » Needs work

patch in #12 do not apply against 2.x

Oleksa, It would be great if you can re-roll the patch

Oleksa-1’s picture

FileSize
2.7 KB

re-roll
user can't vote with this patch for own content - but if he tries this message popups

An error occurred at /vote/comment/324/-1/vote/plain/d3d98d62d4c63dd0cf7092e265018ca4.
Error Description:

Not sure problem with this patch or with new ctools integration?

marvil07’s picture

It would be great to have a configuration option to choose whether or not we wan to allow users to vote on his own content.

PS: writing it to avoid forgetting it ;-)

Oleksa-1’s picture

It is already included in this patch http://drupal.org/files/issues/vud_own_content.JPG

drupov’s picture

But is it already commited to the latest dev? This is a kind of important feature, isn't it?

dmgorsky’s picture

Very important feature!

walker2238’s picture

Subscribing

Oleksa-1’s picture

Status: Needs work » Needs review
FileSize
2.93 KB

actually this is code from userpoint karma applied to vud module

marvil07’s picture

Status: Needs review » Needs work
+++ vud.module	23 Jun 2010 17:13:34 -0000
@@ -5,6 +5,8 @@
+define('VUD_VOTER_OWN',  'vud_voter_own');//need it for option to disallow voting on own content
 

IMHO we do not need to define this as a constant.

+++ vud.theme.inc	23 Jun 2010 17:26:02 -0000
@@ -356,3 +368,17 @@
+function vud_get_content_uid($type, $cid) {
+  // Get the content item's uid.
+  // We don't do full node_load() here for performance reasons
+  if ($type == 'node') {
+    return db_result(db_query('SELECT uid FROM {node} WHERE nid = %d', $cid));
+  }
+  else if ($type == 'comment') {
+    return db_result(db_query('SELECT uid FROM {comments} WHERE cid = %d', $cid));
+  }
+  else {
+    return 0;
+  }
+}

Here we need to change the logic, since it's implemented on vud module, so we need to be agnostic about what vud_* submodule we are in for voting.

I'm still not sure about how to deal with this, but definitely, we want to avoid assuming all possible submodule cases(BTW this logic do not include support for terms).

Powered by Dreditor.

marvil07’s picture

Version: 6.x-2.x-dev » 6.x-3.x-dev
Oleksa-1’s picture

I use this code on big comunity site already during half a year, without any problems. So it is tested very well.

marvil07’s picture

Oleksa: please re-read my comment. I'm talking from an architecture perspective, and IMHO it's unacceptable to assume the base vud module knows all its children vud_* submodules(it is not related with the efficacy of the patch, it solves the problem, but I think it's a bad architecture choice)

Oleksa-1’s picture

Ok, hope to see implementation of this feature in 6.3x

Grayside’s picture

Let's talk architecture.

What about adding a specific callback to the provider modules?

function vud_get_content_uid($type, $id) {
  $callback = 'vud_' . $type . '_content_owner';
  $uid = $callback($id);
  return isset($uid) ? $uid : 0;
}

function vud_node_content_owner($nid) {
  return db_result(db_query("SELECT uid FROM {node} WHERE nid = %d", $nid));
}

function vud_comment_content_owner($cid) {
  return db_result(db_query("SELECT uid FROM {comments} WHERE cid = %d", $cid));
}
marvil07’s picture

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

This will force implementations like vote on users/fields(planned) to have default fallbacks, which would work but it would start forcing the proposed way.

I am really not sure about including this feature, I would prefer that this would be implemented at the widget level. It should be possible using the drupal_alter in vud_vote with custom commands for the ajax things using the widget 'ajax render' callback.

marvil07’s picture

Grayside’s picture

Reading your comment and the linked issue, I am confused.

Are you suggesting you are open to per-widget patches using the forthcoming hook_vud_access() to add this option, or that you want this feature left out for a third-party/site custom module?

This is part of core use cases for a voting widget.

klonos’s picture

subscribing... this is a really important feature and must be added. I too cannot understand why it was set to won't fix :/

Please reconsider Marco.

Grayside’s picture

Status: Closed (won't fix) » Active

Setting back to active just to gain clarification.

marvil07’s picture

Status: Active » Closed (won't fix)

Like mentioned in the related issue (#877392-6: Add hook that allows modules to alter voting permissions), I am inclined to provide a hook that would be implemented outside the module, but it would not provide a default hook implementations at the vud_* modules.

Grayside’s picture

Thank you for clarification. I don't understand your position on what for me is the primary operating mode of any voting widget being used as other than a bookmarking tool. I would think the answer is to implement another configuration checkbox and check that in the _alter hook.

I will post a snippet once the patch lands.

castelar’s picture

subscribing

sandino’s picture

subscribe

klonos’s picture

This is a greatly desired feature, but after 2 years still no solid solution. I completely understand #33, #34 & #38, but still I need to achieve this and I see no obvious way. So, instead of turning this issue to a support request and re-opening it (risking the maintainer's wrath too), I've opened #1201938: How To: Disallow voting on your own content. Anybody with success recipes welcomed to share knowledge and experience there. Thanx beforehand.

drnikki’s picture

@klonos - I'm working on a d7 patch for hiding the widget now.

marvil07’s picture

See #1201938-3: How To: Disallow voting on your own content, on 6.x-3.x is possible implementing hook_vud_access(). Hopefully this issue will now rip :-)

soulfroys’s picture

I just re-rolled the patch #26 against the latest version (6.x-3.2)...

Warning: this patch will never be commited! As already said above, this issue is dead, and the real solution must implement the hook_vud_access(). I posted this patch here for reference only, until I have time to implement the correct solution.

Ainur’s picture

soulfroys, disallow-vote-own-content-554360-45.patch needs to call ctools_include('ajax'); just before ctools_ajax_render_error.

soulfroys’s picture

Hi, It's already there, isn't it?