Removed the rating of reactions
authorAlexander Ebert <ebert@woltlab.com>
Mon, 15 Jul 2019 16:06:36 +0000 (18:06 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 15 Jul 2019 16:06:36 +0000 (18:06 +0200)
See #2975

22 files changed:
com.woltlab.wcf/objectType.xml
com.woltlab.wcf/templates/messageSidebar.tpl
com.woltlab.wcf/templates/userInformationStatistics.tpl
wcfsetup/install/files/acp/update-com.woltlab.wcf_3.2_reactionUpdate.php
wcfsetup/install/files/lib/acp/form/ReactionTypeAddForm.class.php
wcfsetup/install/files/lib/data/article/ViewableArticleList.class.php
wcfsetup/install/files/lib/data/like/Like.class.php
wcfsetup/install/files/lib/data/like/object/LikeObject.class.php
wcfsetup/install/files/lib/data/reaction/ReactionAction.class.php
wcfsetup/install/files/lib/data/reaction/type/ReactionType.class.php
wcfsetup/install/files/lib/page/MembersListPage.class.php
wcfsetup/install/files/lib/system/condition/UserReputationCondition.class.php
wcfsetup/install/files/lib/system/importer/AbstractLikeImporter.class.php
wcfsetup/install/files/lib/system/like/LikeHandler.class.php
wcfsetup/install/files/lib/system/reaction/ReactionHandler.class.php
wcfsetup/install/files/lib/system/stat/DislikeStatDailyHandler.class.php [deleted file]
wcfsetup/install/files/lib/system/stat/LikeStatDailyHandler.class.php
wcfsetup/install/files/lib/system/worker/LikeRebuildDataWorker.class.php
wcfsetup/install/files/lib/system/worker/UserRebuildDataWorker.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml
wcfsetup/setup/db/install.sql

index d6bc997d97ee111e3099b2248b85e89735c90538..138f01e52585730f8fc501688885d0d9d0d19b35 100644 (file)
                        <classname>wcf\system\stat\LikeStatDailyHandler</classname>
                        <categoryname>com.woltlab.wcf.user</categoryname>
                </type>
-               <type>
-                       <name>com.woltlab.wcf.dislike</name>
-                       <definitionname>com.woltlab.wcf.statDailyHandler</definitionname>
-                       <classname>wcf\system\stat\DislikeStatDailyHandler</classname>
-                       <categoryname>com.woltlab.wcf.user</categoryname>
-               </type>
                <type>
                        <name>com.woltlab.wcf.userProfileComment</name>
                        <definitionname>com.woltlab.wcf.statDailyHandler</definitionname>
                        <definitionname>com.woltlab.wcf.condition.userGroupAssignment</definitionname>
                        <classname>wcf\system\condition\UserIntegerPropertyCondition</classname>
                        <conditiongroup>contents</conditiongroup>
-                       <propertyname>positiveReactionsReceived</propertyname>
-                       <minvalue>0</minvalue>
-               </type>
-               <type>
-                       <name>com.woltlab.wcf.negativeReactionsReceived</name>
-                       <definitionname>com.woltlab.wcf.condition.userGroupAssignment</definitionname>
-                       <classname>wcf\system\condition\UserIntegerPropertyCondition</classname>
-                       <conditiongroup>contents</conditiongroup>
-                       <propertyname>negativeReactionsReceived</propertyname>
-                       <minvalue>0</minvalue>
-               </type>
-               <type>
-                       <name>com.woltlab.wcf.neutralReactionsReceived</name>
-                       <definitionname>com.woltlab.wcf.condition.userGroupAssignment</definitionname>
-                       <classname>wcf\system\condition\UserIntegerPropertyCondition</classname>
-                       <conditiongroup>contents</conditiongroup>
-                       <propertyname>neutralReactionsReceived</propertyname>
+                       <propertyname>likesReceived</propertyname>
                        <minvalue>0</minvalue>
                </type>
                <type>
                        <definitionname>com.woltlab.wcf.condition.trophy</definitionname>
                        <classname>wcf\system\condition\UserIntegerPropertyCondition</classname>
                        <conditiongroup>contents</conditiongroup>
-                       <propertyname>positiveReactionsReceived</propertyname>
-                       <minvalue>0</minvalue>
-               </type>
-               <type>
-                       <name>com.woltlab.wcf.negativeReactionsReceived</name>
-                       <definitionname>com.woltlab.wcf.condition.trophy</definitionname>
-                       <classname>wcf\system\condition\UserIntegerPropertyCondition</classname>
-                       <conditiongroup>contents</conditiongroup>
-                       <propertyname>negativeReactionsReceived</propertyname>
-                       <minvalue>0</minvalue>
-               </type>
-               <type>
-                       <name>com.woltlab.wcf.neutralReactionsReceived</name>
-                       <definitionname>com.woltlab.wcf.condition.trophy</definitionname>
-                       <classname>wcf\system\condition\UserIntegerPropertyCondition</classname>
-                       <conditiongroup>contents</conditiongroup>
-                       <propertyname>neutralReactionsReceived</propertyname>
+                       <propertyname>likesReceived</propertyname>
                        <minvalue>0</minvalue>
                </type>
                <type>
                        <classname>wcf\system\condition\UserIntegerPropertyCondition</classname>
                        <conditionobject>com.woltlab.wcf.user</conditionobject>
                        <conditiongroup>contents</conditiongroup>
-                       <propertyname>positiveReactionsReceived</propertyname>
-                       <minvalue>0</minvalue>
-               </type>
-               <type>
-                       <name>com.woltlab.wcf.negativeReactionsReceived</name>
-                       <definitionname>com.woltlab.wcf.condition.notice</definitionname>
-                       <classname>wcf\system\condition\UserIntegerPropertyCondition</classname>
-                       <conditionobject>com.woltlab.wcf.user</conditionobject>
-                       <conditiongroup>contents</conditiongroup>
-                       <propertyname>negativeReactionsReceived</propertyname>
-                       <minvalue>0</minvalue>
-               </type>
-               <type>
-                       <name>com.woltlab.wcf.neutralReactionsReceived</name>
-                       <definitionname>com.woltlab.wcf.condition.notice</definitionname>
-                       <classname>wcf\system\condition\UserIntegerPropertyCondition</classname>
-                       <conditionobject>com.woltlab.wcf.user</conditionobject>
-                       <conditiongroup>contents</conditiongroup>
-                       <propertyname>neutralReactionsReceived</propertyname>
+                       <propertyname>likesReceived</propertyname>
                        <minvalue>0</minvalue>
                </type>
                <type>
                        <classname>wcf\system\condition\UserIntegerPropertyCondition</classname>
                        <conditionobject>com.woltlab.wcf.user</conditionobject>
                        <conditiongroup>contents</conditiongroup>
-                       <propertyname>positiveReactionsReceived</propertyname>
-                       <minvalue>0</minvalue>
-               </type>
-               <type>
-                       <name>com.woltlab.wcf.negativeReactionsReceived</name>
-                       <definitionname>com.woltlab.wcf.condition.ad</definitionname>
-                       <classname>wcf\system\condition\UserIntegerPropertyCondition</classname>
-                       <conditionobject>com.woltlab.wcf.user</conditionobject>
-                       <conditiongroup>contents</conditiongroup>
-                       <propertyname>negativeReactionsReceived</propertyname>
-                       <minvalue>0</minvalue>
-               </type>
-               <type>
-                       <name>com.woltlab.wcf.neutralReactionsReceived</name>
-                       <definitionname>com.woltlab.wcf.condition.ad</definitionname>
-                       <classname>wcf\system\condition\UserIntegerPropertyCondition</classname>
-                       <conditionobject>com.woltlab.wcf.user</conditionobject>
-                       <conditiongroup>contents</conditiongroup>
-                       <propertyname>neutralReactionsReceived</propertyname>
+                       <propertyname>likesReceived</propertyname>
                        <minvalue>0</minvalue>
                </type>
                <type>
                        <definitionname>com.woltlab.wcf.bulkProcessing.user.condition</definitionname>
                        <classname>wcf\system\condition\UserIntegerPropertyCondition</classname>
                        <conditiongroup>contents</conditiongroup>
-                       <propertyname>positiveReactionsReceived</propertyname>
-                       <minvalue>0</minvalue>
-               </type>
-               <type>
-                       <name>com.woltlab.wcf.negativeReactionsReceived</name>
-                       <definitionname>com.woltlab.wcf.bulkProcessing.user.condition</definitionname>
-                       <classname>wcf\system\condition\UserIntegerPropertyCondition</classname>
-                       <conditiongroup>contents</conditiongroup>
-                       <propertyname>negativeReactionsReceived</propertyname>
-                       <minvalue>0</minvalue>
-               </type>
-               <type>
-                       <name>com.woltlab.wcf.neutralReactionsReceived</name>
-                       <definitionname>com.woltlab.wcf.bulkProcessing.user.condition</definitionname>
-                       <classname>wcf\system\condition\UserIntegerPropertyCondition</classname>
-                       <conditiongroup>contents</conditiongroup>
-                       <propertyname>neutralReactionsReceived</propertyname>
+                       <propertyname>likesReceived</propertyname>
                        <minvalue>0</minvalue>
                </type>
                <type>
                        <definitionname>com.woltlab.wcf.condition.userSearch</definitionname>
                        <classname>wcf\system\condition\UserIntegerPropertyCondition</classname>
                        <conditiongroup>contents</conditiongroup>
-                       <propertyname>positiveReactionsReceived</propertyname>
-                       <minvalue>0</minvalue>
-               </type>
-               <type>
-                       <name>com.woltlab.wcf.negativeReactionsReceived</name>
-                       <definitionname>com.woltlab.wcf.condition.userSearch</definitionname>
-                       <classname>wcf\system\condition\UserIntegerPropertyCondition</classname>
-                       <conditiongroup>contents</conditiongroup>
-                       <propertyname>negativeReactionsReceived</propertyname>
-                       <minvalue>0</minvalue>
-               </type>
-               <type>
-                       <name>com.woltlab.wcf.neutralReactionsReceived</name>
-                       <definitionname>com.woltlab.wcf.condition.userSearch</definitionname>
-                       <classname>wcf\system\condition\UserIntegerPropertyCondition</classname>
-                       <conditiongroup>contents</conditiongroup>
-                       <propertyname>neutralReactionsReceived</propertyname>
+                       <propertyname>likesReceived</propertyname>
                        <minvalue>0</minvalue>
                </type>
                <type>
index 7737777e4f529667275e5426c10eb426530c737e..aeac425de8b9f9f84c024e97d40c53bfd1526e76 100644 (file)
@@ -82,9 +82,8 @@
                                        <dl class="plain dataList">
                                                {content}
                                                        {if MODULE_LIKE && MESSAGE_SIDEBAR_ENABLE_LIKES_RECEIVED && !$isReply}
-                                                               {assign var=overallReactionCount value=$userProfile->positiveReactionsReceived - $userProfile->negativeReactionsReceived}
                                                                <dt><a href="{link controller='User' object=$userProfile}{/link}#likes" class="jsTooltip" title="{lang user=$userProfile}wcf.like.showLikesReceived{/lang}">{lang}wcf.like.likesReceived{/lang}</a></dt>
-                                                               <dd>{#$overallReactionCount}</dd>
+                                                               <dd>{#$userProfile->cumulativeLikes}</dd>
                                                        {/if}
                                                        
                                                        {if MESSAGE_SIDEBAR_ENABLE_ACTIVITY_POINTS && $userProfile->activityPoints}
index a5fd11537848e38be44ca242bb9c2a543bec0917..df4d9a92cfa93a8ccd0916bee7203f6def1574ef 100644 (file)
@@ -2,12 +2,9 @@
 
 {event name='statistics'}
 
-{if MODULE_LIKE}
-       {assign var=reactionReputation value=$user->positiveReactionsReceived - $user->negativeReactionsReceived}
-       {if $reactionReputation}
-               <dt>{if $__wcf->getSession()->getPermission('user.profile.canViewUserProfile') && !$user->isProtected()}<a href="{link controller='User' object=$user}{/link}#likes" class="jsTooltip" title="{lang}wcf.like.showLikesReceived{/lang}">{lang}wcf.like.reputation{/lang}</a>{else}{lang}wcf.like.reputation{/lang}{/if}</dt>
-               <dd>{#$reactionReputation}</dd>
-       {/if}
+{if MODULE_LIKE && $user->cumulativeLikes}
+       <dt>{if $__wcf->getSession()->getPermission('user.profile.canViewUserProfile') && !$user->isProtected()}<a href="{link controller='User' object=$user}{/link}#likes" class="jsTooltip" title="{lang}wcf.like.showLikesReceived{/lang}">{lang}wcf.like.reputation{/lang}</a>{else}{lang}wcf.like.reputation{/lang}{/if}</dt>
+       <dd>{#$user->cumulativeLikes}</dd>
 {/if}
 
 {if $user->activityPoints}
index 18069c303e6346347fb5c3e1e4a800244ed8d308..915ea281494196031c3853ccb62e6d9cf7dd169a 100644 (file)
@@ -25,36 +25,30 @@ try {
        WCF::getDB()->beginTransaction();
        
        $reactionTypes = <<<DATA
-('wcf.reactionType.title1', 1, 1, 'like.svg'), 
-('wcf.reactionType.title2', 1, 2, 'haha.svg'), 
-('wcf.reactionType.title3', -1, 3, 'sad.svg'),
-('wcf.reactionType.title4', 0, 4, 'confused.svg'),
-('wcf.reactionType.title5', 1, 5, 'thanks.svg'),
+('wcf.reactionType.title1', 1, 'like.svg'), 
+('wcf.reactionType.title2', 2, 'haha.svg'), 
+('wcf.reactionType.title3', 3, 'sad.svg'),
+('wcf.reactionType.title4', 4, 'confused.svg'),
+('wcf.reactionType.title5', 5, 'thanks.svg'),
 DATA;
        
        // add reaction columns 
-       $statement = WCF::getDB()->prepareStatement(str_replace('wcf1_', 'wcf'.WCF_N.'_', 'INSERT INTO wcf1_reaction_type (title, type, showOrder, iconFile) VALUES '. $reactionTypes));
+       $statement = WCF::getDB()->prepareStatement('INSERT INTO wcf'.WCF_N.'_reaction_type (title, showOrder, iconFile) VALUES '. $reactionTypes);
        $statement->execute();
        
        // update current likes 
-       $sql = "UPDATE wcf1_like SET reactionTypeID = ? WHERE likeValue = ?";
-       $statement = WCF::getDB()->prepareStatement(str_replace('wcf1_', 'wcf'.WCF_N.'_', $sql));
-       
+       $sql = "UPDATE wcf".WCF_N."_like SET reactionTypeID = ? WHERE likeValue = ?";
+       $statement = WCF::getDB()->prepareStatement($sql);
        $statement->execute([
                Like::LIKE,
                1
        ]);
-       $statement->execute([
-               Like::DISLIKE,
-               3
-       ]);
        
-       // delete outdated likes, which aren't likes nor dislikes (normally none should exist)
-       $sql = "DELETE FROM wcf1_like WHERE reactionTypeID = 0";
-       $statement = WCF::getDB()->prepareStatement(str_replace('wcf1_', 'wcf'.WCF_N.'_', $sql));
+       // Delete outdated or unsupported likes.
+       WCF::getDB()->prepareStatement("DELETE FROM wcf".WCF_N."_like WHERE reactionTypeID = 0")->execute();
        
        // add foreign key  
-       $statement = WCF::getDB()->prepareStatement(str_replace('wcf1_', 'wcf'.WCF_N.'_', 'ALTER TABLE wcf1_like ADD FOREIGN KEY (reactionTypeID) REFERENCES wcf1_reaction_type (reactionTypeID) ON DELETE CASCADE'));
+       $statement = WCF::getDB()->prepareStatement('ALTER TABLE wcf'.WCF_N.'_like ADD FOREIGN KEY (reactionTypeID) REFERENCES wcf1_reaction_type (reactionTypeID) ON DELETE CASCADE');
        $statement->execute();
        
        WCF::getDB()->commitTransaction();
index dce9282938fc90a0d231d3dce841aa1e1e5bf75f..62b704c43688d4065fc402ee4d6557edf2eb85ff 100644 (file)
@@ -60,15 +60,6 @@ class ReactionTypeAddForm extends AbstractFormBuilderForm {
                                        ->maximumLength(255)
                                        ->i18n()
                                        ->languageItemPattern('wcf.reactionType.title\d+'),
-                               RadioButtonFormField::create('type')
-                                       ->label('wcf.acp.reactionType.type')
-                                       ->required()
-                                       ->options([
-                                               ReactionType::REACTION_TYPE_POSITIVE => 'wcf.acp.reactionType.type.positive',
-                                               ReactionType::REACTION_TYPE_NEUTRAL => 'wcf.acp.reactionType.type.neutral',
-                                               ReactionType::REACTION_TYPE_NEGATIVE => 'wcf.acp.reactionType.type.negative'
-                                       ])
-                                       ->value(ReactionType::REACTION_TYPE_POSITIVE),
                                ShowOrderFormField::create()
                                        ->description('wcf.acp.reactionType.showOrder.description')
                                        ->required()
index bb18a65639f6adc13b0dd98bdc4ea025f60012ef..de8231b9402ca5a6eaff5a83c85f61b55a8df310 100644 (file)
@@ -3,7 +3,6 @@ namespace wcf\data\article;
 use wcf\data\article\content\ViewableArticleContentList;
 use wcf\system\cache\runtime\UserProfileRuntimeCache;
 use wcf\system\label\object\ArticleLabelObjectHandler;
-use wcf\system\reaction\ReactionHandler;
 use wcf\system\visitTracker\VisitTracker;
 use wcf\system\WCF;
 
@@ -45,11 +44,6 @@ class ViewableArticleList extends ArticleList {
                        $this->sqlSelects .= 'tracked_visit.visitTime';
                        $this->sqlJoins .= " LEFT JOIN wcf".WCF_N."_tracked_visit tracked_visit ON (tracked_visit.objectTypeID = ".VisitTracker::getInstance()->getObjectTypeID('com.woltlab.wcf.article')." AND tracked_visit.objectID = article.articleID AND tracked_visit.userID = ".WCF::getUser()->userID.")";
                }
-               
-               // get like status
-               if (!empty($this->sqlSelects)) $this->sqlSelects .= ',';
-               $this->sqlSelects .= "like_object.likes, like_object.dislikes, like_object.neutralReactions";
-               $this->sqlJoins .= " LEFT JOIN wcf".WCF_N."_like_object like_object ON (like_object.objectTypeID = ".ReactionHandler::getInstance()->getObjectType('com.woltlab.wcf.likeableArticle')->objectTypeID." AND like_object.objectID = article.articleID)";
        }
        
        /**
index be6e5c7c4af8251cb695ba77a811fa162d5bfa34..f5a7143d61c7256ba765e4512fc7b9768b17da55 100644 (file)
@@ -72,26 +72,6 @@ class Like extends DatabaseObject {
                return 'like_table';
        }
        
-       /**
-        * Returns true, if like value is a like.
-        * 
-        * @return      boolean
-        * @deprecated  5.2
-        */
-       public function isLike() {
-               return $this->getReactionType()->isPositive();
-       }
-       
-       /**
-        * Returns true, if like value is a dislike.
-        * 
-        * @return      boolean
-        * @deprecated  5.2
-        */
-       public function isDislike() {
-               return $this->getReactionType()->isNegative();
-       }
-       
        /**
         * Returns the reaction for these like. 
         * 
index e713a16b6b4bb8a1e592140b6d7c28f514b18ded..4d643b922ce489cbbeccf3baf8a9e36304271d0c 100644 (file)
@@ -4,7 +4,6 @@ use wcf\data\object\type\ObjectTypeCache;
 use wcf\data\reaction\type\ReactionTypeCache;
 use wcf\data\user\User;
 use wcf\data\DatabaseObject;
-use wcf\system\reaction\ReactionHandler;
 use wcf\system\WCF;
 use wcf\util\JSON;
 
@@ -21,9 +20,8 @@ use wcf\util\JSON;
  * @property-read      integer         $objectID               id of the liked object
  * @property-read      integer|null    $objectUserID           id of the user who created the liked object or null if user has been deleted or object was created by guest
  * @property-read      integer         $likes                  number of likes of the liked object
- * @property-read      integer         $dislikes               number of dislikes of the liked object
- * @property-read      integer         $neutralReactions       number of neutral reactions on the liked object
- * @property-read      integer         $cumulativeLikes        cumulative result of likes (counting +1) and dislikes (counting -1)
+ * @property-read      integer         $dislikes               legacy column, not used anymore
+ * @property-read      integer         $cumulativeLikes        number of likes of the liked object
  * @property-read      string          $cachedUsers            serialized array with the ids and names of the three users who liked (+1) the object last
  * @property-read      string          $cachedReactions        serialized array with the reactionTypeIDs and the count of the reactions
  */
@@ -151,30 +149,6 @@ class LikeObject extends DatabaseObject {
                return $this->reactions; 
        }
        
-       /**
-        * Returns the reputation of the current like object. Returns null, if
-        * there are no reactions on the object. 
-        * 
-        * @return      integer|null
-        * @since       5.2
-        */
-       public function getReputation() {
-               if ($this->reputation === null && !empty($this->getReactions())) {
-                       $this->reputation = 0;
-                       foreach ($this->getReactions() as $reactionTypeID => $data) {
-                               $reactionType = ReactionHandler::getInstance()->getReactionTypeByID($reactionTypeID);
-                               if ($reactionType->isPositive()) {
-                                       $this->reputation += $data['reactionCount'];
-                               }
-                               else if ($reactionType->isNegative()) {
-                                       $this->reputation -= $data['reactionCount'];
-                               }
-                       }
-               }
-               
-               return $this->reputation;
-       }
-       
        /**
         * Sets the liked object.
         * 
index 50fe922e393f4e987ed4837431c195e4f2506d4c..4d729ec359edb882924e91be2361b2ea4b34fbc0 100644 (file)
@@ -319,49 +319,25 @@ class ReactionAction extends AbstractDatabaseObjectAction {
                //
                
                if ($newLikeObject->objectUserID) {
-                       $sql = "SELECT  COUNT(*) as count, like_table.reactionTypeID
-                               FROM    wcf".WCF_N."_like like_table
-                               WHERE   like_table.objectTypeID = ?
-                                       AND like_table.objectID = ?
-                               GROUP BY like_table.reactionTypeID";
+                       $sql = "SELECT  COUNT(*) as count
+                               FROM    wcf".WCF_N."_like
+                               WHERE   objectTypeID = ?
+                                       AND objectID = ?";
                        $statement = WCF::getDB()->prepareStatement($sql);
                        $statement->execute([
                                $targetObjectType->objectTypeID,
                                $this->parameters['targetObjectID']
                        ]);
-                       
-                       $updateValues = [
-                               'positive' => 0,
-                               'neutral' => 0, 
-                               'negative' => 0
-                       ];
-                       while ($row = $statement->fetchArray()) {
-                               $reactionType = ReactionTypeCache::getInstance()->getReactionTypeByID($row['reactionTypeID']);
-                               
-                               if (!$reactionType->isDisabled) {
-                                       if ($reactionType->isPositive()) {
-                                               $updateValues['positive'] += $row['count'];
-                                       }
-                                       else if ($reactionType->isNegative()) {
-                                               $updateValues['negative'] += $row['count'];
-                                       }
-                                       else if ($reactionType->isNeutral()) {
-                                               $updateValues['neutral'] += $row['count'];
-                                       }
-                               }
-                       }
+                       $count = $statement->fetchSingleColumn();
                        
                        // update received likes
                        $userEditor = new UserEditor(new User($newLikeObject->objectUserID));
                        $userEditor->updateCounters([
-                               'likesReceived' => $updateValues['positive'],
-                               'positiveReactionsReceived' => $updateValues['positive'],
-                               'negativeReactionsReceived' => $updateValues['negative'],
-                               'neutralReactionsReceived' => $updateValues['neutral']
+                               'likesReceived' => $count,
                        ]);
                        
                        // add activity points
-                       UserActivityPointHandler::getInstance()->fireEvents('com.woltlab.wcf.like.activityPointEvent.receivedLikes', [$newLikeObject->objectUserID => $updateValues['positive']]);
+                       UserActivityPointHandler::getInstance()->fireEvents('com.woltlab.wcf.like.activityPointEvent.receivedLikes', [$newLikeObject->objectUserID => $count]);
                }
        }
 }
index 8d1420447919fb77e38b03fb5c918e3b6cb1e481..771d841a1f2afd5144ff3ce66165b7d83824762a 100644 (file)
@@ -15,30 +15,11 @@ use wcf\system\WCF;
  *
  * @property-read      integer         $reactionTypeID         unique id of the reaction type
  * @property-read      string          $title
- * @property-read      integer         $type                   type of the reaction (1 is positive, 0 is neutral and -1 is negative)
  * @property-read      integer         $showOrder              position of the reaction type in relation to the other reaction types
  * @property-read      string          $iconFile               the file location of the icon
  * @property-read       integer                $isDisabled             is `1` if the reaction type is disabled and thus not shown, otherwise `0`
  */
 class ReactionType extends DatabaseObject implements ITitledObject {
-       /**
-        * The type value, if this reaction type is a positive reaction.
-        * @var integer
-        */
-       const REACTION_TYPE_POSITIVE = 1;
-       
-       /**
-        * The type value, if this reaction type is a neutral reaction.
-        * @var integer
-        */
-       const REACTION_TYPE_NEUTRAL = 0;
-       
-       /**
-        * The type value, if this reaction type is a negative reaction.
-        * @var integer
-        */
-       const REACTION_TYPE_NEGATIVE = -1;
-       
        /**
         * @inheritDoc
         */
@@ -71,33 +52,6 @@ class ReactionType extends DatabaseObject implements ITitledObject {
                return WCF::getPath() . 'images/reaction/'. $this->iconFile;
        }
        
-       /**
-        * Returns true, if reaction is a positive reaction.
-        * 
-        * @return      bool
-        */
-       public function isPositive() {
-               return $this->type == self::REACTION_TYPE_POSITIVE;
-       }
-       
-       /**
-        * Returns true, if reaction is a negative reaction.
-        *
-        * @return      bool
-        */
-       public function isNegative() {
-               return $this->type == self::REACTION_TYPE_NEGATIVE;
-       }
-       
-       /**
-        * Returns true, if reaction is a neutral reaction.
-        *
-        * @return      bool
-        */
-       public function isNeutral() {
-               return $this->type == self::REACTION_TYPE_NEUTRAL;
-       }
-       
        /**
         * Returns the absolute location of the icon file. 
         * 
index 2f96b3bbfd3434c5fda098268d82e02029f7e549..da08ea6ebdbf3fe7cb0494398027b1d2c478e179 100644 (file)
@@ -134,7 +134,7 @@ class MembersListPage extends SortablePage {
         */
        protected function readObjects() {
                if ($this->sortField === 'reactionReputation') {
-                       $this->sqlOrderBy = '(user_table.positiveReactionsReceived - user_table.negativeReactionsReceived) '. $this->sortOrder;
+                       $this->sqlOrderBy = 'user_table.likesReceived '. $this->sortOrder;
                }
                
                parent::readObjects();
index a1df321757d3f8b125dc909068aff338d84018cb..0fad8b61511c07d7adde37f4c02063cd049cb12e 100644 (file)
@@ -27,10 +27,10 @@ class UserReputationCondition extends AbstractIntegerCondition implements IConte
                
                if (isset($conditionData['greaterThan'])) {
                        /** @noinspection PhpUndefinedFieldInspection */
-                       $objectList->getConditionBuilder()->add('(user_table.positiveReactionsReceived -  user_table.negativeReactionsReceived) > ?', [$conditionData['greaterThan']]);
+                       $objectList->getConditionBuilder()->add('user_table.likesReceived > ?', [$conditionData['greaterThan']]);
                }
                if (isset($conditionData['lessThan'])) {
-                       $objectList->getConditionBuilder()->add('(user_table.positiveReactionsReceived -  user_table.negativeReactionsReceived) < ?', [$conditionData['lessThan']]);
+                       $objectList->getConditionBuilder()->add('user_table.likesReceived < ?', [$conditionData['lessThan']]);
                }
        }
        
@@ -38,10 +38,10 @@ class UserReputationCondition extends AbstractIntegerCondition implements IConte
         * @inheritDoc
         */
        public function checkUser(Condition $condition, User $user) {
-               if ($condition->greaterThan !== null && ($user->positiveReactionsReceived - $user->negativeReactionsReceived) <= $condition->greaterThan) {
+               if ($condition->greaterThan !== null && $user->likesReceived <= $condition->greaterThan) {
                        return false;
                }
-               if ($condition->lessThan !== null && ($user->positiveReactionsReceived - $user->negativeReactionsReceived) >= $condition->lessThan) {
+               if ($condition->lessThan !== null && $user->likesReceived >= $condition->lessThan) {
                        return false;
                }
                
index a0a85cf4dd60731db1ff23e6506a9697c8b7c8c1..6656a696fcfc34f016a1b19b9905833586779396 100644 (file)
@@ -36,10 +36,7 @@ class AbstractLikeImporter extends AbstractImporter {
                
                if (!isset($data['reactionTypeID'])) {
                        if ($data['likeValue'] == 1) {
-                               $data['reactionTypeID'] = ReactionHandler::getInstance()->getLegacyReactionTypeID(ReactionType::REACTION_TYPE_POSITIVE);
-                       }
-                       else {
-                               $data['reactionTypeID'] = ReactionHandler::getInstance()->getLegacyReactionTypeID(ReactionType::REACTION_TYPE_NEGATIVE);
+                               $data['reactionTypeID'] = ReactionHandler::getInstance()->getFirstReactionTypeID();
                        }
                }
                else {
index 7162bad46e92260076e155f5a530cf5f90f3cadf..85d5368d0053c9be7d5e6b77998cb66ff91fadc3 100644 (file)
@@ -101,11 +101,9 @@ class LikeHandler extends SingletonFactory {
         * @return      array
         */
        public function like(ILikeObject $likeable, User $user, $likeValue, $time = TIME_NOW) {
+               $reactionTypeID = null;
                if ($likeValue == 1) {
-                       $reactionTypeID = ReactionHandler::getInstance()->getLegacyReactionTypeID(ReactionType::REACTION_TYPE_POSITIVE);
-               }
-               else {
-                       $reactionTypeID = ReactionHandler::getInstance()->getLegacyReactionTypeID(ReactionType::REACTION_TYPE_NEGATIVE);
+                       $reactionTypeID = ReactionHandler::getInstance()->getFirstReactionTypeID();
                }
                
                if ($reactionTypeID === null) {
@@ -114,27 +112,18 @@ class LikeHandler extends SingletonFactory {
                                'like' => 0,
                                'newValue' => 0,
                                'oldValue' => 0,
-                               'users' => []
+                               'users' => [],
                        ];
                }
                
                $reactData = ReactionHandler::getInstance()->react($likeable, $user, $reactionTypeID, $time);
-               if ($reactData['reactionTypeID'] === null) {
-                       $newValue = 0; 
-               }
-               else if (ReactionTypeCache::getInstance()->getReactionTypeByID($reactData['reactionTypeID'])->type == ReactionType::REACTION_TYPE_NEGATIVE) {
-                       $newValue = -1;
-               }
-               else {
-                       $newValue = 1;
-               }
                
                return [
                        'data' => $this->loadLikeStatus($reactData['likeObject'], $user),
                        'like' => $reactData['like'],
-                       'newValue' => $newValue,
-                       'oldValue' => 0, // this value is currently a dummy value, maybe determine a real value
-                       'users' => []
+                       'newValue' => 0,
+                       'oldValue' => 0,
+                       'users' => [],
                ];
        }
        
@@ -154,8 +143,8 @@ class LikeHandler extends SingletonFactory {
                        'data' => $this->loadLikeStatus($reactData['likeObject'], $user),
                        'like' => null,
                        'newValue' => 0,
-                       'oldValue' => 0, // this value is currently a dummy value, maybe determine a real value
-                       'users' => []
+                       'oldValue' => 0,
+                       'users' => [],
                ];
        }
        
index 986b38b09a604404d208ca969af7ed1e05b2a7a7..3cca143be8c09034e48c6acf5dd93648e8c9895a 100644 (file)
@@ -326,7 +326,7 @@ class ReactionHandler extends SingletonFactory {
                                        'reactionTypeID' => $reactionTypeID
                                ]);
                                
-                               if ($reaction->isPositive() && $likeable->getUserID()) {
+                               if ($likeable->getUserID()) {
                                        UserActivityPointHandler::getInstance()->fireEvent('com.woltlab.wcf.like.activityPointEvent.receivedLikes', $like->likeID, $likeable->getUserID());
                                }
                        }
@@ -339,12 +339,7 @@ class ReactionHandler extends SingletonFactory {
                                ]);
                                
                                if ($likeable->getUserID()) {
-                                       if ($like->getReactionType()->isPositive() && !$reaction->isPositive()) {
-                                               UserActivityPointHandler::getInstance()->removeEvents('com.woltlab.wcf.like.activityPointEvent.receivedLikes', [$likeable->getUserID() => 1]);
-                                       }
-                                       else if (!$like->getReactionType()->isPositive() && $reaction->isPositive()) {
-                                               UserActivityPointHandler::getInstance()->fireEvent('com.woltlab.wcf.like.activityPointEvent.receivedLikes', $like->likeID, $likeable->getUserID());
-                                       }
+                                       UserActivityPointHandler::getInstance()->removeEvents('com.woltlab.wcf.like.activityPointEvent.receivedLikes', [$likeable->getUserID() => 1]);
                                }
                        }
                        
@@ -402,9 +397,6 @@ class ReactionHandler extends SingletonFactory {
        private function updateLikeObject(ILikeObject $likeable, LikeObject $likeObject, Like $like, ReactionType $reactionType) {
                // update existing object
                if ($likeObject->likeObjectID) {
-                       $likes = $likeObject->likes;
-                       $dislikes = $likeObject->dislikes;
-                       $neutralReactions = $likeObject->neutralReactions;
                        $cumulativeLikes = $likeObject->cumulativeLikes;
                        
                        if ($likeObject->cachedReactions !== null) {
@@ -419,17 +411,7 @@ class ReactionHandler extends SingletonFactory {
                        }
                        
                        if ($like->likeID) {
-                               if ($like->getReactionType()->isPositive()) {
-                                       $likes--;
-                                       $cumulativeLikes--;
-                               }
-                               else if ($like->getReactionType()->isNegative()) {
-                                       $dislikes--;
-                                       $cumulativeLikes++;
-                               }
-                               else {
-                                       $neutralReactions--;
-                               }
+                               $cumulativeLikes--;
                                
                                if (isset($cachedReactions[$like->getReactionType()->reactionTypeID])) {
                                        if (--$cachedReactions[$like->getReactionType()->reactionTypeID] == 0) {
@@ -438,17 +420,7 @@ class ReactionHandler extends SingletonFactory {
                                }
                        }
                        
-                       if ($reactionType->isPositive()) {
-                               $likes++;
-                               $cumulativeLikes++;
-                       }
-                       else if ($reactionType->isNegative()) {
-                               $dislikes++;
-                               $cumulativeLikes--;
-                       }
-                       else {
-                               $neutralReactions++;
-                       }
+                       $cumulativeLikes++;
                        
                        if (isset($cachedReactions[$reactionType->reactionTypeID])) {
                                $cachedReactions[$reactionType->reactionTypeID]++;
@@ -459,11 +431,10 @@ class ReactionHandler extends SingletonFactory {
                        
                        // build update date
                        $updateData = [
-                               'likes' => $likes,
-                               'dislikes' => $dislikes,
-                               'neutralReactions' => $neutralReactions,
+                               'likes' => $cumulativeLikes,
+                               'dislikes' => 0,
                                'cumulativeLikes' => $cumulativeLikes,
-                               'cachedReactions' => serialize($cachedReactions)
+                               'cachedReactions' => serialize($cachedReactions),
                        ];
                        
                        // update data
@@ -471,9 +442,9 @@ class ReactionHandler extends SingletonFactory {
                        $likeObjectEditor->update($updateData);
                }
                else {
-                       $cumulativeLikes = $reactionType->type;
+                       $cumulativeLikes = 1;
                        $cachedReactions = [
-                               $reactionType->reactionTypeID => 1
+                               $reactionType->reactionTypeID => 1,
                        ];
                        
                        // create cache
@@ -481,18 +452,17 @@ class ReactionHandler extends SingletonFactory {
                                'objectTypeID' => $likeable->getObjectType()->objectTypeID,
                                'objectID' => $likeable->getObjectID(),
                                'objectUserID' => $likeable->getUserID() ?: null,
-                               'likes' => ($reactionType->isPositive()) ? 1 : 0,
-                               'dislikes' => ($reactionType->isNegative()) ? 1 : 0,
-                               'neutralReactions' => ($reactionType->isNeutral()) ? 1 : 0,
+                               'likes' => $cumulativeLikes,
+                               'dislikes' => 0,
                                'cumulativeLikes' => $cumulativeLikes,
-                               'cachedReactions' => serialize($cachedReactions)
+                               'cachedReactions' => serialize($cachedReactions),
                        ]);
                }
                
                return [
                        'cumulativeLikes' => $cumulativeLikes, 
                        'cachedReactions' => $cachedReactions, 
-                       'likeObject' => $likeObject
+                       'likeObject' => $likeObject,
                ]; 
        }
        
@@ -506,41 +476,19 @@ class ReactionHandler extends SingletonFactory {
         */
        private function updateUsersLikeCounter(ILikeObject $likeable, LikeObject $likeObject, Like $like, ReactionType $reactionType = null) {
                if ($likeable->getUserID()) {
-                       $counters = [
-                               'likesReceived' => 0,
-                               'positiveReactionsReceived' => 0,
-                               'negativeReactionsReceived' => 0,
-                               'neutralReactionsReceived' => 0
-                       ];
-                       
+                       $likesReceived = 0;
                        if ($like->likeID) {
-                               if ($like->getReactionType()->isPositive()) {
-                                       $counters['likesReceived']--;
-                                       $counters['positiveReactionsReceived']--;
-                               }
-                               else if ($like->getReactionType()->isNegative()) {
-                                       $counters['negativeReactionsReceived']--;
-                               }
-                               else if ($like->getReactionType()->isNeutral()) {
-                                       $counters['neutralReactionsReceived']--;
-                               }
+                               $likesReceived--;
                        }
                        
                        if ($reactionType !== null) {
-                               if ($reactionType->isPositive()) {
-                                       $counters['likesReceived']++;
-                                       $counters['positiveReactionsReceived']++;
-                               }
-                               else if ($reactionType->isNegative()) {
-                                       $counters['negativeReactionsReceived']++;
-                               }
-                               else if ($reactionType->isNeutral()) {
-                                       $counters['neutralReactionsReceived']++;
-                               }
+                               $likesReceived++;
                        }
                        
-                       $userEditor = new UserEditor(UserRuntimeCache::getInstance()->getObject($likeable->getUserID()));
-                       $userEditor->updateCounters($counters);
+                       if ($likesReceived !== 0) {
+                               $userEditor = new UserEditor(UserRuntimeCache::getInstance()->getObject($likeable->getUserID()));
+                               $userEditor->updateCounters(['likesReceived' => $likesReceived]);
+                       }
                }
        }
        
@@ -569,7 +517,7 @@ class ReactionHandler extends SingletonFactory {
                        $likeEditor = new LikeEditor($like);
                        $likeEditor->delete();
                        
-                       if ($likeable->getUserID() && $like->getReactionType()->isPositive()) {
+                       if ($likeable->getUserID()) {
                                UserActivityPointHandler::getInstance()->removeEvents('com.woltlab.wcf.like.activityPointEvent.receivedLikes', [$likeable->getUserID() => 1]);
                        }
                        
@@ -615,9 +563,6 @@ class ReactionHandler extends SingletonFactory {
                }
                
                // update existing object
-               $likes = $likeObject->likes;
-               $dislikes = $likeObject->dislikes;
-               $neutralReactions = $likeObject->neutralReactions;
                $cumulativeLikes = $likeObject->cumulativeLikes;
                $cachedReactions = @unserialize($likeObject->cachedReactions);
                if (!is_array($cachedReactions)) {
@@ -625,20 +570,7 @@ class ReactionHandler extends SingletonFactory {
                }
                
                if ($like->likeID) {
-                       if ($like->getReactionType()->isPositive()) {
-                               $likes--;
-                               $cumulativeLikes--;
-                       }
-                       else if ($like->getReactionType()->isNegative()) {
-                               $dislikes--;
-                               $cumulativeLikes++;
-                       }
-                       else if ($like->getReactionType()->isNeutral()) {
-                               $neutralReactions--;
-                       }
-                       else {
-                               throw new \LogicException('Unreachable');
-                       }
+                       $cumulativeLikes--;
                        
                        if (isset($cachedReactions[$like->getReactionType()->reactionTypeID])) {
                                if (--$cachedReactions[$like->getReactionType()->reactionTypeID] == 0) {
@@ -648,9 +580,8 @@ class ReactionHandler extends SingletonFactory {
                        
                        // build update date
                        $updateData = [
-                               'likes' => $likes,
-                               'dislikes' => $dislikes,
-                               'neutralReactions' => $neutralReactions,
+                               'likes' => $cumulativeLikes,
+                               'dislikes' => 0,
                                'cumulativeLikes' => $cumulativeLikes,
                                'cachedReactions' => serialize($cachedReactions)
                        ];
@@ -694,43 +625,17 @@ class ReactionHandler extends SingletonFactory {
                foreach ($likeObjects as $likeObject) {
                        if ($likeObject->likes) {
                                if (!isset($users[$likeObject->objectUserID])) {
-                                       $users[$likeObject->objectUserID] = [
-                                               'positiveReactions' => 0,
-                                               'negativeReactions' => 0,
-                                               'neutralReactions' => 0
-                                       ];
+                                       $users[$likeObject->objectUserID] = 0;
                                }
                                
-                               foreach ($likeObject->getReactions() as $reactionTypeID => $data) {
-                                       switch (ReactionTypeCache::getInstance()->getReactionTypeByID($reactionTypeID)->type) {
-                                               case ReactionType::REACTION_TYPE_POSITIVE:
-                                                       $users[$likeObject->objectUserID]['positiveReactions'] += $data['reactionCount'];
-                                                       break;
-                                               
-                                               case ReactionType::REACTION_TYPE_NEUTRAL:
-                                                       $users[$likeObject->objectUserID]['neutralReactions'] += $data['reactionCount'];
-                                                       break;
-                                               
-                                               case ReactionType::REACTION_TYPE_NEGATIVE:
-                                                       $users[$likeObject->objectUserID]['negativeReactions'] += $data['reactionCount'];
-                                                       break;
-                                               
-                                               default:
-                                                       throw new \LogicException('Unreachable');
-                                       }
-                               }
+                               $users[$likeObject->objectUserID] -= count($likeObject->getReactions());
                        }
                }
                
                foreach ($users as $userID => $reactionData) {
                        $userEditor = new UserEditor(new User(null, ['userID' => $userID]));
                        $userEditor->updateCounters([
-                               'positiveReactionsReceived' => $users[$userID]['positiveReactions'] *-1,
-                               'negativeReactionsReceived' => $users[$userID]['negativeReactions'] *-1,
-                               'neutralReactionsReceived' => $users[$userID]['neutralReactions'] *-1,
-                               
-                               // maintain deprecated value for legacy reasons
-                               'likesReceived' => $users[$userID]['positiveReactions'] *-1
+                               'likesReceived' => $users[$userID],
                        ]);
                }
                
@@ -741,13 +646,9 @@ class ReactionHandler extends SingletonFactory {
                $likeList->readObjects();
                
                if (count($likeList)) {
-                       $likeData = $positiveLikeData = [];
+                       $likeData = [];
                        foreach ($likeList as $like) {
                                $likeData[$like->likeID] = $like->userID;
-                               
-                               if ($like->getReactionType()->isPositive()) {
-                                       $positiveLikeData[$like->likeID] = $like->userID;
-                               }
                        }
                        
                        // delete like notifications
@@ -761,7 +662,7 @@ class ReactionHandler extends SingletonFactory {
                        }
                        
                        // revoke activity points
-                       UserActivityPointHandler::getInstance()->removeEvents('com.woltlab.wcf.like.activityPointEvent.receivedLikes', $positiveLikeData);
+                       UserActivityPointHandler::getInstance()->removeEvents('com.woltlab.wcf.like.activityPointEvent.receivedLikes', $likeData);
                        
                        // delete likes
                        LikeEditor::deleteAll(array_keys($likeData));
@@ -806,39 +707,31 @@ class ReactionHandler extends SingletonFactory {
        }
        
        /**
-        * Returns the legacy reactionTypeID for a specific type. The given type must be
-        * ReactionType::REACTION_TYPE_POSITIVE for a like 
-        * or ReactionType::REACTION_TYPE_NEGATIVE for a dislike 
-        * other values are not allowed and will resulted in a LogicException.
-        * If there are no legacy reaction type, the method returns null.
+        * Returns the first available reaction type.
         * 
-        * @param       integer         $type
-        * @return      integer|null
+        * @return ReactionType|null
         */
-       public function getLegacyReactionTypeID($type) {
-               $reactionTypes = ReactionTypeCache::getInstance()->getEnabledReactionTypes();
-               ReactionType::sort($reactionTypes, 'showOrder');
-               switch ($type) {
-                       case ReactionType::REACTION_TYPE_POSITIVE: 
-                               foreach ($reactionTypes as $reactionType) {
-                                       if ($reactionType->isPositive()) {
-                                               return $reactionType->reactionTypeID;
-                                       }
-                               }
-                               
-                               return null; 
-                               
-                       case ReactionType::REACTION_TYPE_NEGATIVE:
-                               foreach ($reactionTypes as $reactionType) {
-                                       if ($reactionType->isNegative()) {
-                                               return $reactionType->reactionTypeID;
-                                       }
-                               }
-                               
-                               return null;
+       public function getFirstReactionType() {
+               static $firstReactionType;
+               
+               if ($firstReactionType === null) {
+                       $reactionTypes = ReactionTypeCache::getInstance()->getEnabledReactionTypes();
+                       ReactionType::sort($reactionTypes, 'showOrder');
                        
-                       default: 
-                               throw new \LogicException('Invalid type given.');
+                       $firstReactionType = reset($reactionTypes);
                }
+               
+               return $firstReactionType;
+       }
+       
+       /**
+        * Returns the first available reaction type's id.
+        * 
+        * @return int|null
+        */
+       public function getFirstReactionTypeID() {
+               $firstReactionType = $this->getFirstReactionType();
+               
+               return $firstReactionType ? $firstReactionType->reactionTypeID : null;
        }
 }
diff --git a/wcfsetup/install/files/lib/system/stat/DislikeStatDailyHandler.class.php b/wcfsetup/install/files/lib/system/stat/DislikeStatDailyHandler.class.php
deleted file mode 100644 (file)
index 9e6ba94..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-<?php
-namespace wcf\system\stat;
-use wcf\data\like\Like;
-
-/**
- * Stat handler implementation for dislike stats.
- * 
- * @author     Marcel Werk
- * @copyright  2001-2019 WoltLab GmbH
- * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package    WoltLabSuite\Core\System\Stat
- */
-class DislikeStatDailyHandler extends LikeStatDailyHandler {
-       protected $likeValue = Like::DISLIKE;
-}
index 5902b7aa07ea45faf0908386af8d68bc1051e3de..105328245360ccbda973e80b48ac196ea7268f65 100644 (file)
@@ -1,6 +1,5 @@
 <?php
 namespace wcf\system\stat;
-use wcf\data\like\Like;
 use wcf\system\WCF;
 
 /**
@@ -12,26 +11,22 @@ use wcf\system\WCF;
  * @package    WoltLabSuite\Core\System\Stat
  */
 class LikeStatDailyHandler extends AbstractStatDailyHandler {
-       protected $likeValue = Like::LIKE;
-       
        /**
         * @inheritDoc
         */
        public function getData($date) {
                $sql = "SELECT  COUNT(*)
                        FROM    wcf".WCF_N."_like
-                       WHERE   time BETWEEN ? AND ?
-                               AND likeValue = ?";
+                       WHERE   time BETWEEN ? AND ?";
                $statement = WCF::getDB()->prepareStatement($sql);
-               $statement->execute([$date, $date + 86399, $this->likeValue]);
+               $statement->execute([$date, $date + 86399]);
                $counter = intval($statement->fetchSingleColumn());
                
                $sql = "SELECT  COUNT(*)
                        FROM    wcf".WCF_N."_like
-                       WHERE   time < ?
-                               AND likeValue = ?";
+                       WHERE   time < ?";
                $statement = WCF::getDB()->prepareStatement($sql);
-               $statement->execute([$date + 86400, $this->likeValue]);
+               $statement->execute([$date + 86400]);
                $total = intval($statement->fetchSingleColumn());
                
                return [
index 8dc4d40c8ee6f5930414a8b6c9309ca8dbcea774..f2682733a58491806272af3501e2ba20fdc5022b 100644 (file)
@@ -57,7 +57,7 @@ class LikeRebuildDataWorker extends AbstractRebuildDataWorker {
                $itemsToUser = [];
                $likeObjectData = [];
                foreach ($this->objectList as $like) {
-                       if ($like->objectUserID && $like->likeValue == Like::LIKE) {
+                       if ($like->objectUserID) {
                                if (!isset($itemsToUser[$like->objectUserID])) {
                                        $itemsToUser[$like->objectUserID] = 0;
                                }
@@ -71,24 +71,14 @@ class LikeRebuildDataWorker extends AbstractRebuildDataWorker {
                        if (!isset($likeObjectData[$like->objectTypeID][$like->objectID])) {
                                $likeObjectData[$like->objectTypeID][$like->objectID] = [
                                        'likes' => 0,
-                                       'dislikes' => 0,
-                                       'neutralReactions' => 0,
                                        'cumulativeLikes' => 0,
                                        'objectUserID' => $like->objectUserID, 
                                        'cachedReactions' => []
                                ];
                        }
                        
-                       if ($like->isLike()) {
-                               $likeObjectData[$like->objectTypeID][$like->objectID]['likes']++;
-                       }
-                       else if ($like->isDislike()) {
-                               $likeObjectData[$like->objectTypeID][$like->objectID]['dislikes']++;
-                       }
-                       else {
-                               $likeObjectData[$like->objectTypeID][$like->objectID]['neutralReactions']++;
-                       }
-                       $likeObjectData[$like->objectTypeID][$like->objectID]['cumulativeLikes'] += $like->likeValue;
+                       $likeObjectData[$like->objectTypeID][$like->objectID]['likes']++;
+                       $likeObjectData[$like->objectTypeID][$like->objectID]['cumulativeLikes']++;
                        
                        if (!isset($likeObjectData[$like->objectTypeID][$like->objectID]['cachedReactions'][$like->getReactionType()->reactionTypeID])) {
                                $likeObjectData[$like->objectTypeID][$like->objectID]['cachedReactions'][$like->getReactionType()->reactionTypeID] = 0;
@@ -101,11 +91,9 @@ class LikeRebuildDataWorker extends AbstractRebuildDataWorker {
                UserActivityPointHandler::getInstance()->fireEvents('com.woltlab.wcf.like.activityPointEvent.receivedLikes', $itemsToUser, false);
                
                $sql = "INSERT INTO                     wcf".WCF_N."_like_object
-                                                       (objectTypeID, objectID, objectUserID, likes, dislikes, neutralReactions, cumulativeLikes, cachedReactions)
-                       VALUES                          (?, ?, ?, ?, ?, ?, ?, ?)
+                                                       (objectTypeID, objectID, objectUserID, likes, dislikes, cumulativeLikes, cachedReactions)
+                       VALUES                          (?, ?, ?, ?, ?, ?, ?)
                        ON DUPLICATE KEY UPDATE         likes = likes + VALUES(likes),
-                                                       dislikes = dislikes + VALUES(dislikes),
-                                                       neutralReactions = neutralReactions + VALUES(neutralReactions),
                                                        cumulativeLikes = cumulativeLikes + VALUES(cumulativeLikes),
                                                        cachedReactions = VALUES(cachedReactions)";
                $statement = WCF::getDB()->prepareStatement($sql);
@@ -118,8 +106,6 @@ class LikeRebuildDataWorker extends AbstractRebuildDataWorker {
                                        $objectID,
                                        $data['objectUserID'],
                                        $data['likes'],
-                                       $data['dislikes'],
-                                       $data['neutralReactions'],
                                        $data['cumulativeLikes'], 
                                        serialize($data['cachedReactions'])
                                ]);
index d319285edbba05983e4e2feb6046a52eda3511cf..edac82bb93f6600a3e9436f31a019af9b2665c82 100644 (file)
@@ -82,67 +82,21 @@ class UserRebuildDataWorker extends AbstractRebuildDataWorker {
                        
                        // update like counter
                        if (MODULE_LIKE) {
-                               $positiveReactionTypes = $negativeReactionTypes = $neutralReactionTypes = [];
-                               
-                               foreach (ReactionTypeCache::getInstance()->getEnabledReactionTypes() as $reactionType) {
-                                       switch ($reactionType->type) {
-                                               case ReactionType::REACTION_TYPE_POSITIVE: 
-                                                       $positiveReactionTypes[] = $reactionType->reactionTypeID;
-                                                       break;
-                                               
-                                               case ReactionType::REACTION_TYPE_NEGATIVE: 
-                                                       $negativeReactionTypes[] = $reactionType->reactionTypeID;
-                                                       break;
-                                                       
-                                               case ReactionType::REACTION_TYPE_NEUTRAL:
-                                                       $neutralReactionTypes[] = $reactionType->reactionTypeID;
-                                                       break;
-                                                       
-                                               default: 
-                                                       throw new \LogicException('Unreachable');
-                                       }
-                               }
-                               
                                $sql = "UPDATE  wcf".WCF_N."_user user_table SET";
-                                       
-                               if (!empty($positiveReactionTypes)) {
+                               
+                               $reactionTypeIDs = array_keys(ReactionTypeCache::getInstance()->getEnabledReactionTypes());
+                               if (!empty($reactionTypeIDs)) {
                                        $sql .= " likesReceived = (
                                                        SELECT  COUNT(*)
                                                        FROM    wcf".WCF_N."_like
                                                        WHERE   objectUserID = user_table.userID
-                                                               AND reactionTypeID IN (". implode(',', $positiveReactionTypes) .")
-                                               ), positiveReactionsReceived = (
-                                                       SELECT  COUNT(*)
-                                                       FROM    wcf".WCF_N."_like
-                                                       WHERE   objectUserID = user_table.userID
-                                                               AND reactionTypeID IN (". implode(',', $positiveReactionTypes) ."))";
+                                                               AND reactionTypeID IN (". implode(',', $reactionTypeIDs) .")
+                                               )";
                                }
                                else {
-                                       $sql .= " likesReceived = 0, positiveReactionsReceived = 0";
+                                       $sql .= " likesReceived = 0";
                                }
                                
-                               if (!empty($negativeReactionTypes)) {
-                                       $sql .= ", negativeReactionsReceived = (
-                                                       SELECT  COUNT(*)
-                                                       FROM    wcf".WCF_N."_like
-                                                       WHERE   objectUserID = user_table.userID
-                                                               AND reactionTypeID IN (". implode(',', $negativeReactionTypes) ."))";
-                               }
-                               else {
-                                       $sql .= ", negativeReactionsReceived = 0";
-                               }
-                                       
-                               if (!empty($neutralReactionTypes)) {
-                                       $sql .= ", neutralReactionsReceived = (
-                                                       SELECT  COUNT(*)
-                                                       FROM    wcf".WCF_N."_like
-                                                       WHERE   objectUserID = user_table.userID
-                                                               AND reactionTypeID IN (". implode(',', $neutralReactionTypes) ."))";
-                               }
-                               else {
-                                       $sql .= ", neutralReactionsReceived = 0";
-                               }
-                                       
                                $sql .= " ".$conditionBuilder;
                                $statement = WCF::getDB()->prepareStatement($sql);
                                $statement->execute($conditionBuilder->getParameters());
index 5d5c150845fdd2cb7c6db12145f77573ef54f6e1..41b271a4da08baa622b12a9e19648b71f54a3276 100644 (file)
@@ -2569,9 +2569,6 @@ Kein Abschnitt darf leer sein und alle Abschnitten dürfen nur folgende Zeichen
        <category name="wcf.acp.reactionType">
                <item name="wcf.acp.reactionType.delete.confirmMessage"><![CDATA[{if LANGUAGE_USE_INFORMAL_VARIANT}Willst du{else}Wollen Sie{/if} den Reaktions-Typen <span class="confirmationObject">{$reactionType->getTitle()}</span> wirklich löschen?]]></item>
                <item name="wcf.acp.reactionType.type"><![CDATA[Reaktions-Typ]]></item>
-               <item name="wcf.acp.reactionType.type.positive"><![CDATA[Positiv]]></item>
-               <item name="wcf.acp.reactionType.type.negative"><![CDATA[Negativ]]></item>
-               <item name="wcf.acp.reactionType.type.neutral"><![CDATA[Neutral]]></item>
                <item name="wcf.acp.reactionType.isDisabled"><![CDATA[Reaktion deaktivieren]]></item>
                <item name="wcf.acp.reactionType.image"><![CDATA[Reaktions-Datei]]></item>
                <item name="wcf.acp.reactionType.showOrder.description"><![CDATA[Der Reaktions-Typ wird nach dem ausgewählten Reaktions-Typ angezeigt.]]></item>
@@ -4904,9 +4901,6 @@ Die E-Mail-Adresse des neuen Benutzers lautet: {@$user->email}
                <item name="wcf.user.condition.notUserTrophyIDs.description"><![CDATA[Benutzer dürfen keine der ausgewählten Trophäen erhalten haben.]]></item>
                <item name="wcf.user.condition.notUserTrophyIDs.error.userTrophyIntersection"><![CDATA[Die ausgewählten Trophäen in „hat Trophäe“ und „hat nicht Trophäe“ sind widersprüchlich.]]></item>
                <item name="wcf.user.condition.trophyPoints"><![CDATA[Trophäen]]></item>
-               <item name="wcf.user.condition.positiveReactionsReceived"><![CDATA[Positive Reaktionen]]></item>
-               <item name="wcf.user.condition.negativeReactionsReceived"><![CDATA[Negative Reaktionen]]></item>
-               <item name="wcf.user.condition.neutralReactionsReceived"><![CDATA[Neutrale Reaktionen]]></item>
                <item name="wcf.user.condition.userReputation"><![CDATA[Reputation aus Reaktionen]]></item>
        </category>
        <category name="wcf.user.coverPhoto">
index 5c15bb14f6714b7fc476e414770139141743eab4..9f060d5ed88f21375665f23ead713bd1931ce9ae 100644 (file)
@@ -2497,9 +2497,6 @@ If you have <strong>already bought the licenses for the listed apps</strong>, th
        <category name="wcf.acp.reactionType">
                <item name="wcf.acp.reactionType.delete.confirmMessage"><![CDATA[Do you really want to delete the reaction type <span class="confirmationObject">{$reactionType->getTitle()}</span>?]]></item>
                <item name="wcf.acp.reactionType.type"><![CDATA[Reaction Type]]></item>
-               <item name="wcf.acp.reactionType.type.positive"><![CDATA[Positiv]]></item>
-               <item name="wcf.acp.reactionType.type.negative"><![CDATA[Negativ]]></item>
-               <item name="wcf.acp.reactionType.type.neutral"><![CDATA[Neutral]]></item>
                <item name="wcf.acp.reactionType.isDisabled"><![CDATA[Disable Reaction]]></item>
                <item name="wcf.acp.reactionType.image"><![CDATA[Reaction File]]></item>
                <item name="wcf.acp.reactionType.showOrder.description"><![CDATA[The reaction type will be shown after the selected reaction type.]]></item>
@@ -4900,9 +4897,6 @@ Open the link below to access the user profile:
                <item name="wcf.user.condition.notUserTrophyIDs.description"><![CDATA[User has not received the selected trophies.]]></item>
                <item name="wcf.user.condition.notUserTrophyIDs.error.userTrophyIntersection"><![CDATA[The selected trophies in “User has Trophy” and “User does not have Trophy” are conflicting.]]></item>
                <item name="wcf.user.condition.trophyPoints"><![CDATA[Trophies]]></item>
-               <item name="wcf.user.condition.positiveReactionsReceived"><![CDATA[Positive Reactions]]></item>
-               <item name="wcf.user.condition.negativeReactionsReceived"><![CDATA[Negative Reactions]]></item>
-               <item name="wcf.user.condition.neutralReactionsReceived"><![CDATA[Neutral Reactions]]></item>
                <item name="wcf.user.condition.userReputation"><![CDATA[Reputation from Reactions]]></item>
        </category>
        <category name="wcf.user.coverPhoto">
index 43762c2718ad4d7585a5268d4f69a3094abedd21..64af1aca36b7f7ba0ca0adc8513232db7db72cb7 100644 (file)
@@ -678,7 +678,6 @@ CREATE TABLE wcf1_like_object (
        objectUserID INT(10),
        likes MEDIUMINT(7) NOT NULL DEFAULT 0,
        dislikes MEDIUMINT(7) NOT NULL DEFAULT 0,
-       neutralReactions MEDIUMINT(7) NOT NULL DEFAULT 0,
        cumulativeLikes MEDIUMINT(7) NOT NULL DEFAULT 0,
        cachedUsers TEXT,
        cachedReactions TEXT,
@@ -1201,7 +1200,6 @@ DROP TABLE IF EXISTS wcf1_reaction_type;
 CREATE TABLE wcf1_reaction_type (
        reactionTypeID INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY, 
        title VARCHAR(255), 
-       type TINYINT(1),
        showOrder INT(10) NOT NULL DEFAULT 0,
        iconFile MEDIUMTEXT,
        isDisabled TINYINT(1) NOT NULL DEFAULT 0
@@ -1488,9 +1486,6 @@ CREATE TABLE wcf1_user (
        disableCoverPhotoReason TEXT,
        disableCoverPhotoExpires INT(10) NOT NULL DEFAULT 0,
        articles INT(10) NOT NULL DEFAULT 0,
-       positiveReactionsReceived INT(10) NOT NULL DEFAULT 0,
-       negativeReactionsReceived INT(10) NOT NULL DEFAULT 0,
-       neutralReactionsReceived INT(10) NOT NULL DEFAULT 0,
        blacklistMatches VARCHAR(255) NOT NULL DEFAULT '',
        
        KEY username (username),
@@ -1501,9 +1496,6 @@ CREATE TABLE wcf1_user (
        KEY registrationData (registrationIpAddress, registrationDate),
        KEY activityPoints (activityPoints),
        KEY likesReceived (likesReceived),
-       KEY positiveReactionsReceived (positiveReactionsReceived),
-       KEY negativeReactionsReceived (negativeReactionsReceived),
-       KEY neutralReactionsReceived (neutralReactionsReceived),
        KEY authData (authData),
        KEY trophyPoints (trophyPoints)
 );
@@ -2430,8 +2422,8 @@ INSERT INTO wcf1_contact_option (optionID, optionTitle, optionDescription, optio
 INSERT INTO wcf1_contact_recipient (recipientID, name, email, isAdministrator, originIsSystem) VALUES (1, 'wcf.contact.recipient.name1', '', 1, 1);
 
 -- default reaction type
-INSERT INTO wcf1_reaction_type (title, type, showOrder, iconFile) VALUES ('wcf.reactionType.title1', 1, 1, 'like.svg');
-INSERT INTO wcf1_reaction_type (title, type, showOrder, iconFile) VALUES ('wcf.reactionType.title2', 1, 2, 'haha.svg');
-INSERT INTO wcf1_reaction_type (title, type, showOrder, iconFile) VALUES ('wcf.reactionType.title3', -1, 3, 'sad.svg');
-INSERT INTO wcf1_reaction_type (title, type, showOrder, iconFile) VALUES ('wcf.reactionType.title4', 0, 4, 'confused.svg');
-INSERT INTO wcf1_reaction_type (title, type, showOrder, iconFile) VALUES ('wcf.reactionType.title5', 1, 5, 'thanks.svg');
+INSERT INTO wcf1_reaction_type (title, showOrder, iconFile) VALUES ('wcf.reactionType.title1', 1, 'like.svg');
+INSERT INTO wcf1_reaction_type (title, showOrder, iconFile) VALUES ('wcf.reactionType.title2', 2, 'haha.svg');
+INSERT INTO wcf1_reaction_type (title, showOrder, iconFile) VALUES ('wcf.reactionType.title3', 3, 'sad.svg');
+INSERT INTO wcf1_reaction_type (title, showOrder, iconFile) VALUES ('wcf.reactionType.title4', 4, 'confused.svg');
+INSERT INTO wcf1_reaction_type (title, showOrder, iconFile) VALUES ('wcf.reactionType.title5', 5, 'thanks.svg');