Remove all "FileHasObject" edge reads and writes
[phabricator.git] / src / applications / auth / query / PhabricatorAuthTemporaryTokenQuery.php
blob72141f75f0d2ef8c86a0818f802922399fd82bcc
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 loadPage() {
48 return $this->loadStandardPage($this->newResultObject());
51 protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
52 $where = parent::buildWhereClauseParts($conn);
54 if ($this->ids !== null) {
55 $where[] = qsprintf(
56 $conn,
57 'id IN (%Ld)',
58 $this->ids);
61 if ($this->tokenResources !== null) {
62 $where[] = qsprintf(
63 $conn,
64 'tokenResource IN (%Ls)',
65 $this->tokenResources);
68 if ($this->tokenTypes !== null) {
69 $where[] = qsprintf(
70 $conn,
71 'tokenType IN (%Ls)',
72 $this->tokenTypes);
75 if ($this->expired !== null) {
76 if ($this->expired) {
77 $where[] = qsprintf(
78 $conn,
79 'tokenExpires <= %d',
80 time());
81 } else {
82 $where[] = qsprintf(
83 $conn,
84 'tokenExpires > %d',
85 time());
89 if ($this->tokenCodes !== null) {
90 $where[] = qsprintf(
91 $conn,
92 'tokenCode IN (%Ls)',
93 $this->tokenCodes);
96 if ($this->userPHIDs !== null) {
97 $where[] = qsprintf(
98 $conn,
99 'userPHID IN (%Ls)',
100 $this->userPHIDs);
103 return $where;
106 public function getQueryApplicationClass() {
107 return 'PhabricatorAuthApplication';