Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/auth/query/PhabricatorAuthInviteSearchEngine.php
12256 views
1
<?php
2
3
final class PhabricatorAuthInviteSearchEngine
4
extends PhabricatorApplicationSearchEngine {
5
6
public function getResultTypeDescription() {
7
return pht('Auth Email Invites');
8
}
9
10
public function getApplicationClassName() {
11
return 'PhabricatorAuthApplication';
12
}
13
14
public function canUseInPanelContext() {
15
return false;
16
}
17
18
public function buildSavedQueryFromRequest(AphrontRequest $request) {
19
$saved = new PhabricatorSavedQuery();
20
21
return $saved;
22
}
23
24
public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
25
$query = id(new PhabricatorAuthInviteQuery());
26
27
return $query;
28
}
29
30
public function buildSearchForm(
31
AphrontFormView $form,
32
PhabricatorSavedQuery $saved) {}
33
34
protected function getURI($path) {
35
return '/people/invite/'.$path;
36
}
37
38
protected function getBuiltinQueryNames() {
39
$names = array(
40
'all' => pht('All'),
41
);
42
43
return $names;
44
}
45
46
public function buildSavedQueryFromBuiltin($query_key) {
47
$query = $this->newSavedQuery();
48
$query->setQueryKey($query_key);
49
50
switch ($query_key) {
51
case 'all':
52
return $query;
53
}
54
55
return parent::buildSavedQueryFromBuiltin($query_key);
56
}
57
58
protected function getRequiredHandlePHIDsForResultList(
59
array $invites,
60
PhabricatorSavedQuery $query) {
61
62
$phids = array();
63
foreach ($invites as $invite) {
64
$phids[$invite->getAuthorPHID()] = true;
65
if ($invite->getAcceptedByPHID()) {
66
$phids[$invite->getAcceptedByPHID()] = true;
67
}
68
}
69
70
return array_keys($phids);
71
}
72
73
protected function renderResultList(
74
array $invites,
75
PhabricatorSavedQuery $query,
76
array $handles) {
77
assert_instances_of($invites, 'PhabricatorAuthInvite');
78
79
$viewer = $this->requireViewer();
80
81
$rows = array();
82
foreach ($invites as $invite) {
83
$rows[] = array(
84
$invite->getEmailAddress(),
85
$handles[$invite->getAuthorPHID()]->renderLink(),
86
($invite->getAcceptedByPHID()
87
? $handles[$invite->getAcceptedByPHID()]->renderLink()
88
: null),
89
phabricator_datetime($invite->getDateCreated(), $viewer),
90
);
91
}
92
93
$table = id(new AphrontTableView($rows))
94
->setHeaders(
95
array(
96
pht('Email Address'),
97
pht('Sent By'),
98
pht('Accepted By'),
99
pht('Invited'),
100
))
101
->setColumnClasses(
102
array(
103
'',
104
'',
105
'wide',
106
'right',
107
));
108
109
$result = new PhabricatorApplicationSearchResultView();
110
$result->setTable($table);
111
112
return $result;
113
}
114
}
115
116