Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
Hi,
I've upgraded form version 2.6 to version 2.7 today and after that voting button only appears to authors of node when they are allowed to vote.
After reviewing the code I see that in plus1.module in function theme_plus1_widget line 428:
elseif (user_access('vote on content')) {
// Is this the user's own content and do we allow them to vote on it?
if ($is_author && variable_get('plus1_vote_on_own', 1)) {
if ($vote_text = variable_get('plus1_vote', 'Vote')) {
// User is eligible to vote.
// The class name provided by Drupal.settings.plus1.vote_class what
// we will search for in our jQuery later.
$output_content .= '<form class="' . $vote_class . '" action="'
. url("plus1/vote/$node->nid",
array('query' => 'token=' . drupal_get_token($node->nid) . '&' . drupal_get_destination()))
. '" method="post"><div>';
$output_content .= '<button type="submit"><span>' . t(filter_xss_admin($vote_text)) . '</span></button>';
$author_text = variable_get('plus1_author_text', 'Your content');
if ($author_text) {
$output_content .= '<div class="plus1-author-text">' . t(filter_xss_admin($author_text)) . '</div>';
}
$output_content .= '</div></form>';
}
}
With condidion $is_author && variable_get('plus1_vote_on_own', 1)
button is noly rendered when user is author an athors can vote own content.
I changed this code for this and everything seems to work again:
elseif (user_access('vote on content')) {
// Is this the user's own content and do we allow them to vote on it?
if (!$is_author || ($is_author && variable_get('plus1_vote_on_own', 1))) {
$vote_text = variable_get('plus1_vote', 'Vote');
if ($vote_text) {
// User is eligible to vote.
// The class name provided by Drupal.settings.plus1.vote_class what
// we will search for in our jQuery later.
$output_content .= '<form class="' . $vote_class . '" action="'
. url("plus1/vote/$node->nid",
array('query' => 'token=' . drupal_get_token($node->nid) . '&' . drupal_get_destination()))
. '" method="post"><div>';
$output_content .= '<button type="submit"><span>' . t(filter_xss_admin($vote_text)) . '</span></button>';
$output_content .= '</div></form>';
}
}
else if($is_author && !variable_get('plus1_vote_on_own', 1)) {
$author_text = variable_get('plus1_author_text', 'Your content');
if ($author_text) {
$output_content .= '<div class="plus1-author-text">' . t(filter_xss_admin($author_text)) . '</div>';
}
}
}
Comment | File | Size | Author |
---|---|---|---|
#12 | plus1-only_author_vote-1067244-12.patch | 1.91 KB | pivica |
#11 | Bug? Plus 1 confused about the node ownership. | 66.5 KB | john.karahalis |
#4 | plus1-only_author_vote-1067244-4.patch | 990 bytes | jonathanpglick |
Comments
Comment #1
Code Rader CreditAttribution: Code Rader commentedYes, this is a critical bug. I didn't have authors enabled to vote so no one could vote on anything anymore. The above code works. It needs to be put into a patch though.
Comment #2
hamsterbacke42 CreditAttribution: hamsterbacke42 commentedThanks a lot for this solution, had the same problem and thought I was too stupid to set up the module correctly
Comment #3
saml CreditAttribution: saml commentedThanks for the patch jmpalomar! ... only that now there is a big "ugly" vote button instead of the up-arrow, that was used before ... but maybe one can find the old theming code again and use it ... I might try this ...
Comment #4
jonathanpglick CreditAttribution: jonathanpglick commentedI ran into this problem and the above changes worked for me. Attached is a patch of the changes so it'll hopefully be easier to get into the codebase.
Comment #5
codycraven CreditAttribution: codycraven commentedThis is ridiculously critical it completely breaks the module. The patch in #4 works fine.
Comment #6
NancyDruOkay. Do you know Git well enough to show me how?
Comment #7
codycraven CreditAttribution: codycraven commentedHere are the commands you need (this should all be listed for you here):
First create a clone from git:
Then (I don't think this step is necessary after a fresh clone but might as well do it since I'm not a git expert) ensure you are on the right branch.
Now apply your patch
Commit the changes
Push it back to the Drupal.org repository so it shows up on Drupal.org
Then to tag a release when ready, you would swap 8 in to [minor version here] since that would be the next version.
Comment #8
NancyDruThanks. Many years ago there was no such thing as a GUI. Everything was done by CLI. Then Microsoft and Apple convinced the world to switch to GUIs. I was one who switched. I'm not excited by going back to CLI. I have tried to install Tortoise GIT, but so far I seem to be missing something. Perhaps I need to remove Tortoise CVS first.
Comment #9
codycraven CreditAttribution: codycraven commentedI concur, seems like the Git GUIs I've used aren't exactly up to snuff with what's out there for CVS, SVN, or Mercurial.
Comment #10
davemybes CreditAttribution: davemybes commentedHi Nancy,
I use Tortoise Git, but you have to install msysgit as well (this file to be exact: http://code.google.com/p/msysgit/downloads/detail?name=Git-1.7.3.1-previ...). Then, in TortoiseGit, go to Settings and set the Git.exe path to where you installed msysgit (C:\Program Files (x86)\Git\bin in my case). That got it all working for me.
There is a 1.7.4 msysgit version, but its a beta, so I didn't use it.
Comment #11
john.karahalis CreditAttribution: john.karahalis commentedHey Nancy.
You shouldn't need to use git to apply the patch. Just drop the patch into the module directory and run
patch < plus1-only_author_vote-1067244-4.patch
. Of course, committing and pushing the result of the patch will require git.For the record, I don't know that this patch is perfect. It looks like it introduces a new bug regarding node ownership (see the screenshot). I did not see this bug in 2.6.
Comment #12
pivica CreditAttribution: pivica commentedHere is a new patch builded against latest dev release - reused patch from #4, changed comments a little bit and fixed problem in #11.
Comment #13
firebus CreditAttribution: firebus commentedthis patch works for me, and i'm not seeing any ownership issues (although it's not clear to me from #11 how to reproduce this issue...)
Comment #14
john.karahalis CreditAttribution: john.karahalis commentedFor #11, I did the following...
Steps:
Expected result:
Plus 1 does not indicate that the logged-in admin user owns the node.
Actual result:
Plus 1 does, mistakenly, indicate that the logged-in admin user owns the node.
Comment #15
firebus CreditAttribution: firebus commentedthanks john! i was unable to reproduce this error after applying the patch in #12. i tried both enabling and disabling the "Allow author to vote on own content:" field in case that had something to with it, and was unable to reproduce in either case.
Comment #16
vadim.eremeev CreditAttribution: vadim.eremeev commentedI just had the same bug, thanks for solution!
Comment #17
john.karahalis CreditAttribution: john.karahalis commentedAny guess on when this will be committed/pushed?
Comment #18
pavlosdan CreditAttribution: pavlosdan commentedpatch from #12 did the trick for me. many thanks
Comment #19
endless_wander CreditAttribution: endless_wander commentedPatch in 12 worked for me. Is there a way to post a link to this thread on the project's home page? It would have saved me an hour or so of troubleshooting.
Comment #20
NancyDruNote posted.
Comment #21
ezra-g CreditAttribution: ezra-g commented#12 functions as expected for me as well and look like the right code fix. Thanks!
Comment #22
valeria_gc CreditAttribution: valeria_gc commentedDid you find a solution for the "missing arrow"?
Thanx!
Comment #23
ezra-g CreditAttribution: ezra-g commentedThis is committed. Thanks!
http://drupalcode.org/project/plus1.git/commit/9392628
Comment #25
brad.bulger CreditAttribution: brad.bulger commentedit's kinda bad that this is still broken in the current main release. not what i think of as "actively maintained".