Fork me on GitHub
Current releases are 2.1 (gold) and 2.0.18.11 (security patch for 2.0)
Ready for 2.1? Find out if your favorite plugins are compatible.
The 2.0 branch will no longer receive updates after Dec 2014.

There are some minor bugs with this plugin*

edited August 2011 in Feedback
This discussion is related to the Voting addon.
If there is a comment with 2 vote, you can click up to increase it to 3. Then click up again resets it to 0, click again, sets it to 1, again to 2, and again back to 3.

Needs improvement.
Tagged:

Answers

  • I don't have this bug. Which version of Vanilla do you use?
  • BboyHavocBboyHavoc New
    edited April 2012

    In the class.voting.plugin.php file, replace the content around line 249-268 with this...hopefully that helps. Took me a few hours to figure it out =P:

    $CommentID = GetValue(0, $Sender->RequestArgs, 0);
          $VoteType = GetValue(1, $Sender->RequestArgs);
          $TransientKey = GetValue(2, $Sender->RequestArgs);
          $Session = Gdn::Session();
          $OriginalScore = $Object->Score;
          $FinalVote = 0;
          $Total = 0;
          if ($Session->IsValid() && $Session->ValidateTransientKey($TransientKey) && $CommentID > 0) {
             $CommentModel = new CommentModel();
             $OldUserVote = $CommentModel->GetUserScore($CommentID, $Session->UserID);
             $NewUserVote = $VoteType == 'voteup' ? 1 : -1; //if voteup then $NewUserVote = 1 else -1
             $FinalVote = intval($OldUserVote) + intval($NewUserVote);
             // Allow admins to vote unlimited.
             $AllowVote = $Session->CheckPermission('Garden.Moderation.Manage');
             // Only allow users to vote up or down by 1.
             if (!$AllowVote && ($FinalVote > -2 && $FinalVote < 2)){
                $AllowVote = true;
             }else {
                $AllowVote = false;
             }
    
             if ($AllowVote){
                $Total = $CommentModel->SetUserScore($CommentID, $Session->UserID, $FinalVote);
             }else {
                $FinalFinalVote = $OriginalScore + $OldUserVote;
                $Total = $CommentModel->SetUserScore($CommentID, $Session->UserID, $FinalFinalVote);
             }
    
    mattcharliepratt
  • 422422 Developer MVP

    another bug is the missing loading.gif

    422 Real Estate Australia , now open Check it out

    UnderDog
Sign In or Register to comment.