Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/dashboard/query/PhabricatorDashboardPanelQuery.php
12242 views
1
<?php
2
3
final class PhabricatorDashboardPanelQuery
4
extends PhabricatorCursorPagedPolicyAwareQuery {
5
6
private $ids;
7
private $phids;
8
private $archived;
9
private $panelTypes;
10
private $authorPHIDs;
11
12
public function withIDs(array $ids) {
13
$this->ids = $ids;
14
return $this;
15
}
16
17
public function withPHIDs(array $phids) {
18
$this->phids = $phids;
19
return $this;
20
}
21
22
public function withArchived($archived) {
23
$this->archived = $archived;
24
return $this;
25
}
26
27
public function withPanelTypes(array $types) {
28
$this->panelTypes = $types;
29
return $this;
30
}
31
32
public function withAuthorPHIDs(array $authors) {
33
$this->authorPHIDs = $authors;
34
return $this;
35
}
36
37
public function newResultObject() {
38
// TODO: If we don't do this, SearchEngine explodes when trying to
39
// enumerate custom fields. For now, just give the panel a default panel
40
// type so custom fields work. In the long run, we may want to find a
41
// cleaner or more general approach for this.
42
$text_type = id(new PhabricatorDashboardTextPanelType())
43
->getPanelTypeKey();
44
45
return id(new PhabricatorDashboardPanel())
46
->setPanelType($text_type);
47
}
48
49
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
50
$where = parent::buildWhereClauseParts($conn);
51
52
if ($this->ids !== null) {
53
$where[] = qsprintf(
54
$conn,
55
'panel.id IN (%Ld)',
56
$this->ids);
57
}
58
59
if ($this->phids !== null) {
60
$where[] = qsprintf(
61
$conn,
62
'panel.phid IN (%Ls)',
63
$this->phids);
64
}
65
66
if ($this->archived !== null) {
67
$where[] = qsprintf(
68
$conn,
69
'panel.isArchived = %d',
70
(int)$this->archived);
71
}
72
73
if ($this->panelTypes !== null) {
74
$where[] = qsprintf(
75
$conn,
76
'panel.panelType IN (%Ls)',
77
$this->panelTypes);
78
}
79
80
if ($this->authorPHIDs !== null) {
81
$where[] = qsprintf(
82
$conn,
83
'panel.authorPHID IN (%Ls)',
84
$this->authorPHIDs);
85
}
86
87
return $where;
88
}
89
90
public function getQueryApplicationClass() {
91
return 'PhabricatorDashboardApplication';
92
}
93
94
protected function getPrimaryTableAlias() {
95
return 'panel';
96
}
97
98
}
99
100