2 namespace wcf\system\page\handler
;
3 use wcf\data\page\Page
;
4 use wcf\data\user\online\UserOnline
;
5 use wcf\system\cache\runtime\UserRuntimeCache
;
9 * Implementation of the `IOnlineLocationPageHandler` interface for user-bound pages.
11 * @author Matthias Schmidt
12 * @copyright 2001-2019 WoltLab GmbH
13 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
14 * @package WoltLabSuite\Core\System\Page\Handler
17 trait TUserOnlineLocationPageHandler
{
18 use TOnlineLocationPageHandler
;
21 * Returns the textual description if a user is currently online viewing this page.
23 * @param Page $page visited page
24 * @param UserOnline $user user online object with request data
26 * @see IOnlineLocationPageHandler::getOnlineLocation()
28 public function getOnlineLocation(Page
$page, UserOnline
$user) {
29 if ($user->pageObjectID
=== null) {
33 $userObject = UserRuntimeCache
::getInstance()->getObject($user->pageObjectID
);
34 if ($userObject === null) {
38 return WCF
::getLanguage()->getDynamicVariable('wcf.page.onlineLocation.'.$page->identifier
, ['user' => $userObject]);
42 * Prepares fetching all necessary data for the textual description if a user is currently online
45 * @param Page $page visited page
46 * @param UserOnline $user user online object with request data
47 * @see IOnlineLocationPageHandler::prepareOnlineLocation()
49 public function prepareOnlineLocation(/** @noinspection PhpUnusedParameterInspection */Page
$page, UserOnline
$user) {
50 if ($user->pageObjectID
!== null) {
51 UserRuntimeCache
::getInstance()->cacheObjectID($user->pageObjectID
);