Path: blob/master/src/applications/metamta/query/PhabricatorMetaMTAMailQuery.php
12256 views
<?php12final class PhabricatorMetaMTAMailQuery3extends PhabricatorCursorPagedPolicyAwareQuery {45private $ids;6private $phids;7private $actorPHIDs;8private $recipientPHIDs;9private $createdMin;10private $createdMax;1112public function withIDs(array $ids) {13$this->ids = $ids;14return $this;15}1617public function withPHIDs(array $phids) {18$this->phids = $phids;19return $this;20}2122public function withActorPHIDs(array $phids) {23$this->actorPHIDs = $phids;24return $this;25}2627public function withRecipientPHIDs(array $phids) {28$this->recipientPHIDs = $phids;29return $this;30}3132public function withDateCreatedBetween($min, $max) {33$this->createdMin = $min;34$this->createdMax = $max;35return $this;36}3738protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {39$where = parent::buildWhereClauseParts($conn);4041if ($this->ids !== null) {42$where[] = qsprintf(43$conn,44'mail.id IN (%Ld)',45$this->ids);46}4748if ($this->phids !== null) {49$where[] = qsprintf(50$conn,51'mail.phid IN (%Ls)',52$this->phids);53}5455if ($this->actorPHIDs !== null) {56$where[] = qsprintf(57$conn,58'mail.actorPHID IN (%Ls)',59$this->actorPHIDs);60}6162if ($this->createdMin !== null) {63$where[] = qsprintf(64$conn,65'mail.dateCreated >= %d',66$this->createdMin);67}6869if ($this->createdMax !== null) {70$where[] = qsprintf(71$conn,72'mail.dateCreated <= %d',73$this->createdMax);74}7576return $where;77}7879protected function buildJoinClauseParts(AphrontDatabaseConnection $conn) {80$joins = parent::buildJoinClauseParts($conn);8182if ($this->shouldJoinRecipients()) {83$joins[] = qsprintf(84$conn,85'JOIN %T recipient86ON mail.phid = recipient.src87AND recipient.type = %d88AND recipient.dst IN (%Ls)',89PhabricatorEdgeConfig::TABLE_NAME_EDGE,90PhabricatorMetaMTAMailHasRecipientEdgeType::EDGECONST,91$this->recipientPHIDs);92}9394return $joins;95}9697private function shouldJoinRecipients() {98if ($this->recipientPHIDs === null) {99return false;100}101102return true;103}104105protected function getPrimaryTableAlias() {106return 'mail';107}108109public function newResultObject() {110return new PhabricatorMetaMTAMail();111}112113public function getQueryApplicationClass() {114return 'PhabricatorMetaMTAApplication';115}116117protected function shouldGroupQueryResultRows() {118if ($this->shouldJoinRecipients()) {119if (count($this->recipientPHIDs) > 1) {120return true;121}122}123124return parent::shouldGroupQueryResultRows();125}126127}128129130