Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/dashboard/query/PhabricatorDashboardQuery.php
12242 views
1
<?php
2
3
final class PhabricatorDashboardQuery
4
extends PhabricatorCursorPagedPolicyAwareQuery {
5
6
private $ids;
7
private $phids;
8
private $statuses;
9
private $authorPHIDs;
10
private $canEdit;
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 withStatuses(array $statuses) {
23
$this->statuses = $statuses;
24
return $this;
25
}
26
27
public function withAuthorPHIDs(array $authors) {
28
$this->authorPHIDs = $authors;
29
return $this;
30
}
31
32
public function withCanEdit($can_edit) {
33
$this->canEdit = $can_edit;
34
return $this;
35
}
36
37
public function newResultObject() {
38
return new PhabricatorDashboard();
39
}
40
41
protected function didFilterPage(array $dashboards) {
42
43
$phids = mpull($dashboards, 'getPHID');
44
45
if ($this->canEdit) {
46
$dashboards = id(new PhabricatorPolicyFilter())
47
->setViewer($this->getViewer())
48
->requireCapabilities(array(
49
PhabricatorPolicyCapability::CAN_EDIT,
50
))
51
->apply($dashboards);
52
}
53
54
return $dashboards;
55
}
56
57
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
58
$where = parent::buildWhereClauseParts($conn);
59
60
if ($this->ids !== null) {
61
$where[] = qsprintf(
62
$conn,
63
'dashboard.id IN (%Ld)',
64
$this->ids);
65
}
66
67
if ($this->phids !== null) {
68
$where[] = qsprintf(
69
$conn,
70
'dashboard.phid IN (%Ls)',
71
$this->phids);
72
}
73
74
if ($this->statuses !== null) {
75
$where[] = qsprintf(
76
$conn,
77
'dashboard.status IN (%Ls)',
78
$this->statuses);
79
}
80
81
if ($this->authorPHIDs !== null) {
82
$where[] = qsprintf(
83
$conn,
84
'dashboard.authorPHID IN (%Ls)',
85
$this->authorPHIDs);
86
}
87
88
return $where;
89
}
90
91
public function getQueryApplicationClass() {
92
return 'PhabricatorDashboardApplication';
93
}
94
95
protected function getPrimaryTableAlias() {
96
return 'dashboard';
97
}
98
99
}
100
101