Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/people/query/PhabricatorPeopleUserEmailQuery.php
12256 views
1
<?php
2
3
final class PhabricatorPeopleUserEmailQuery
4
extends PhabricatorCursorPagedPolicyAwareQuery {
5
6
private $ids;
7
private $phids;
8
9
public function withIDs(array $ids) {
10
$this->ids = $ids;
11
return $this;
12
}
13
14
public function withPHIDs(array $phids) {
15
$this->phids = $phids;
16
return $this;
17
}
18
19
public function newResultObject() {
20
return new PhabricatorUserEmail();
21
}
22
23
protected function getPrimaryTableAlias() {
24
return 'email';
25
}
26
27
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
28
$where = parent::buildWhereClauseParts($conn);
29
30
if ($this->ids !== null) {
31
$where[] = qsprintf(
32
$conn,
33
'email.id IN (%Ld)',
34
$this->ids);
35
}
36
37
if ($this->phids !== null) {
38
$where[] = qsprintf(
39
$conn,
40
'email.phid IN (%Ls)',
41
$this->phids);
42
}
43
44
return $where;
45
}
46
47
protected function willLoadPage(array $page) {
48
49
$user_phids = mpull($page, 'getUserPHID');
50
51
$users = id(new PhabricatorPeopleQuery())
52
->setViewer($this->getViewer())
53
->setParentQuery($this)
54
->withPHIDs($user_phids)
55
->execute();
56
$users = mpull($users, null, 'getPHID');
57
58
foreach ($page as $key => $address) {
59
$user = idx($users, $address->getUserPHID());
60
61
if (!$user) {
62
unset($page[$key]);
63
$this->didRejectResult($address);
64
continue;
65
}
66
67
$address->attachUser($user);
68
}
69
70
return $page;
71
}
72
73
public function getQueryApplicationClass() {
74
return 'PhabricatorPeopleApplication';
75
}
76
77
}
78
79