HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

There are some minor bugs with this plugin*

edited August 2011 in Feedback
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

  • the latest beta.
  • 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);
             }
    
  • another bug is the missing loading.gif

    There was an error rendering this rich post.

Sign In or Register to comment.