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>';
        }
    }
  }
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Code Rader’s picture

Component: User interface » Code

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.

hamsterbacke42’s picture

Thanks a lot for this solution, had the same problem and thought I was too stupid to set up the module correctly

saml’s picture

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 ...

jonathanpglick’s picture

Status: Active » Needs review
FileSize
990 bytes

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.

codycraven’s picture

Status: Needs review » Reviewed & tested by the community

This is ridiculously critical it completely breaks the module. The patch in #4 works fine.

NancyDru’s picture

Okay. Do you know Git well enough to show me how?

codycraven’s picture

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.git
cd 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.x
git pull origin 6.x-2.x

Now apply your patch

git apply [patch.name]
rm  [patch.name]

Commit the changes

git add -A
git 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.x

Then 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.x
git tag 6.x-2.[minor version here]
git push origin 6.x-2.[minor version here]
NancyDru’s picture

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.

codycraven’s picture

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.

davemybes’s picture

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.

john.karahalis’s picture

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.

pivica’s picture

Version: 6.x-2.7 » 6.x-2.x-dev
Status: Reviewed & tested by the community » Needs review
FileSize
1.91 KB

Here is a new patch builded against latest dev release - reused patch from #4, changed comments a little bit and fixed problem in #11.

firebus’s picture

Status: Needs review » Reviewed & tested by the community

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...)

john.karahalis’s picture

For #11, I did the following...

Steps:

  1. Set some content type, say the "Story" content type, to be votable.
  2. Log in with user John and create a Story node.
  3. Log in with user admin and view the newly-created Story node.

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.

firebus’s picture

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.

vadim.eremeev’s picture

I just had the same bug, thanks for solution!

john.karahalis’s picture

Any guess on when this will be committed/pushed?

pavlosdan’s picture

patch from #12 did the trick for me. many thanks

endless_wander’s picture

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.

NancyDru’s picture

Note posted.

ezra-g’s picture

#12 functions as expected for me as well and look like the right code fix. Thanks!

valeria_gc’s picture

Did you find a solution for the "missing arrow"?

Thanx!

ezra-g’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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

brad.bulger’s picture

it's kinda bad that this is still broken in the current main release. not what i think of as "actively maintained".