Users running a non-download version of Vanilla (pulled from github), on branch release/2019.016 or master from the last 2 weeks should upgrade to release/2019.017 or latest master for security reasons. Downloaded official open sources releases are not affected.
Please upgrade here. These earlier versions are no longer being updated and have security issues.

[Solved] KarmaBank and I Like This: consecutive "Likes" not being counted

This discussion is related to the Karma Bank addon.
50sQuiff50sQuiff ✭✭
edited April 2013 in Vanilla 2.0 - 2.8

Hi @x00 and others. I've installed "I Like This" and KarmaBank to create a basic reputation system for my forum. Here's what happens:

  1. Logged in as User A, I Like a post by User B. The number of Likes associated with the post increases by 1.
  2. User B's Karma balance only increases when I log in as User B and/or reload a page. I presume this is related to some caching process.

I can repeat 1 and 2 as many times as I like and it works fine. But here is where the problem lies:

  1. Logged in as User A, I Like a post by User B. The number of Likes associated with the post increases by 1.
  2. Logged in as User A, I Like a different post by User B. The number of Likes associated with that post increases by 1.
  3. User B refreshes the page but his Karma only increases by 1.

Is there a way for me to fix this? Is it a simple rules issue? I'm currently using diffequals with values of 1.0 and 1.0.

Regards,
Quiff

Comments

  • 50sQuiff50sQuiff ✭✭
    edited October 2012

    OK, it seems like I've fixed it with a hack. I replaced the line

    $KarmaBank->Transaction($Type,$Rule->Amount,$Value,$RuleID);

    With

    $LikeAmount = $Value - $TallyValue; $KarmaBank->Transaction($Type,$LikeAmount,$Value,$RuleID);

  • no don't that. Try changing

        public static function OperationDiffEquals($MetaValue,$Target,$Condition,$User,$LastTrans,$Option){
            $Difference=$MetaValue-($LastTrans ? $LastTrans->LastTally : 0);
            if($Difference && abs($Difference)%$Target!==0)
                return FALSE;
            return abs($Difference)!= $Difference? -1:1;
        }
    

    to

        public static function OperationDiffEquals($MetaValue,$Target,$Condition,$User,$LastTrans,$Option){
            $Difference=$MetaValue-($LastTrans ? $LastTrans->LastTally : 0);
            if($Difference && abs($Difference)%$Target!==0)
                return FALSE;
            return $Difference;
        } 
    

    that way other things won't get broken

    grep is your friend.

    50sQuiffkirkpa31Srggamer
  • Thank you, that works.

  • kirkpa31kirkpa31 ✭✭
    edited April 2013

    EDIT - Problem Solved

    I solved it - your solution does work. Thank you @x00! I must've typed something incorrectly in my first attempt.

Sign In or Register to comment.