Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / people / query / PhabricatorPeopleUserEmailQuery.php
blob6e2627a96d924a34f26c1213e79f3f3a5f97cb91
1 <?php
3 final class PhabricatorPeopleUserEmailQuery
4 extends PhabricatorCursorPagedPolicyAwareQuery {
6 private $ids;
7 private $phids;
9 public function withIDs(array $ids) {
10 $this->ids = $ids;
11 return $this;
14 public function withPHIDs(array $phids) {
15 $this->phids = $phids;
16 return $this;
19 public function newResultObject() {
20 return new PhabricatorUserEmail();
23 protected function loadPage() {
24 return $this->loadStandardPage($this->newResultObject());
27 protected function getPrimaryTableAlias() {
28 return 'email';
31 protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
32 $where = parent::buildWhereClauseParts($conn);
34 if ($this->ids !== null) {
35 $where[] = qsprintf(
36 $conn,
37 'email.id IN (%Ld)',
38 $this->ids);
41 if ($this->phids !== null) {
42 $where[] = qsprintf(
43 $conn,
44 'email.phid IN (%Ls)',
45 $this->phids);
48 return $where;
51 protected function willLoadPage(array $page) {
53 $user_phids = mpull($page, 'getUserPHID');
55 $users = id(new PhabricatorPeopleQuery())
56 ->setViewer($this->getViewer())
57 ->setParentQuery($this)
58 ->withPHIDs($user_phids)
59 ->execute();
60 $users = mpull($users, null, 'getPHID');
62 foreach ($page as $key => $address) {
63 $user = idx($users, $address->getUserPHID());
65 if (!$user) {
66 unset($page[$key]);
67 $this->didRejectResult($address);
68 continue;
71 $address->attachUser($user);
74 return $page;
77 public function getQueryApplicationClass() {
78 return 'PhabricatorPeopleApplication';