From: Cyperghost Date: Tue, 3 Jan 2017 18:39:28 +0000 (+0100) Subject: Add a function to set a object visit by given userIDs (#2159) X-Git-Tag: 3.0.0~66 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=66cf5bb33ca9d131a7970926c90c36591154da21;p=GitHub%2FWoltLab%2FWCF.git Add a function to set a object visit by given userIDs (#2159) * Add a function to set a object visit by given userIDs * Add transaction and reformat code * Add whitspaces * fix indentation --- diff --git a/wcfsetup/install/files/lib/system/visitTracker/VisitTracker.class.php b/wcfsetup/install/files/lib/system/visitTracker/VisitTracker.class.php index 79b4c8466e..6f895241e7 100644 --- a/wcfsetup/install/files/lib/system/visitTracker/VisitTracker.class.php +++ b/wcfsetup/install/files/lib/system/visitTracker/VisitTracker.class.php @@ -148,6 +148,30 @@ class VisitTracker extends SingletonFactory { } } + /** + * Tracks an object visit for the users with the given ids. + * + * @param string $objectType + * @param integer $objectID + * @param integer[] $userIDs + * @param int $time + */ + public function trackObjectVisitByUserIDs($objectType, $objectID, array $userIDs, $time = TIME_NOW) { + // save visit + $sql = "REPLACE INTO wcf".WCF_N."_tracked_visit + (objectTypeID, objectID, userID, visitTime) + VALUES (?, ?, ?, ?)"; + $statement = WCF::getDB()->prepareStatement($sql); + $objectTypeID = $this->getObjectTypeID($objectType); + WCF::getDB()->beginTransaction(); + + foreach ($userIDs as $userID) { + $statement->execute([$objectTypeID, $objectID, $userID, $time]); + } + + WCF::getDB()->commitTransaction(); + } + /** * Tracks an object visit. *