Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/chatlog/query/PhabricatorChatLogChannelQuery.php
13402 views
1
<?php
2
3
final class PhabricatorChatLogChannelQuery
4
extends PhabricatorCursorPagedPolicyAwareQuery {
5
6
private $channels;
7
private $channelIDs;
8
9
public function withChannelNames(array $channels) {
10
$this->channels = $channels;
11
return $this;
12
}
13
14
public function withIDs(array $channel_ids) {
15
$this->channelIDs = $channel_ids;
16
return $this;
17
}
18
19
protected function loadPage() {
20
$table = new PhabricatorChatLogChannel();
21
$conn_r = $table->establishConnection('r');
22
23
$data = queryfx_all(
24
$conn_r,
25
'SELECT * FROM %T c %Q %Q %Q',
26
$table->getTableName(),
27
$this->buildWhereClause($conn_r),
28
$this->buildOrderClause($conn_r),
29
$this->buildLimitClause($conn_r));
30
31
$logs = $table->loadAllFromArray($data);
32
33
return $logs;
34
}
35
36
protected function buildWhereClause(AphrontDatabaseConnection $conn) {
37
$where = array();
38
39
$where[] = $this->buildPagingClause($conn);
40
41
if ($this->channelIDs) {
42
$where[] = qsprintf(
43
$conn,
44
'id IN (%Ld)',
45
$this->channelIDs);
46
47
}
48
49
if ($this->channels) {
50
$where[] = qsprintf(
51
$conn,
52
'channelName IN (%Ls)',
53
$this->channels);
54
}
55
56
return $this->formatWhereClause($conn, $where);
57
}
58
59
public function getQueryApplicationClass() {
60
return 'PhabricatorChatLogApplication';
61
}
62
63
}
64
65