Fixed like counter issues
authorMarcel Werk <burntime@woltlab.com>
Sun, 24 Nov 2013 14:05:19 +0000 (15:05 +0100)
committerMarcel Werk <burntime@woltlab.com>
Sun, 24 Nov 2013 14:05:19 +0000 (15:05 +0100)
wcfsetup/install/files/lib/system/like/LikeHandler.class.php

index dd2d848696a4fc6e95938580491fa158a426b07a..3cab98584c2cd22f245f3621d1fc916bc940a59c 100644 (file)
@@ -294,7 +294,10 @@ class LikeHandler extends SingletonFactory {
                                        'likeValue' => $likeValue
                                ));
                                
-                               if ($likeValue == Like::DISLIKE) UserActivityPointHandler::getInstance()->removeEvents('com.woltlab.wcf.like.activityPointEvent.receivedLikes', array($user->userID => 1));
+                               if ($likeable->getUserID()) {
+                                       if ($likeValue == Like::DISLIKE) UserActivityPointHandler::getInstance()->removeEvents('com.woltlab.wcf.like.activityPointEvent.receivedLikes', array($likeable->getUserID() => 1));
+                                       else UserActivityPointHandler::getInstance()->fireEvent('com.woltlab.wcf.like.activityPointEvent.receivedLikes', $like->likeID, $likeable->getUserID());
+                               }
                        }
                        
                        // update object's like counter
@@ -320,7 +323,7 @@ class LikeHandler extends SingletonFactory {
         * 
         * @param       \wcf\data\like\Like                     $like
         * @param       \wcf\data\like\object\ILikeObject       $likeable
-        * @param       \wcf\data\like\object\LikeObject                $likeObject
+        * @param       \wcf\data\like\object\LikeObject        $likeObject
         * @param       \wcf\data\user\User                     $user
         * @return      array
         */
@@ -381,9 +384,9 @@ class LikeHandler extends SingletonFactory {
                                        $userEditor->updateCounters(array(
                                                'likesReceived' => -1
                                        ));
+                                       
+                                       UserActivityPointHandler::getInstance()->removeEvents('com.woltlab.wcf.like.activityPointEvent.receivedLikes', array($likeable->getUserID() => 1));
                                }
-                               
-                               UserActivityPointHandler::getInstance()->removeEvents('com.woltlab.wcf.like.activityPointEvent.receivedLikes', array($likeable->getUserID() => 1));
                        }
                        
                        // update object's like counter