Path: blob/master/src/applications/metamta/query/PhabricatorMetaMTAApplicationEmailQuery.php
12256 views
<?php12final class PhabricatorMetaMTAApplicationEmailQuery3extends PhabricatorCursorPagedPolicyAwareQuery {45private $ids;6private $phids;7private $addresses;8private $addressPrefix;9private $applicationPHIDs;1011public function withIDs(array $ids) {12$this->ids = $ids;13return $this;14}1516public function withPHIDs(array $phids) {17$this->phids = $phids;18return $this;19}2021public function withAddresses(array $addresses) {22$this->addresses = $addresses;23return $this;24}2526public function withAddressPrefix($prefix) {27$this->addressPrefix = $prefix;28return $this;29}3031public function withApplicationPHIDs(array $phids) {32$this->applicationPHIDs = $phids;33return $this;34}3536protected function loadPage() {37return $this->loadStandardPage(new PhabricatorMetaMTAApplicationEmail());38}3940protected function willFilterPage(array $app_emails) {41$app_emails_map = mgroup($app_emails, 'getApplicationPHID');42$applications = id(new PhabricatorApplicationQuery())43->setViewer($this->getViewer())44->withPHIDs(array_keys($app_emails_map))45->execute();46$applications = mpull($applications, null, 'getPHID');4748foreach ($app_emails_map as $app_phid => $app_emails_group) {49foreach ($app_emails_group as $app_email) {50$application = idx($applications, $app_phid);51if (!$application) {52unset($app_emails[$app_phid]);53continue;54}55$app_email->attachApplication($application);56}57}58return $app_emails;59}6061protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {62$where = parent::buildWhereClauseParts($conn);6364if ($this->addresses !== null) {65$where[] = qsprintf(66$conn,67'appemail.address IN (%Ls)',68$this->addresses);69}7071if ($this->addressPrefix !== null) {72$where[] = qsprintf(73$conn,74'appemail.address LIKE %>',75$this->addressPrefix);76}7778if ($this->applicationPHIDs !== null) {79$where[] = qsprintf(80$conn,81'appemail.applicationPHID IN (%Ls)',82$this->applicationPHIDs);83}8485if ($this->phids !== null) {86$where[] = qsprintf(87$conn,88'appemail.phid IN (%Ls)',89$this->phids);90}9192if ($this->ids !== null) {93$where[] = qsprintf(94$conn,95'appemail.id IN (%Ld)',96$this->ids);97}9899return $where;100}101102protected function getPrimaryTableAlias() {103return 'appemail';104}105106public function getQueryApplicationClass() {107return 'PhabricatorMetaMTAApplication';108}109110}111112113