Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/countdown/query/PhabricatorCountdownQuery.php
12256 views
1
<?php
2
3
final class PhabricatorCountdownQuery
4
extends PhabricatorCursorPagedPolicyAwareQuery {
5
6
private $ids;
7
private $phids;
8
private $authorPHIDs;
9
private $upcoming;
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 $author_phids) {
22
$this->authorPHIDs = $author_phids;
23
return $this;
24
}
25
26
public function withUpcoming() {
27
$this->upcoming = true;
28
return $this;
29
}
30
31
public function newResultObject() {
32
return new PhabricatorCountdown();
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
'id IN (%Ld)',
42
$this->ids);
43
}
44
45
if ($this->phids !== null) {
46
$where[] = qsprintf(
47
$conn,
48
'phid IN (%Ls)',
49
$this->phids);
50
}
51
52
if ($this->authorPHIDs !== null) {
53
$where[] = qsprintf(
54
$conn,
55
'authorPHID in (%Ls)',
56
$this->authorPHIDs);
57
}
58
59
if ($this->upcoming !== null) {
60
$where[] = qsprintf(
61
$conn,
62
'epoch >= %d',
63
PhabricatorTime::getNow());
64
}
65
66
return $where;
67
}
68
69
public function getQueryApplicationClass() {
70
return 'PhabricatorCountdownApplication';
71
}
72
73
public function getBuiltinOrders() {
74
return array(
75
'ending' => array(
76
'vector' => array('-epoch', '-id'),
77
'name' => pht('End Date (Past to Future)'),
78
),
79
'unending' => array(
80
'vector' => array('epoch', 'id'),
81
'name' => pht('End Date (Future to Past)'),
82
),
83
) + parent::getBuiltinOrders();
84
}
85
86
public function getOrderableColumns() {
87
return array(
88
'epoch' => array(
89
'table' => $this->getPrimaryTableAlias(),
90
'column' => 'epoch',
91
'type' => 'int',
92
),
93
) + parent::getOrderableColumns();
94
}
95
96
protected function newPagingMapFromPartialObject($object) {
97
return array(
98
'id' => (int)$object->getID(),
99
'epoch' => (int)$object->getEpoch(),
100
);
101
}
102
103
}
104
105