Apply PSR-12 code style (#3886)
[GitHub/WoltLab/WCF.git] / wcfsetup / install / files / lib / data / acp / session / log / ACPSessionLog.class.php
CommitLineData
11ade432 1<?php
a9229942 2
11ade432 3namespace wcf\data\acp\session\log;
a9229942 4
11ade432
AE
5use wcf\data\DatabaseObject;
6use wcf\system\WCF;
ccc092e2 7use wcf\util\UserUtil;
11ade432
AE
8
9/**
ed6a4e42 10 * Represents a acp session log entry.
e9335ed9 11 *
a9229942
TD
12 * @author Marcel Werk
13 * @copyright 2001-2019 WoltLab GmbH
14 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
15 * @package WoltLabSuite\Core\Data\Acp\Session\Log
16 *
17 * @property-read int $sessionLogID unique id of the acp session log entry
18 * @property-read string $sessionID id of the acp session the acp session log entry belongs to
19 * @property-read int|null $userID id of the user who has caused the acp session log entry or `null`
20 * @property-read string $ipAddress ip address of the user who has caused the acp session access log entry
21 * @property-read string $hostname name of the internet host corresponding to the user's IP address
22 * @property-read string $userAgent user agent of the user who has caused the acp session access log entry
23 * @property-read int $time timestamp at which the acp session log entry has been created
24 * @property-read int $lastActivityTime timestamp at which the associated session has been active for the last time
25 * @property-read string|null $active has the corresponding acp session id as the value if the session is still active, otherwise `null`
11ade432 26 */
a9229942
TD
27class ACPSessionLog extends DatabaseObject
28{
29 /**
30 * @inheritDoc
31 */
32 protected static $databaseTableIndexName = 'sessionLogID';
33
34 /** @noinspection PhpMissingParentConstructorInspection */
35
36 /**
37 * @inheritDoc
38 */
39 public function __construct($id, ?array $row = null, ?DatabaseObject $object = null)
40 {
41 if ($id !== null) {
42 $sql = "SELECT acp_session_log.*, user_table.username, 0 AS active
43 FROM wcf" . WCF_N . "_acp_session_log acp_session_log
44 LEFT JOIN wcf" . WCF_N . "_user user_table
45 ON (user_table.userID = acp_session_log.userID)
46 WHERE acp_session_log.sessionLogID = ?";
47 $statement = WCF::getDB()->prepareStatement($sql);
48 $statement->execute([$id]);
49 $row = $statement->fetchArray();
50 } elseif ($object !== null) {
51 $row = $object->data;
52 }
53
54 $this->handleData($row);
55 }
56
57 /**
58 * @deprecated 5.4 - This method always returns false.
59 */
60 public function isActive()
61 {
62 return false;
63 }
64
65 /**
66 * @deprecated 5.4 - This method always returns false.
67 */
68 public function isActiveUserSession()
69 {
70 return false;
71 }
72
73 /**
74 * Returns the ip address and attempts to convert into IPv4.
75 *
76 * @return string
77 */
78 public function getIpAddress()
79 {
80 return UserUtil::convertIPv6To4($this->ipAddress);
81 }
11ade432 82}