@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 upstream/main 88 lines 2.0 kB view raw
1<?php 2 3/** 4 * @extends PhabricatorCursorPagedPolicyAwareQuery<PhabricatorOAuthClientAuthorization> 5 */ 6final class PhabricatorOAuthClientAuthorizationQuery 7 extends PhabricatorCursorPagedPolicyAwareQuery { 8 9 private $phids; 10 private $userPHIDs; 11 private $clientPHIDs; 12 13 public function withPHIDs(array $phids) { 14 $this->phids = $phids; 15 return $this; 16 } 17 18 public function withUserPHIDs(array $phids) { 19 $this->userPHIDs = $phids; 20 return $this; 21 } 22 23 public function withClientPHIDs(array $phids) { 24 $this->clientPHIDs = $phids; 25 return $this; 26 } 27 28 public function newResultObject() { 29 return new PhabricatorOAuthClientAuthorization(); 30 } 31 32 protected function willFilterPage(array $authorizations) { 33 $client_phids = mpull($authorizations, 'getClientPHID'); 34 35 $clients = id(new PhabricatorOAuthServerClientQuery()) 36 ->setViewer($this->getViewer()) 37 ->setParentQuery($this) 38 ->withPHIDs($client_phids) 39 ->execute(); 40 $clients = mpull($clients, null, 'getPHID'); 41 42 foreach ($authorizations as $key => $authorization) { 43 $client = idx($clients, $authorization->getClientPHID()); 44 45 if (!$client) { 46 $this->didRejectResult($authorization); 47 unset($authorizations[$key]); 48 continue; 49 } 50 51 $authorization->attachClient($client); 52 } 53 54 return $authorizations; 55 } 56 57 protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { 58 $where = parent::buildWhereClauseParts($conn); 59 60 if ($this->phids !== null) { 61 $where[] = qsprintf( 62 $conn, 63 'phid IN (%Ls)', 64 $this->phids); 65 } 66 67 if ($this->userPHIDs !== null) { 68 $where[] = qsprintf( 69 $conn, 70 'userPHID IN (%Ls)', 71 $this->userPHIDs); 72 } 73 74 if ($this->clientPHIDs !== null) { 75 $where[] = qsprintf( 76 $conn, 77 'clientPHID IN (%Ls)', 78 $this->clientPHIDs); 79 } 80 81 return $where; 82 } 83 84 public function getQueryApplicationClass() { 85 return PhabricatorOAuthServerApplication::class; 86 } 87 88}