Commit | Line | Data |
---|---|---|
11ade432 | 1 | <?php |
a9229942 | 2 | |
11ade432 | 3 | namespace wcf\data\acp\session; |
a9229942 | 4 | |
11ade432 | 5 | use wcf\data\DatabaseObject; |
945667b7 | 6 | use wcf\system\WCF; |
11ade432 AE |
7 | |
8 | /** | |
9 | * Represents an ACP session. | |
e9335ed9 | 10 | * |
a9229942 TD |
11 | * @author Alexander Ebert |
12 | * @copyright 2001-2019 WoltLab GmbH | |
13 | * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php> | |
a9229942 TD |
14 | * |
15 | * @property-read string $sessionID unique textual identifier of the acp session | |
16 | * @property-read int|null $userID id of the user the acp session belongs to or `null` if the acp session belongs to a guest | |
17 | * @property-read string $ipAddress id of the user whom the acp session belongs to | |
18 | * @property-read string $userAgent user agent of the user whom the acp session belongs to | |
19 | * @property-read int $lastActivityTime timestamp at which the latest activity occurred | |
20 | * @property-read string $requestURI uri of the latest request | |
21 | * @property-read string $requestMethod used request method of the latest request (`GET`, `POST`) | |
22 | * @property-read string $sessionVariables serialized array with variables stored on a session-basis | |
db579a51 | 23 | * @deprecated 5.4 Distinct ACP sessions have been removed. This class is preserved due to its use in legacy sessions. |
11ade432 | 24 | */ |
a9229942 TD |
25 | class ACPSession extends DatabaseObject |
26 | { | |
27 | /** | |
28 | * @inheritDoc | |
29 | */ | |
30 | protected static $databaseTableIndexIsIdentity = false; | |
31 | ||
32 | /** | |
33 | * Returns true if this session type supports persistent logins. | |
34 | * | |
35 | * @return bool | |
36 | */ | |
37 | public static function supportsPersistentLogins() | |
38 | { | |
39 | return false; | |
40 | } | |
41 | ||
42 | /** | |
43 | * Returns the existing session object for given user id or null if there | |
44 | * is no such session. | |
45 | * | |
46 | * @param int $userID | |
47 | * @return ACPSession | |
48 | */ | |
49 | public static function getSessionByUserID($userID) | |
50 | { | |
51 | $sql = "SELECT * | |
52 | FROM " . static::getDatabaseTableName() . " | |
53 | WHERE userID = ?"; | |
54 | $statement = WCF::getDB()->prepareStatement($sql); | |
55 | $statement->execute([$userID]); | |
56 | ||
57 | return $statement->fetchObject(static::class); | |
58 | } | |
11ade432 | 59 | } |