3 namespace wcf\system\page\handler
;
5 use wcf\data\conversation\Conversation
;
6 use wcf\data\page\Page
;
7 use wcf\data\user\online\UserOnline
;
8 use wcf\system\cache\runtime\UserConversationRuntimeCache
;
12 * Implementation of the online location-related page handler methods for conversations.
14 * @author Matthias Schmidt
15 * @copyright 2001-2019 WoltLab GmbH
16 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
17 * @package WoltLabSuite\Core\System\Page\Handler
20 trait TConversationOnlineLocationPageHandler
22 use TOnlineLocationPageHandler
;
25 * Returns the textual description if a user is currently online viewing this page.
27 * @param Page $page visited page
28 * @param UserOnline $user user online object with request data
30 * @see IOnlineLocationPageHandler::getOnlineLocation()
33 public function getOnlineLocation(Page
$page, UserOnline
$user)
35 if ($user->pageObjectID
=== null) {
39 $conversation = UserConversationRuntimeCache
::getInstance()->getObject($user->pageObjectID
);
40 if ($conversation === null ||
!$conversation->canRead()) {
44 if ($conversation->userID
!= WCF
::getUser()->userID
&& $user->userID
!= WCF
::getUser()->userID
) {
45 // Make sure that requests from invisible participants are not listed
46 // if the active user is not the author of the conversation.
47 $userConversation = Conversation
::getUserConversation($conversation->conversationID
, $user->userID
);
48 if ($userConversation !== null && $userConversation->isInvisible
) {
53 return WCF
::getLanguage()->getDynamicVariable(
54 'wcf.page.onlineLocation.' . $page->identifier
,
55 ['conversation' => $conversation]
60 * Prepares fetching all necessary data for the textual description if a user is currently online
63 * @param Page $page visited page
64 * @param UserOnline $user user online object with request data
65 * @see IOnlineLocationPageHandler::prepareOnlineLocation()
67 public function prepareOnlineLocation(
71 if ($user->pageObjectID
!== null) {
72 UserConversationRuntimeCache
::getInstance()->cacheObjectID($user->pageObjectID
);