Support from Acquia helps fund testing for Drupal Acquia logo

Comments

photoscapes’s picture

I am looking for the same thing. Did you find a solution to this yet?

neopoet’s picture

Nope :(

neopoet’s picture

I just discovered this-- it might be of interest.

Instead of prohibiting people from voting on their own items, it automatically "self votes" 100% on each-- I suppose it has essentially the same effect.

http://drupal.org/node/176560

john.karahalis’s picture

This feature is needed. I'm going to send a quick message to the developer and ask what he/she thinks.

ezra-g’s picture

[edited for clarity]
A quickie way of achieving this functionality would be to set the Fivestar widget to display manually and then in the node template add a conditional to check if the current user is the author of the node being viewed before printing the fivestar widget:

<?php
global $user;
if ($user->uid != $node->uid) {
 print fivestar_widget_form($node);
}
?>

If this was added to the module as a configuration option, should it be site-wide, on a per-role or a per-node type basis?

john.karahalis’s picture

I thought about doing something like that, but wouldn't that also prevent the author from seeing the current rating of his own posts?

jhedstrom’s picture

Version: 5.x-1.8 » 5.x-1.11
Status: Active » Needs review
FileSize
985 bytes

I've created a patch that accomplishes this via an additional permission (rate own content). Note, since the new permission won't be immediately granted to users, this will change default behaviour, which may cause confusion (users who used to be able to vote on their own content, won't be able to do so, until the new permission is granted).

dawehner’s picture

FileSize
1.88 KB

i wrote a similar patch, which adds some more features than just rating on own content

* allow to rate on author content, by nodetype
* allow certain users to rate always on own content, even if forbidden by the node type settings

Here is the patch

written for head, but should also work for previous versions

ibexy’s picture

applied this patch. The option for vote on own node appeard in as expected and even though its not checked, users can still vote on their own node. I have installed the advanced profile module and it creates profiles as biography node type. Users can still vote on their own profile display in a view I implemented.

roderik’s picture

FYI: I applied the patch from #8 (whose way of thinking seems to me to be more inline with Drupal/fivestar than #7) to the 6.x-1.13 release.
It applied (with huge offsets, but still) and worked well against my custom node type. NB: the 3rd hunk of the patch fails to apply; this is not a problem. (See the patch itself, if curious.)

dawehner’s picture

FileSize
1.52 KB

yes definitve something strange, the last part

i wrote the patch, if i remember right for the last five devel version

it removed the 3 stuff and there are no problems anymore with patching

more people who would like to test?

chasz’s picture

+1

yrre7’s picture

subscribing

quicksketch’s picture

Status: Needs review » Needs work

This patch seems like a pretty good idea in most regards, but the implementation does not work at all. There are several permissions that are checked:

+  else if (user_access('rate on own content') && variable_get('fivestar_author_'. $node->type, 1)) {
+    return drupal_get_form('fivestar_form_node_'. $node->nid, 'node', $node->nid);
+  }
+  else if (user_access('allow always to rate on own content')) {
+    return drupal_get_form('fivestar_form_node_'. $node->nid, 'node', $node->nid);
+  }

Yet these permissions "rate on own content" and "allow always to rate on own content" don't exist. I don't think they should exist at all anyway. I'd find their usefulness extremely limited compared to the addition of code. So I'd opt for removing what exists of them from the patch.

The patch also sets a variable for 'fivestar_author_'. $node_type, but doesn't use it anywhere. This should be the only variable checked for access IMO (in addition to "rate content" of course).

I do like how this patch modifies fivestar_widget_form() to include the permission checking though. This would save a lot of themers the hassle of checking permissions themselves. It would also allow us to simplify the code in fivestar_nodeapi(), where we're doing similar checks.

Lastly, this patch would also have to incorporate functionality into fivestar_comment module, as this approach would only stop you from voting directly on nodes, but you could still leave a rating through a comment.

So I'm in full support of this patch, but it still needs some work.

dawehner’s picture

Version: 5.x-1.11 » 5.x-1.13
FileSize
2.04 KB

Very very strange, here is the original patch rerolled to the new version

The patch applies perfect here, even on the current version for 6

but i have to create a fivestar_access function, because fivestar/vote could be accessed without the permission to vote on own content.
fivestar_access is not good, because of hook_access, any other suggestions

hedac’s picture

is this applied in current dev of 6.x ?
an "Allow users to vote own nodes" toogle in the options of each content type would be awesome. just below "Allow users to undo their votes".

dawehner’s picture

Assigned: Unassigned » dawehner

i think this is not part of any dev.

i will find time this weekend to reroll the patch... get some work in it

gonzalez_ea’s picture

subscribing

Flying Drupalist’s picture

Subscribe

dawehner’s picture

good morning

i removed the permissions and just check for content type now.
additional i added support for comments and testet it

Off Topic: What does this line? :)
<?php $comment->fivestar_rating = $comment->fivestar_rating; ?>

here is the patch

dawehner’s picture

Status: Needs work » Needs review
oradoe’s picture

DELETED

roderik’s picture

Status: Needs review » Reviewed & tested by the community

#20 applies to 5.x-1.13 and 6.x-1.13. (to both modules with offsets? But does not matter I guess)

And works.

So after the scrutiny already received by quicksketch, I guess I can change status?

(I should be more proactive next time and ask "what are all these permissions", I guess.)

sped2773’s picture

The patch in #20 will not work for fivestar_comment the + line below only checks if the fivestar_author_vote variable is set or not i.e. it will be disabled or enabled it does not take into account the current user at all so if it is enabled everyone can rate, if it is disabled no one can rate.

// Comment form. Do not allow ratings inside of threads.
   if ($form_id == 'comment_form' && empty($form['pid']['#value']) && user_access('rate content')) {
     $node = node_load($form['nid']['#value']);
-    if (variable_get('fivestar_comment_'. $node->type, FIVESTAR_COMMENT_DISABLED)) {
+    if (variable_get('fivestar_comment_'. $node->type, FIVESTAR_COMMENT_DISABLED) && variable_get('fivestar_author_vote_'. $node->type, FIVESTAR_COMMENT_DISABLED)) {
       // Splice in the fivestar right before the body.

There needs to be a check similar to that perform in the fivestar_widget_form in fivestar.module to check the if the user is the node author e.g.

global $user;
$allow_voting = TRUE;

// If this is the node author, check if they are allowed to vote
if ($user->uid == $node->uid) {
   $allow_voting = variable_get('fivestar_author_vote_'. $node->type, 1);
}

if (variable_get('fivestar_comment_'. $node->type, FIVESTAR_COMMENT_DISABLED) && $allow_voting) {

... etc
quicksketch’s picture

Status: Reviewed & tested by the community » Needs work

Yep, needs work per sped2773's comments. This needs to be updated for fivestar_comment.module.

dawehner’s picture

Status: Needs work » Needs review
FileSize
2.61 KB

here is a new version which solved the fivestar_comment problem.

OT. should i write a test for this?

bakhayt’s picture

Subscribing

=====
The online community of Dubai.

gunzip’s picture

subscribe (will this appear in the core ?)

czeky’s picture

new patch on this?

czeky’s picture

did the patch manually on older dev version, thanx

Parkes Design’s picture

Subscribing

Breakerandi’s picture

I'm too stupid to do a patch, so I hope the problem will be fixed in the next release..

jwjoshuawalker’s picture

Title: Prohibit users from voting on their OWN nodes » Prohibit members from voting on their OWN nodes
Version: 7.x-2.x-dev » 5.x-1.13
Assigned: Unassigned » dawehner

Hey guys, not sure if everyone is content with the current fixes available. I hadn't seen this thread during my time working on creating this effect.

Here is a method of preventing the node owner from voting on the node. This does not 'patch' or in any other way effect the fivestar module which allows you to upgrade as new versions come out.

First step is making a node-your_content_type.tpl.php for the node types you have fivestar voting on.

Next, in the location you wish your fivestar to be located, enter this code:

<?php

  if($user->uid) {
    $nodevotes = fivestar_get_votes('node', $node->nid, $tag = 'vote', $user->uid);
    if(empty($nodevotes['user']['uid']) && $node->uid != $user->uid) {
      print fivestar_widget_form($node); 
    }
    else {
      print fivestar_static('node', $node->nid, $tag = 'vote', $node->type); 
    }
  }
  else {
    print fivestar_static('node', $node->nid, $tag = 'vote', $node->type); 
  }

    ?>

This obviously also prevents anonymous users from voting. It also checks to see if this user has voted previously and does not let him vote on the node again or change his vote.

To accomplish preventing the author from voting on his own node without doing the other 2 checks, just enter the code like this:

<?php

  if($node->uid != $user->uid) {
    print fivestar_widget_form($node);
  }
  else {
    print fivestar_static('node', $node->nid, $tag = 'vote', $node->type); 
  }
    
?>

I know this works on fivestar 6.x-1.15 and 6.x-1.18 and probably any other release.

If you use the first version of the code, users will be able to change their vote while still on the page in case of an accident or mis-click, but once they leave the page or refresh, the vote is locked and they cannot change it. The second version however, uses fivestar's typical procedure that allows users to change their vote at any time.

Also be sure to go back to the settings page for that content type, and turn off the fivestar displays for teaser and full node. DO NOT disable it, just select "hidden" from the 'Teaser ' & 'Full Node' display options.

gunzip’s picture

@blindside,

correct me if i'm wrong but i think this does not solve the problem at all
as users can still vote on their own items doing a direct http POST request.

jwjoshuawalker’s picture

Never looked at that. I didn't count on fivestar ninjas~

I suppose in that case, if you still wanted to stay out of the module's code, you could put something else inline with the 'if this node is owned by this user' check, a URL parse to also exit() or something if they try to do a direct POST.

drupov’s picture

subscribe

gmcs’s picture

subscribing. this is surely an essential feature for a fair reflection on voting?

mrówek’s picture

This works with Fivestar 6.x-1.19

1) Add to function fivestar_form_alter

    $form['fivestar']['fivestar_author_vote'] = array(
      '#type' => 'checkbox',
      '#title' => t('Allow the author to rate his own content'),
      '#default_value' => variable_get('fivestar_author_vote_'. $form['#node_type']->type, 1),
      '#weight' => -4,
    );

2) Add after

fivestar_validate_target('node', $node->nid)

this additional checks

 && ($node->uid != $user->uid || ($node->uid == $user->uid && variable_get('fivestar_author_vote_'. $node->type, 1)))

Insert global $user; before those ifs

GreenReaper’s picture

Surely all you need for part 2 is this?
&& ($node->uid != $user->uid || variable_get('fivestar_author_vote_'. $node->type, 1))

If the first test fails, the first part of the second test is redundant.

azwildcat’s picture

FileSize
14.6 KB
14.57 KB

I applied the patch from #26 and it did what it was supposed to do but now the authored user cannot see the score for his node. The star display style setting is “display user vote value” and text display style setting is “current average in text.” See the attachments to see what I mean. Users should not be allowed to vote on their own contents but should be able to see the scores tallied from other users. Please fix. Thanks.

mrówek’s picture

@GreenReaper

This test is used to decide if to use static (info only) or dynamic (voting) widget:

if (user_access('rate content') && fivestar_validate_target('node', $node->nid) && ($node->uid != $user->uid || ($node->uid == $user->uid && variable_get('fivestar_author_vote_'. $node->type, 1)))) {
   #USE DYNAMIC
}
#USE STATIC

$node->uid != $user->uid // use dynamic widget always when not-author is watching
OR
$node->uid == $user->uid && variable_get('fivestar_author_vote_'. $node->type, 1) // if author is watching but setting says author can vote on him self - use dynamic widget

"If the first test fails, the first part of the second test is redundant."
Yes you are right :) , but i prefer using more readible way.

----

@azwildcat

I had same problem with this patch. Try my way. I don't know how to make patches, no time to learn it :|

drupov’s picture

@mrówek: hi, what do you mean in #38 by "Insert global $user; before those ifs". Which "ifs" do you mean?

Would it be possible to make a patch for your solution?

kumobako’s picture

FileSize
1.68 KB

Patch for #38 against 6.x-1.x-dev 2010-Jan-28.
Thank you mrówek.

GreenReaper’s picture

To extend this to comments, which can be posted by anonymous users, I needed the hostname. I ended up adding hostname in various database query strings in the fivestar_bonus_api module and then using it in fivestarextra. Just throwing these patches out there in case anyone is in a similar situation.

joeytheman’s picture

is this going to be committed?

joeytheman’s picture

or developed for 6.x?

tbertin’s picture

subscribing

mstrelan’s picture

subscribe

joyseeker’s picture

Forget what I wrote earlier -- got the patch in #43 working -- I guess it would help to log in as a different user when making a comment to test it... Thanks for the patch!

ltwinner’s picture

It's nearly 3 years since this issue was posted, any chance of committing a fix?

mstrelan’s picture

Version: 5.x-1.13 » 6.x-1.x-dev
coolhandlukek2’s picture

Subscribe - will try #43 kumobako's patch would be good to have this commited.

dawehner’s picture

Assigned: dawehner » Unassigned

Unassign myself.

YK85’s picture

subscribing

udvranto’s picture

Not sure why it's not part of the module!

Version 1.3:

includes/fivestar.admin.inc

    '#title' => t('Enable Fivestar rating for the "@tag" tag', array('@tag' => $tag)),
    '#default_value' => $settings['fivestar'],
    '#return_value' => 1,
    '#weight' => -5,
  );

  $form['fivestar_author_can_vote'] = array(
    '#type' => 'checkbox',
    '#title' => t('Allow the author to rate his own content'),
    '#default_value' => $settings['author_can_vote'],
    '#weight' => -5,
  );

fivestar.module

          case 'below':
            if (user_access('rate content')) {
              $content = '';
              foreach (fivestar_get_tags() as $tag) {
                if (fivestar_validate_target('node', $node->nid, $tag)) {
                  global $user;
                  if($node->uid != $user->uid || variable_get('fivestar_author_can_vote_'. $node->type, 0))
                    $content .= fivestar_widget_form($node, $tag);
                  else
                      $content .= fivestar_static('node', $node->nid, $node->type, $tag);
                }
              }
              if ($content) {
                $node->content['fivestar_widget'] = array(
                  '#value' => $content,
                  '#weight' => $position == 'above' ? -10 : 50,
                );
              }

function fivestar_get_settings($node_type, $tag):

  $settings = array(
    'fivestar' => variable_get('fivestar_' . $suffix, 0),
    'stars' => variable_get('fivestar_stars_' . $suffix, 5),
    'unvote_enable' => variable_get('fivestar_unvote_' . $suffix, 0),
    'feedback_enable' => variable_get('fivestar_feedback_'. $suffix, 1),
    'labels_enable' => variable_get('fivestar_labels_enable_'. $suffix, 1),
    'labels' => variable_get('fivestar_labels_'. $suffix, array()),
    'star_display' => variable_get('fivestar_style_' . $suffix, 'average'),
    'text_display' => variable_get('fivestar_text_' . $suffix, 'dual'),
    'title_display' => variable_get('fivestar_title_' . $suffix, 1),
    'position' => variable_get('fivestar_position_' . $suffix, 'below'),
    'position_teaser' => variable_get('fivestar_position_teaser_' . $suffix, 'hidden'),
    'author_can_vote' => variable_get('fivestar_author_can_vote_' . $suffix, 0),
  );
udvranto’s picture

What do I need to do to check it in the dev?

udvranto’s picture

Version: 6.x-2.x-dev » 7.x-2.x-dev
Status: Needs work » Needs review
FileSize
599 bytes
1.5 KB

Changes for 7.x

Update: Ignore this

udvranto’s picture

Status: Needs review » Needs work
FileSize
599 bytes
1.5 KB

For 7.x

Update: Ignore this

udvranto’s picture

Version: 6.x-1.x-dev » 6.x-2.x-dev
Status: Needs review » Needs work
FileSize
2.43 KB

Version 6.x-2.x

udvranto’s picture

FileSize
2.55 KB

Version 7.x-2.x head
Not sure if I should change the version in the issue.

Weka’s picture

Version: 7.x-2.x-dev » 6.x-2.x-dev

+1 Subscribe

Weka’s picture

Another temporary solution until this feature is implemented would be to:
1: Change the Teaser/Full node display options to either 'hidden' or 'Static display ...
2. Set up a view for the voting process using the User: Current filter.

udvranto’s picture

I am not sure why this feature is not being considered for so long. Clearly many users want this and has been manually implemented by many.

I have been using the dev version and getting tired of manually patching the module again and again. :(

ezra-g’s picture

Status: Needs work » Needs review
brunorios1’s picture

sub

john.karahalis’s picture

This bug has been open for a long time. Is this something that belongs in the Voting API instead? If so, maybe we could hand it off to them.

ericduran’s picture

Version: 6.x-2.x-dev » 7.x-2.x-dev
Category: feature » bug
Status: Needs review » Needs work

Hmm, so this has been a request for a long time now and is actually one of those tickets that just keep coming up, so lets just fix it once and for all.

Some feedback on the ticket. -- We need too suport both the node specific fivestar widget but we also need to add support for the exposed stars formatter since it's probably going to be more popular because is the only way you can get fivestar on any entity.

gawi’s picture

What is the current state of this fix and condition of this request?
Thanks

Leeteq’s picture

Priority: Normal » Major
ericduran’s picture

Category: bug » feature
Priority: Major » Minor

This is not a major issue. I'm changing to minor. For my own sanity on the issue queue.

ericduran’s picture

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

Ok, so unless someone writes a patch for the 7.x-2.x version, I honestly don't see this feature getting in.

Marking it as wont fix unless someone wants to take it over.

kssundar’s picture

Here's a js quick fix. No need to change fivestar module

function custommodule_form_comment_form_alter(&$form, &$form_state){
  global $user;
  if($user->uid == db_result(db_query("SELECT uid FROM {node} WHERE nid = %d",$form['nid']['#value']))){
    drupal_add_js('$(document).ready(function(){$(".fivestar-widget div div div div div div a").mouseover(function(){ return false;});$(".fivestar-widget div div div div div div a").click(function(){ return false;});});', "inline");
  }
}

You can try to simplify this further by writing hook_perm in a custommodule and using the permission here.
You can also put this code in node.tpl.php or node-content_type.tpl.php. Just replace $form['nid']['#value'] with $node->nid and there will be no need of form alter there.

rogical’s picture

Title: Prohibit members from voting on their OWN nodes » Prohibit users from voting on their OWN nodes

this is quite necessary and waiting for a patch also.

Energyblazar’s picture

+1 me too waiting form a long time for this patch, that disables the author to vote on himself...

dimitriz1’s picture

Priority: Minor » Normal
Status: Closed (won't fix) » Active

This is a joke that this hasnt been implemented into the module yet. One of first things anyone would think of when writing a rating system is to prevent a user voting on their own content...how did no one think of it for this module. And this is the longest running and has the most comments of any issue in the queue, maybe the maintainer should step aside from this module if they are not bothered putting in this simple and much demanded feature that has been requested for nearly 5 years now.

rogical’s picture

Agree.

Mile23’s picture

Just to point out that there's a patch at http://drupal.org/node/189527#comment-3973308

soulfroys’s picture

Priority: Normal » Critical
Status: Active » Needs review
FileSize
1.87 KB

I use the patch in #43 since 11.07.2010 without problems. I fixed the codeding standard and reroll against the last version (6.x-1.20). This is critical, isn't It? Without this feature, I can not use it.

Status: Needs review » Needs work

The last submitted patch, allow-disallow-rate-own-content-option-189527-78.patch, failed testing.

soulfroys’s picture

Version: 7.x-2.x-dev » 6.x-1.x-dev
Status: Needs work » Needs review

Oops...

soulfroys’s picture

G2’s picture

Status: Needs work » Needs review
FileSize
1.71 KB

Version: 6.x-1.x-dev » 7.x-2.x-dev
Status: Needs review » Needs work

The last submitted patch, fivestar-disallow-rate-own-content-189527-82.patch, failed testing.

G2’s picture

The last submitted patch, fivestar-disallow-rate-own-content-189527-84.patch, failed testing.

G2’s picture

Status: Needs review » Needs work
FileSize
2 KB

I created a patch for the latest version (7.x-2.x-dev) using the same logic as the patch in #78. It also works well with 7.x-2.0-alpha2.

G2’s picture

Status: Needs work » Needs review
FileSize
2 KB
Energyblazar’s picture

Hi there guregori

Firstly thank u for ur time and effort...

I did try ur patch, after applying went to Configuration > Content Authoring > Fivestar, found no checkbox there. So then when to structure > content types > created content > Manage Fields > Fivestar field settings, still no checkbox named "Allow author to rate own content".

But yes when i went to People > Permissions > Fivestar, i saw an option called rate own content.

Now i am confused weather as to option was already there or was added in global permission by your applied patch.

Also, can we disable current user voting on himself.

To be specific, i have enabled user voting on users ( so instead of voting on another content, user votes on another user)
Now i want to disable current user voting on himself....any suggestions to as to how can i achieve this.

Thanks

G2’s picture

Priority: Critical » Normal
Status: Needs review » Active

Hi,

You should find the checkbox in Configuration > Content Authoring > Fivestar if you applied the patch correctly. It's a patch against multiple files so make sure to use 'patch -p1 fivestar-disallow-rate-own-content-189527-86.patch' to make every necessary changes. Don't forget to flush caches, just to be sure.

Also, check if there exists any other copy of fivestar module in each possible location, there might be an other somewhere if the checkbox is still not there.

If you see a 'rate own content' permission, that is not caused by this patch, but some other one, that's the only possibility I can think of. Though I think it's a good idea to implement it this way.

If you disable users voting on their own content using my patch, users won't be able to vote on themselves as well.

Energyblazar’s picture

Yep guregori, found the checkbox, had to delete and reinstall the fivestar module.

You were right the rate own content was due to different patch. Here is link [ http://drupal.org/node/1549218 ]

I have 2 different installations of drupal where i am testing your patch...and in both i am facing 2 different difficulties

In first one which is a very fresh installation, i can't untick the checkbox "Allow author to rate own content". If i untick and save it again it returns back as ticked checkbox.

In second installation it gets unticked but still the user can vote on himself. I forgot to mention i am using this user reference patch http://drupal.org/node/1300766 . This patch enables me to cast vote on any user, from the list of users, in the user reference field.

G2’s picture

Try to flush caches and refresh the page if you can't untick the checkbox. To be honest I can't see what might cause the problem there.

As for the other thing, I think you'd need the 'disallow user voting on himself' feature implemented in that patch you're using. Did you try adding a fivestar field to the user object instead of using a patch? You can do that in Configuration -> People -> Account settings -> Manage fields.

Sorry for the late answer, hope I could help.

Energyblazar’s picture

Hello guregori...

I did try to flush caches and refresh pages but still no use. What i shall do is email u admin id and password if you mail me your email at energyblazar@gmail.com.

Also for other thing i think i owe you a further indepth explanation.

In my site i have 2 entites, (1) USERS (2) GROUPS.

->USERS join/create GROUP/S (multiple groups).
->USERS can caste VOTE.
->VOTES can be caste'd only on GROUP MEMBERS.

My Solution using modules Fivestar + User Reference + Few Patches (which includes your patch)

Added Fivestar field in User Profiles (Parent), and one more in User Group comment form (Targets parent feild via user reference fivestar patch).

Thus, Before saving a comment in the particular group, user selects rating (out of 5 stars) and also selects user to be rated via user reference field.

Now i dont want user selecting himself and rating himself.

And many many thanks for your helping hand in the confusing puzzle of drupal Land. :D

Routh’s picture

@guregori :

I'm trying to get your patch applied to the 7.x-2.x-dev branch, however I'm getting a Hunk#1 and Hunk#2 fail on both files:

patch < fivestar-disallow-rate-own-content-189527-86_0.patch
patching file fivestar.admin.inc
Hunk #1 FAILED at 26.
Hunk #2 FAILED at 41.
2 out of 2 hunks FAILED -- saving rejects to file fivestar.admin.inc.rej
patching file fivestar.field.inc
Hunk #1 FAILED at 448.
Hunk #2 FAILED at 463.
2 out of 2 hunks FAILED -- saving rejects to file fivestar.field.inc.rej

Not sure what's wrong. Patch is downloaded to the fivestar directory. This patch has worked for others?

Routh’s picture

Status: Active » Needs review
tmctighe’s picture

I had the same issue, created a patch that adds a per-field choice as opposed to a global setting (patch from #86 would need to remove the created variable on hook_uninstall to meet drupal standards, this shouldn't).

This patch worked for me (7.x-2.x).

Status: Needs review » Needs work

The last submitted patch, fivestar-disallow-rate-own-content-189527-95.patch, failed testing.

tmctighe’s picture

Fixing patch from #95 (notices).

tmctighe’s picture

Status: Needs work » Needs review

forgot status change...

drupov’s picture

Yeah,

patch from #97 works fine!

Great, thanks!

matt.rad’s picture

Title: Prohibit members from voting on their OWN nodes » Prohibit users from voting on their OWN nodes
Version: 5.x-1.13 » 7.x-2.x-dev
Assigned: dawehner » Unassigned

+1

whiteph’s picture

Issue summary: View changes

I applied the patch in #97 in my test system. It works fine for the case where votes are made directly on nodes. It fails when votes can be made on comments attached to a target node. fivestar_field_formatter_view(), which is where the disabling logic is in patch #97, isn't called for fivestars within comments. A possibility is to unset the fivestar form within the comment form, so the user can't see the widget if it's his/her own. That's going to need a fair bit of messing around in something like fivestar_form_comment_form_alter(), plus digging out the "can vote" field meta data which contains the yes/no value for whether owner is allowed to vote or not.

Another challenge is that even though the default is "no, owners can't vote on their own nodes", we'd have to create an update method to set all of the existing fivestar metadata to be set to "yes", otherwise 20,000+ D7 sites in the wild would suddenly find that voting behaviour has changed and they have to do something pronto as we've introduced the new constraint.

Finally, we'd have to test with all of the various other voting targets like users and entity references.

All of which means that this is a chunky piece of work. Anybody up for doing some of this?

whiteph’s picture

Status: Needs review » Needs work
whiteph’s picture

Thinking a bit more about my last comment, the need to include comment-based voting may be an example of "the perfect is the enemy of the good". That is, adding the feature for fivestar widgets which get voted on directly is a perfectly good addition to the module.

Having just fixed Don't let user to change his vote or re-vote, where I created a simple update function, creating a similar function for this issue will be trivial.

So, next time I get some time I'm going to do this.

whiteph’s picture

Status: Needs work » Fixed

Don't let user to change his vote or re-vote created an instance-based property to control re-voting. To keep in sympathy with that, I've re-worked the patch for this feature to be instance-based too.

I've also created an update hook, which sets the allow_ownvote property to TRUE for all existing Fivestar widgets, so existing websites using Fivestar get no surprises. Be sure to run the update after installing the latest 7.x-2.x-dev version.

If anybody wants protection for comment-based votes, please open a new feature request.

Status: Fixed » Closed (fixed)

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

msypes’s picture

Status: Closed (fixed) » Active

Not sure why this was closed, as it still doesn't work, at least not entirely.
While whatever was done to prevent users from voting on their own nodes on the actual node view page, users can still vote on their nodes in a view.

neopoet’s picture

Status: Active » Reviewed & tested by the community

[deleted - this should be "needs review"]

neopoet’s picture

Status: Reviewed & tested by the community » Needs review

changing status to "needs review"

Mile23’s picture

I would suggest filing a new issue dealing with views, especially if you have a patch to fix it.

TR’s picture

Status: Needs review » Fixed

This issue was improperly reopened in #106. As stated in #109, if you have found a problem with this feature open a new issue.

Also, "Needs review" is not the appropriate status - there is nothing (no patch) to review here ...

TR’s picture

Status: Fixed » Closed (fixed)