Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/people/query/PhabricatorPeopleLogQuery.php
12256 views
1
<?php
2
3
final class PhabricatorPeopleLogQuery
4
extends PhabricatorCursorPagedPolicyAwareQuery {
5
6
private $ids;
7
private $actorPHIDs;
8
private $userPHIDs;
9
private $relatedPHIDs;
10
private $sessionKeys;
11
private $actions;
12
private $remoteAddressPrefix;
13
private $dateCreatedMin;
14
private $dateCreatedMax;
15
16
public function withIDs(array $ids) {
17
$this->ids = $ids;
18
return $this;
19
}
20
21
public function withActorPHIDs(array $actor_phids) {
22
$this->actorPHIDs = $actor_phids;
23
return $this;
24
}
25
26
public function withUserPHIDs(array $user_phids) {
27
$this->userPHIDs = $user_phids;
28
return $this;
29
}
30
31
public function withRelatedPHIDs(array $related_phids) {
32
$this->relatedPHIDs = $related_phids;
33
return $this;
34
}
35
36
public function withSessionKeys(array $session_keys) {
37
$this->sessionKeys = $session_keys;
38
return $this;
39
}
40
41
public function withActions(array $actions) {
42
$this->actions = $actions;
43
return $this;
44
}
45
46
public function withRemoteAddressPrefix($remote_address_prefix) {
47
$this->remoteAddressPrefix = $remote_address_prefix;
48
return $this;
49
}
50
51
public function withDateCreatedBetween($min, $max) {
52
$this->dateCreatedMin = $min;
53
$this->dateCreatedMax = $max;
54
return $this;
55
}
56
57
public function newResultObject() {
58
return new PhabricatorUserLog();
59
}
60
61
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
62
$where = parent::buildWhereClauseParts($conn);
63
64
if ($this->ids !== null) {
65
$where[] = qsprintf(
66
$conn,
67
'id IN (%Ld)',
68
$this->ids);
69
}
70
71
if ($this->actorPHIDs !== null) {
72
$where[] = qsprintf(
73
$conn,
74
'actorPHID IN (%Ls)',
75
$this->actorPHIDs);
76
}
77
78
if ($this->userPHIDs !== null) {
79
$where[] = qsprintf(
80
$conn,
81
'userPHID IN (%Ls)',
82
$this->userPHIDs);
83
}
84
85
if ($this->relatedPHIDs !== null) {
86
$where[] = qsprintf(
87
$conn,
88
'(actorPHID IN (%Ls) OR userPHID IN (%Ls))',
89
$this->relatedPHIDs,
90
$this->relatedPHIDs);
91
}
92
93
if ($this->sessionKeys !== null) {
94
$where[] = qsprintf(
95
$conn,
96
'session IN (%Ls)',
97
$this->sessionKeys);
98
}
99
100
if ($this->actions !== null) {
101
$where[] = qsprintf(
102
$conn,
103
'action IN (%Ls)',
104
$this->actions);
105
}
106
107
if ($this->remoteAddressPrefix !== null) {
108
$where[] = qsprintf(
109
$conn,
110
'remoteAddr LIKE %>',
111
$this->remoteAddressPrefix);
112
}
113
114
if ($this->dateCreatedMin !== null) {
115
$where[] = qsprintf(
116
$conn,
117
'dateCreated >= %d',
118
$this->dateCreatedMin);
119
}
120
121
if ($this->dateCreatedMax !== null) {
122
$where[] = qsprintf(
123
$conn,
124
'dateCreated <= %d',
125
$this->dateCreatedMax);
126
}
127
128
return $where;
129
}
130
131
public function getQueryApplicationClass() {
132
return 'PhabricatorPeopleApplication';
133
}
134
135
}
136
137