Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/auth/query/PhabricatorAuthTemporaryTokenQuery.php
12256 views
1
<?php
2
3
final class PhabricatorAuthTemporaryTokenQuery
4
extends PhabricatorCursorPagedPolicyAwareQuery {
5
6
private $ids;
7
private $tokenResources;
8
private $tokenTypes;
9
private $userPHIDs;
10
private $expired;
11
private $tokenCodes;
12
13
public function withIDs(array $ids) {
14
$this->ids = $ids;
15
return $this;
16
}
17
18
public function withTokenResources(array $resources) {
19
$this->tokenResources = $resources;
20
return $this;
21
}
22
23
public function withTokenTypes(array $types) {
24
$this->tokenTypes = $types;
25
return $this;
26
}
27
28
public function withExpired($expired) {
29
$this->expired = $expired;
30
return $this;
31
}
32
33
public function withTokenCodes(array $codes) {
34
$this->tokenCodes = $codes;
35
return $this;
36
}
37
38
public function withUserPHIDs(array $phids) {
39
$this->userPHIDs = $phids;
40
return $this;
41
}
42
43
public function newResultObject() {
44
return new PhabricatorAuthTemporaryToken();
45
}
46
47
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
48
$where = parent::buildWhereClauseParts($conn);
49
50
if ($this->ids !== null) {
51
$where[] = qsprintf(
52
$conn,
53
'id IN (%Ld)',
54
$this->ids);
55
}
56
57
if ($this->tokenResources !== null) {
58
$where[] = qsprintf(
59
$conn,
60
'tokenResource IN (%Ls)',
61
$this->tokenResources);
62
}
63
64
if ($this->tokenTypes !== null) {
65
$where[] = qsprintf(
66
$conn,
67
'tokenType IN (%Ls)',
68
$this->tokenTypes);
69
}
70
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());
82
}
83
}
84
85
if ($this->tokenCodes !== null) {
86
$where[] = qsprintf(
87
$conn,
88
'tokenCode IN (%Ls)',
89
$this->tokenCodes);
90
}
91
92
if ($this->userPHIDs !== null) {
93
$where[] = qsprintf(
94
$conn,
95
'userPHID IN (%Ls)',
96
$this->userPHIDs);
97
}
98
99
return $where;
100
}
101
102
public function getQueryApplicationClass() {
103
return 'PhabricatorAuthApplication';
104
}
105
106
}
107
108