Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / auth / query / PhabricatorAuthTemporaryTokenQuery.php
blobc5cb39096c0531ea52691ccb5c996973b013a6d0
1 <?php
3 final class PhabricatorAuthTemporaryTokenQuery
4 extends PhabricatorCursorPagedPolicyAwareQuery {
6 private $ids;
7 private $tokenResources;
8 private $tokenTypes;
9 private $userPHIDs;
10 private $expired;
11 private $tokenCodes;
13 public function withIDs(array $ids) {
14 $this->ids = $ids;
15 return $this;
18 public function withTokenResources(array $resources) {
19 $this->tokenResources = $resources;
20 return $this;
23 public function withTokenTypes(array $types) {
24 $this->tokenTypes = $types;
25 return $this;
28 public function withExpired($expired) {
29 $this->expired = $expired;
30 return $this;
33 public function withTokenCodes(array $codes) {
34 $this->tokenCodes = $codes;
35 return $this;
38 public function withUserPHIDs(array $phids) {
39 $this->userPHIDs = $phids;
40 return $this;
43 public function newResultObject() {
44 return new PhabricatorAuthTemporaryToken();
47 protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
48 $where = parent::buildWhereClauseParts($conn);
50 if ($this->ids !== null) {
51 $where[] = qsprintf(
52 $conn,
53 'id IN (%Ld)',
54 $this->ids);
57 if ($this->tokenResources !== null) {
58 $where[] = qsprintf(
59 $conn,
60 'tokenResource IN (%Ls)',
61 $this->tokenResources);
64 if ($this->tokenTypes !== null) {
65 $where[] = qsprintf(
66 $conn,
67 'tokenType IN (%Ls)',
68 $this->tokenTypes);
71 if ($this->expired !== null) {
72 if ($this->expired) {
73 $where[] = qsprintf(
74 $conn,
75 'tokenExpires <= %d',
76 time());
77 } else {
78 $where[] = qsprintf(
79 $conn,
80 'tokenExpires > %d',
81 time());
85 if ($this->tokenCodes !== null) {
86 $where[] = qsprintf(
87 $conn,
88 'tokenCode IN (%Ls)',
89 $this->tokenCodes);
92 if ($this->userPHIDs !== null) {
93 $where[] = qsprintf(
94 $conn,
95 'userPHID IN (%Ls)',
96 $this->userPHIDs);
99 return $where;
102 public function getQueryApplicationClass() {
103 return 'PhabricatorAuthApplication';