@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
at recaptime-dev/main 98 lines 2.1 kB view raw
1<?php 2 3/** 4 * @extends PhabricatorCursorPagedPolicyAwareQuery<PhabricatorAuthChallenge> 5 */ 6final class PhabricatorAuthChallengeQuery 7 extends PhabricatorCursorPagedPolicyAwareQuery { 8 9 private $ids; 10 private $phids; 11 private $userPHIDs; 12 private $factorPHIDs; 13 private $challengeTTLMin; 14 private $challengeTTLMax; 15 16 public function withIDs(array $ids) { 17 $this->ids = $ids; 18 return $this; 19 } 20 21 public function withPHIDs(array $phids) { 22 $this->phids = $phids; 23 return $this; 24 } 25 26 public function withUserPHIDs(array $user_phids) { 27 $this->userPHIDs = $user_phids; 28 return $this; 29 } 30 31 public function withFactorPHIDs(array $factor_phids) { 32 $this->factorPHIDs = $factor_phids; 33 return $this; 34 } 35 36 public function withChallengeTTLBetween($challenge_min, $challenge_max) { 37 $this->challengeTTLMin = $challenge_min; 38 $this->challengeTTLMax = $challenge_max; 39 return $this; 40 } 41 42 public function newResultObject() { 43 return new PhabricatorAuthChallenge(); 44 } 45 46 protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { 47 $where = parent::buildWhereClauseParts($conn); 48 49 if ($this->ids !== null) { 50 $where[] = qsprintf( 51 $conn, 52 'id IN (%Ld)', 53 $this->ids); 54 } 55 56 if ($this->phids !== null) { 57 $where[] = qsprintf( 58 $conn, 59 'phid IN (%Ls)', 60 $this->phids); 61 } 62 63 if ($this->userPHIDs !== null) { 64 $where[] = qsprintf( 65 $conn, 66 'userPHID IN (%Ls)', 67 $this->userPHIDs); 68 } 69 70 if ($this->factorPHIDs !== null) { 71 $where[] = qsprintf( 72 $conn, 73 'factorPHID IN (%Ls)', 74 $this->factorPHIDs); 75 } 76 77 if ($this->challengeTTLMin !== null) { 78 $where[] = qsprintf( 79 $conn, 80 'challengeTTL >= %d', 81 $this->challengeTTLMin); 82 } 83 84 if ($this->challengeTTLMax !== null) { 85 $where[] = qsprintf( 86 $conn, 87 'challengeTTL <= %d', 88 $this->challengeTTLMax); 89 } 90 91 return $where; 92 } 93 94 public function getQueryApplicationClass() { 95 return PhabricatorAuthApplication::class; 96 } 97 98}