Use page-based online location
[GitHub/WoltLab/com.woltlab.wcf.conversation.git] / files / lib / system / page / handler / TConversationOnlineLocationPageHandler.class.php
1 <?php
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\UserConversationRuntimeCache;
6 use wcf\system\WCF;
7
8 /**
9 * Implementation of the online location-related page handler methods for conversations.
10 *
11 * @author Matthias Schmidt
12 * @copyright 2001-2016 WoltLab GmbH
13 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
14 * @package com.woltlab.wcf.conversation
15 * @subpackage system.page.handler
16 * @category Community Framework
17 * @since 2.2
18 */
19 trait TConversationOnlineLocationPageHandler {
20 use TOnlineLocationPageHandler;
21
22 /**
23 * @see IMenuPageHandler::getOnlineLocation()
24 */
25 public function getOnlineLocation(Page $page, UserOnline $user) {
26 if ($user->objectID === null) {
27 return '';
28 }
29
30 $conversation = UserConversationRuntimeCache::getInstance()->getObject($user->objectID);
31 if ($conversation === null || !$conversation->canRead()) {
32 return '';
33 }
34
35 return WCF::getLanguage()->getDynamicVariable('wcf.page.onlineLocation.'.$page->identifier, ['conversation' => $conversation]);
36 }
37
38 /**
39 * @see IOnlineLocationPageHandler::prepareOnlineLocation()
40 */
41 public function prepareOnlineLocation(Page $page, UserOnline $user) {
42 if ($user->objectID !== null) {
43 UserConversationRuntimeCache::getInstance()->cacheObjectID($user->objectID);
44 }
45 }
46 }