Posted by jmpalomar on February 20, 2011 at 12:20pm
17 followers
| Project: | Plus 1 |
| Version: | 6.x-2.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
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>';
}
}
}
Comments
#1
Yes, 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.
#2
Thanks a lot for this solution, had the same problem and thought I was too stupid to set up the module correctly
#3
Thanks 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 ...
#4
I 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.
#5
This is ridiculously critical it completely breaks the module. The patch in #4 works fine.
#6
Okay. Do you know Git well enough to show me how?
#7
Here are the commands you need (this should all be listed for you here):
First create a clone from git:
git clone --branch 6.x-2.x http://git.drupal.org/project/plus1.gitcd plus1
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.
git checkout --track origin/6.x-2.xgit pull origin 6.x-2.x
Now apply your patch
git apply [patch.name]rm [patch.name]
Commit the changes
git add -Agit commit -m "Issue #[issue number] by [comma-separated usernames]: [Short summary of the change]."
Push it back to the Drupal.org repository so it shows up on Drupal.org
git push origin 6.x-2.xThen to tag a release when ready, you would swap 8 in to [minor version here] since that would be the next version.
git checkout 6.x-2.xgit tag 6.x-2.[minor version here]
git push origin 6.x-2.[minor version here]
#8
Thanks. 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.
#9
I 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.
#10
Hi 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.
#11
Hey 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.
#12
Here is a new patch builded against latest dev release - reused patch from #4, changed comments a little bit and fixed problem in #11.
#13
this 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...)
#14
For #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.
#15
thanks 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.
#16
I just had the same bug, thanks for solution!
#17
Any guess on when this will be committed/pushed?
#18
patch from #12 did the trick for me. many thanks
#19
Patch 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.
#20
Note posted.
#21
#12 functions as expected for me as well and look like the right code fix. Thanks!
#22
Did you find a solution for the "missing arrow"?
Thanx!
#23
This is committed. Thanks!
http://drupalcode.org/project/plus1.git/commit/9392628
#24
Automatically closed -- issue fixed for 2 weeks with no activity.