Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/calendar/query/PhabricatorCalendarImportQuery.php
12256 views
1
<?php
2
3
final class PhabricatorCalendarImportQuery
4
extends PhabricatorCursorPagedPolicyAwareQuery {
5
6
private $ids;
7
private $phids;
8
private $authorPHIDs;
9
private $isDisabled;
10
11
public function withIDs(array $ids) {
12
$this->ids = $ids;
13
return $this;
14
}
15
16
public function withPHIDs(array $phids) {
17
$this->phids = $phids;
18
return $this;
19
}
20
21
public function withAuthorPHIDs(array $phids) {
22
$this->authorPHIDs = $phids;
23
return $this;
24
}
25
26
public function withIsDisabled($is_disabled) {
27
$this->isDisabled = $is_disabled;
28
return $this;
29
}
30
31
public function newResultObject() {
32
return new PhabricatorCalendarImport();
33
}
34
35
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
36
$where = parent::buildWhereClauseParts($conn);
37
38
if ($this->ids !== null) {
39
$where[] = qsprintf(
40
$conn,
41
'import.id IN (%Ld)',
42
$this->ids);
43
}
44
45
if ($this->phids !== null) {
46
$where[] = qsprintf(
47
$conn,
48
'import.phid IN (%Ls)',
49
$this->phids);
50
}
51
52
if ($this->authorPHIDs !== null) {
53
$where[] = qsprintf(
54
$conn,
55
'import.authorPHID IN (%Ls)',
56
$this->authorPHIDs);
57
}
58
59
if ($this->isDisabled !== null) {
60
$where[] = qsprintf(
61
$conn,
62
'import.isDisabled = %d',
63
(int)$this->isDisabled);
64
}
65
66
return $where;
67
}
68
69
protected function willFilterPage(array $page) {
70
$engines = PhabricatorCalendarImportEngine::getAllImportEngines();
71
foreach ($page as $key => $import) {
72
$engine_type = $import->getEngineType();
73
$engine = idx($engines, $engine_type);
74
75
if (!$engine) {
76
unset($page[$key]);
77
$this->didRejectResult($import);
78
continue;
79
}
80
81
$import->attachEngine(clone $engine);
82
}
83
84
return $page;
85
}
86
87
protected function getPrimaryTableAlias() {
88
return 'import';
89
}
90
91
public function getQueryApplicationClass() {
92
return 'PhabricatorCalendarApplication';
93
}
94
95
}
96
97