'template' => WCF::getTPL()->fetch('groupedUserList')
];
}
+
+ /**
+ * Inserts a new visitor if it does not already exist, or updates it if it does.
+ * @since 5.2
+ */
+ public function registerVisitor() {
+ $sql = "INSERT INTO wcf".WCF_N."_user_profile_visitor
+ (ownerID, userID, time)
+ VALUES (?, ?, ?)
+ ON DUPLICATE KEY UPDATE time = VALUES(time)";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute([
+ $this->parameters['data']['ownerID'],
+ $this->parameters['data']['userID'],
+ $this->parameters['data']['time'] ?? TIME_NOW,
+ ]);
+ }
}
use wcf\data\user\follow\UserFollowerList;
use wcf\data\user\follow\UserFollowingList;
use wcf\data\user\group\UserGroup;
-use wcf\data\user\profile\visitor\UserProfileVisitor;
-use wcf\data\user\profile\visitor\UserProfileVisitorEditor;
+use wcf\data\user\profile\visitor\UserProfileVisitorAction;
use wcf\data\user\profile\visitor\UserProfileVisitorList;
use wcf\data\user\UserEditor;
use wcf\data\user\UserProfile;
// save visitor
/** @noinspection PhpUndefinedFieldInspection */
if (PROFILE_ENABLE_VISITORS && WCF::getUser()->userID && !WCF::getUser()->canViewOnlineStatus) {
- if (($visitor = UserProfileVisitor::getObject($this->user->userID, WCF::getUser()->userID)) !== null) {
- $editor = new UserProfileVisitorEditor($visitor);
- $editor->update(['time' => TIME_NOW]);
- }
- else {
- UserProfileVisitorEditor::create([
+ (new UserProfileVisitorAction([], 'registerVisitor', [
+ 'data' => [
'ownerID' => $this->user->userID,
'userID' => WCF::getUser()->userID,
- 'time' => TIME_NOW
- ]);
- }
+ ]
+ ]))->executeAction();
}
}