3 namespace wcf\system\event\listener;
5 use wcf\system\database\util\PreparedStatementConditionBuilder;
6 use wcf\system\user\activity\point\UserActivityPointHandler;
8 use wcf\system\worker\UserActivityPointItemsRebuildDataWorker;
11 * Updates the user activity point items counter for person information.
13 * @author Matthias Schmidt
14 * @copyright 2001-2021 WoltLab GmbH
15 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
16 * @package WoltLabSuite\Core\System\Event\Listener
18 class PersonUserActivityPointItemsRebuildDataWorkerListener extends AbstractEventListener
20 protected function onExecute(UserActivityPointItemsRebuildDataWorker $worker): void
22 $objectType = UserActivityPointHandler::getInstance()
23 ->getObjectTypeByName('com.woltlab.wcf.people.information');
25 $conditionBuilder = new PreparedStatementConditionBuilder();
26 $conditionBuilder->add('user_activity_point.objectTypeID = ?', [$objectType->objectTypeID]);
27 $conditionBuilder->add('user_activity_point.userID IN (?)', [$worker->getObjectList()->getObjectIDs()]);
29 $sql = "UPDATE wcf" . WCF_N . "_user_activity_point user_activity_point
30 SET user_activity_point.items = (
32 FROM wcf" . WCF_N . "_person_information person_information
33 WHERE person_information.userID = user_activity_point.userID
35 user_activity_point.activityPoints = user_activity_point.items * ?
37 $statement = WCF::getDB()->prepareStatement($sql);
38 $statement->execute(\array_merge(
39 [$objectType->points],
40 $conditionBuilder->getParameters()