@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 119 lines 2.6 kB view raw
1<?php 2 3abstract class PhabricatorApplicationTransactionCommentQuery 4 extends PhabricatorCursorPagedPolicyAwareQuery { 5 6 private $ids; 7 private $authorPHIDs; 8 private $phids; 9 private $transactionPHIDs; 10 private $isDeleted; 11 private $hasTransaction; 12 13 abstract protected function newApplicationTransactionCommentTemplate(); 14 15 public function withIDs(array $ids) { 16 $this->ids = $ids; 17 return $this; 18 } 19 20 public function withPHIDs(array $phids) { 21 $this->phids = $phids; 22 return $this; 23 } 24 25 public function withTransactionPHIDs(array $transaction_phids) { 26 $this->transactionPHIDs = $transaction_phids; 27 return $this; 28 } 29 30 public function withAuthorPHIDs(array $phids) { 31 $this->authorPHIDs = $phids; 32 return $this; 33 } 34 35 public function withIsDeleted($deleted) { 36 $this->isDeleted = $deleted; 37 return $this; 38 } 39 40 public function withHasTransaction($has_transaction) { 41 $this->hasTransaction = $has_transaction; 42 return $this; 43 } 44 45 public function newResultObject() { 46 return $this->newApplicationTransactionCommentTemplate(); 47 } 48 49 protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { 50 $where = parent::buildWhereClauseParts($conn); 51 $alias = $this->getPrimaryTableAlias(); 52 53 if ($this->ids !== null) { 54 $where[] = qsprintf( 55 $conn, 56 '%T.id IN (%Ld)', 57 $alias, 58 $this->ids); 59 } 60 61 if ($this->phids !== null) { 62 $where[] = qsprintf( 63 $conn, 64 '%T.phid IN (%Ls)', 65 $alias, 66 $this->phids); 67 } 68 69 if ($this->authorPHIDs !== null) { 70 $where[] = qsprintf( 71 $conn, 72 '%T.authorPHID IN (%Ls)', 73 $alias, 74 $this->authorPHIDs); 75 } 76 77 if ($this->transactionPHIDs !== null) { 78 $where[] = qsprintf( 79 $conn, 80 '%T.transactionPHID IN (%Ls)', 81 $alias, 82 $this->transactionPHIDs); 83 } 84 85 if ($this->isDeleted !== null) { 86 $where[] = qsprintf( 87 $conn, 88 '%T.isDeleted = %d', 89 $alias, 90 (int)$this->isDeleted); 91 } 92 93 if ($this->hasTransaction !== null) { 94 if ($this->hasTransaction) { 95 $where[] = qsprintf( 96 $conn, 97 '%T.transactionPHID IS NOT NULL', 98 $alias); 99 } else { 100 $where[] = qsprintf( 101 $conn, 102 '%T.transactionPHID IS NULL', 103 $alias); 104 } 105 } 106 107 return $where; 108 } 109 110 protected function getPrimaryTableAlias() { 111 return 'xcomment'; 112 } 113 114 public function getQueryApplicationClass() { 115 // TODO: Figure out the app via the template? 116 return null; 117 } 118 119}