Overhauled page title management
[GitHub/WoltLab/WCF.git] / wcfsetup / install / files / lib / system / user / online / location / UserLocation.class.php
1 <?php
2 namespace wcf\system\user\online\location;
3 use wcf\data\user\online\UserOnline;
4 use wcf\data\user\User;
5 use wcf\data\user\UserList;
6 use wcf\system\WCF;
7
8 /**
9 * Implementation of IUserOnlineLocation for the user profile location.
10 *
11 * @author Marcel Werk
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
15 * @subpackage system.user.online.location
16 * @category Community Framework
17 * @deprecated since 2.2
18 */
19 class UserLocation implements IUserOnlineLocation {
20 /**
21 * user ids
22 * @var integer[]
23 */
24 protected $userIDs = [];
25
26 /**
27 * list of users
28 * @var User[]
29 */
30 protected $users = null;
31
32 /**
33 * @inheritDoc
34 */
35 public function cache(UserOnline $user) {
36 if ($user->objectID) $this->userIDs[] = $user->objectID;
37 }
38
39 /**
40 * @inheritDoc
41 */
42 public function get(UserOnline $user, $languageVariable = '') {
43 if ($this->users === null) {
44 $this->readUsers();
45 }
46
47 if (!isset($this->users[$user->objectID])) {
48 return '';
49 }
50
51 return WCF::getLanguage()->getDynamicVariable($languageVariable, ['user' => $this->users[$user->objectID]]);
52 }
53
54 /**
55 * Loads the users.
56 */
57 protected function readUsers() {
58 $this->users = [];
59
60 if (empty($this->userIDs)) return;
61 $this->userIDs = array_unique($this->userIDs);
62
63 $userList = new UserList();
64 $userList->setObjectIDs($this->userIDs);
65 $userList->readObjects();
66 $this->users = $userList->getObjects();
67 }
68 }