Posted by Gekiboy on August 20, 2009 at 3:23am
| Project: | Vote Up/Down |
| Version: | 6.x-3.x-dev |
| Component: | User interface |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (won't fix) |
Issue Summary
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.
Comments
#1
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.
#2
No more features are being added to 1.x
Needs re-roll for 2.x
#3
This patch was for the 6-2.x branch. Does it not patch correctly?
#4
Nm, my mistake, this is using 6-1.x. I'll wait until 6-2.x has a stable release before doing anything.
#5
subscribe
#6
@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.
#7
Is this patch already part of 2.x? I can't vote on my own content.
#8
Uh nevermind, I had userpoint karma enabled, which has this feature.
I suggest everyone who needs this feature to install that module.
#9
@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.
#10
this one is better )
#11
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!!!
#12
@mitkoru please try this patch
#13
I can confirm that patch from #12 is working!
Thanks Oleksa!
#14
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.
#15
pls remove this lines from the patch from #12
+ if (!$user->uid) {
+ // Anonymous users can't do karma
+ exit();
+ }
+
#16
marking as active as it was not applied on CVS
#17
Subscribing. Thanks
#18
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
#19
patch in #12 do not apply against 2.x
Oleksa, It would be great if you can re-roll the patch
#20
re-roll
user can't vote with this patch for own content - but if he tries this message popups
Not sure problem with this patch or with new ctools integration?
#21
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 ;-)
#22
It is already included in this patch http://drupal.org/files/issues/vud_own_content.JPG
#23
But is it already commited to the latest dev? This is a kind of important feature, isn't it?
#24
Very important feature!
#25
Subscribing
#26
actually this is code from userpoint karma applied to vud module
#27
+++ 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.
#28
#29
I use this code on big comunity site already during half a year, without any problems. So it is tested very well.
#30
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)
#31
Ok, hope to see implementation of this feature in 6.3x
#32
Let's talk architecture.
What about adding a specific callback to the provider modules?
<?php
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));
}
?>
#33
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.
#34
realted #877392: Add hook that allows modules to alter voting permissions
#35
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.
#36
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.
#37
Setting back to active just to gain clarification.
#38
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.
#39
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.
#40
subscribing
#41
subscribe
#42
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.
#43
@klonos - I'm working on a d7 patch for hiding the widget now.
#44
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 :-)