3 use wcf\data\page\PageCache
;
4 use wcf\data\user\online\UserOnline
;
5 use wcf\data\user\online\UsersOnlineList
;
6 use wcf\system\page\handler\IOnlineLocationPageHandler
;
7 use wcf\system\page\PageLocationManager
;
8 use wcf\system\request\LinkHandler
;
10 use wcf\util\HeaderUtil
;
13 * Shows page which lists all users who are online.
16 * @copyright 2001-2016 WoltLab GmbH
17 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
18 * @package com.woltlab.wcf
20 * @category Community Framework
22 * @property UsersOnlineList $objectList
24 class UsersOnlineListPage
extends SortablePage
{
28 public $neededPermissions = ['user.profile.canViewUsersOnlineList'];
33 public $enableTracking = true;
38 public $itemsPerPage = 100;
43 public $defaultSortField = USERS_ONLINE_DEFAULT_SORT_FIELD
;
48 public $defaultSortOrder = USERS_ONLINE_DEFAULT_SORT_ORDER
;
53 public $validSortFields = ['username', 'lastActivityTime', 'requestURI'];
58 public $objectListClassName = UsersOnlineList
::class;
64 public $locations = [];
69 public function readParameters() {
70 parent
::readParameters();
72 if (WCF
::getSession()->getPermission('admin.user.canViewIpAddress')) {
73 $this->validSortFields
[] = 'ipAddress';
74 $this->validSortFields
[] = 'userAgent';
78 HeaderUtil
::redirect(LinkHandler
::getInstance()->getLink('UsersOnlineList', [], 'sortField=' . $this->sortField
. '&sortOrder=' . $this->sortOrder
));
86 protected function initObjectList() {
87 parent
::initObjectList();
88 $this->objectList
->readStats();
89 $this->objectList
->checkRecord();
91 if (!USERS_ONLINE_SHOW_ROBOTS
) {
92 $this->objectList
->getConditionBuilder()->add('session.spiderID IS NULL');
94 if (!USERS_ONLINE_SHOW_GUESTS
) {
95 if (USERS_ONLINE_SHOW_ROBOTS
) {
96 $this->objectList
->getConditionBuilder()->add('(session.userID IS NOT NULL OR session.spiderID IS NOT NULL)');
99 $this->objectList
->getConditionBuilder()->add('session.userID IS NOT NULL');
107 public function readData() {
111 if (MODULE_MEMBERS_LIST
) PageLocationManager
::getInstance()->addParentLocation('com.woltlab.wcf.MembersList');
113 // cache all necessary data for showing locations
114 foreach ($this->objectList
as $userOnline) {
115 if ($userOnline->controller
) {
116 $page = PageCache
::getInstance()->getPageByController($userOnline->controller
);
117 if ($page !== null && $page->getHandler() !== null && $page->getHandler() instanceof IOnlineLocationPageHandler
) {
118 $page->getHandler()->prepareOnlineLocation($page, $userOnline);
124 /** @var UserOnline $userOnline */
125 foreach ($this->objectList
as $userOnline) {
126 $userOnline->setLocation();
133 public function assignVariables() {
134 parent
::assignVariables();
136 WCF
::getTPL()->assign([
137 'allowSpidersToIndexThisPage' => true
144 protected function readObjects() {
145 if ($this->sqlOrderBy
) $this->sqlOrderBy
= ($this->sortField
== 'lastActivityTime' ?
'session.' : '').$this->sqlOrderBy
;
146 parent
::readObjects();