Determine legacy reaction types for likes
authorJoshua Rüsweg <josh@bastelstu.be>
Thu, 2 Aug 2018 10:12:25 +0000 (12:12 +0200)
committerJoshua Rüsweg <josh@bastelstu.be>
Thu, 2 Aug 2018 10:12:25 +0000 (12:12 +0200)
See #2508

wcfsetup/install/files/lib/system/reaction/ReactionHandler.class.php

index b62f1c666a6ec131c659ef4daa2294d069590bf3..a21caa378cb9b04b129bbc56def4cb11b81f0148 100644 (file)
@@ -751,14 +751,27 @@ class ReactionHandler extends SingletonFactory {
         * @return      integer|null
         */
        public function getLegacyReactionTypeID($type) {
-               // @TODO determine real values
+               $reactionTypes = ReactionTypeCache::getInstance()->getEnabledReactionTypes();
+               ReactionType::sort($reactionTypes, 'showOrder');
                switch ($type) {
                        case ReactionType::REACTION_TYPE_POSITIVE: 
-                               return 2; 
+                               foreach ($reactionTypes as $reactionType) {
+                                       if ($reactionType->isPositive()) {
+                                               return $reactionType->reactionTypeID;
+                                       }
+                               }
+                               
+                               return null; 
                                
                        case ReactionType::REACTION_TYPE_NEGATIVE:
-                               return 1;
+                               foreach ($reactionTypes as $reactionType) {
+                                       if ($reactionType->isNegative()) {
+                                               return $reactionType->reactionTypeID;
+                                       }
+                               }
                                
+                               return null;
+                       
                        default: 
                                throw new \LogicException('Invalid type given.');
                }