Rebuild trophy points in UserRebuildDataWorker
authorJoshua Rüsweg <josh@bastelstu.be>
Tue, 1 Aug 2017 10:16:44 +0000 (12:16 +0200)
committerJoshua Rüsweg <josh@bastelstu.be>
Tue, 1 Aug 2017 10:16:44 +0000 (12:16 +0200)
See #2315

wcfsetup/install/files/lib/system/worker/UserRebuildDataWorker.class.php

index d7c17e82e8364b6124c35962c8cf38cca401a580..8e320488168069159cf81547eb18e47e70522dc1 100644 (file)
@@ -84,6 +84,25 @@ class UserRebuildDataWorker extends AbstractRebuildDataWorker {
                                $statement->execute($conditionBuilder->getParameters());
                        }
                        
+                       // update trophy points
+                       if (MODULE_TROPHY) {
+                               $conditionBuilder = new PreparedStatementConditionBuilder();
+                               $conditionBuilder->add('user_table.userID IN (?)', [$userIDs]);
+                               $sql = "UPDATE  wcf".WCF_N."_user user_table
+                                       SET     trophyPoints = (
+                                                       SELECT          COUNT(*)
+                                                       FROM            wcf".WCF_N."_user_trophy user_trophy
+                                                       LEFT JOIN       wcf".WCF_N."_trophy trophy ON user_trophy.trophyID = trophy.trophyID
+                                                       LEFT JOIN       wcf".WCF_N."_category trophy_category ON trophy.categoryID = trophy_category.categoryID
+                                                       WHERE           user_trophy.userID = user_table.userID
+                                                                       AND trophy.isDisabled = 0
+                                                                       AND trophy_category.isDisabled = 0
+                                               )
+                                       ".$conditionBuilder;
+                               $statement = WCF::getDB()->prepareStatement($sql);
+                               $statement->execute($conditionBuilder->getParameters());
+                       }
+                       
                        // update signatures and about me
                        $sql = "UPDATE  wcf".WCF_N."_user_option_value
                                SET     userOption" . User::getUserOptionID('aboutMe') . " = ?