2012-04-05 02:51:16 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorOAuthServerClientQuery
|
2014-03-18 21:27:55 +01:00
|
|
|
extends PhabricatorCursorPagedPolicyAwareQuery {
|
|
|
|
|
2014-03-18 23:39:45 +01:00
|
|
|
private $ids;
|
2014-03-18 21:27:55 +01:00
|
|
|
private $phids;
|
2012-04-05 02:51:16 +02:00
|
|
|
private $creatorPHIDs;
|
|
|
|
|
2014-03-18 23:39:45 +01:00
|
|
|
public function withIDs(array $ids) {
|
|
|
|
$this->ids = $ids;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2014-03-18 21:27:55 +01:00
|
|
|
public function withPHIDs(array $phids) {
|
|
|
|
$this->phids = $phids;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2012-04-05 02:51:16 +02:00
|
|
|
public function withCreatorPHIDs(array $phids) {
|
|
|
|
$this->creatorPHIDs = $phids;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2014-03-18 21:27:55 +01:00
|
|
|
public function loadPage() {
|
2012-04-05 02:51:16 +02:00
|
|
|
$table = new PhabricatorOAuthServerClient();
|
|
|
|
$conn_r = $table->establishConnection('r');
|
|
|
|
|
|
|
|
$data = queryfx_all(
|
|
|
|
$conn_r,
|
2014-03-18 21:31:04 +01:00
|
|
|
'SELECT * FROM %T client %Q %Q %Q',
|
2012-04-05 02:51:16 +02:00
|
|
|
$table->getTableName(),
|
2014-03-18 21:31:04 +01:00
|
|
|
$this->buildWhereClause($conn_r),
|
|
|
|
$this->buildOrderClause($conn_r),
|
|
|
|
$this->buildLimitClause($conn_r));
|
2012-04-05 02:51:16 +02:00
|
|
|
|
|
|
|
return $table->loadAllFromArray($data);
|
|
|
|
}
|
|
|
|
|
|
|
|
private function buildWhereClause($conn_r) {
|
|
|
|
$where = array();
|
|
|
|
|
2014-03-18 23:39:45 +01:00
|
|
|
if ($this->ids) {
|
|
|
|
$where[] = qsprintf(
|
|
|
|
$conn_r,
|
|
|
|
'id IN (%Ld)',
|
|
|
|
$this->ids);
|
|
|
|
}
|
|
|
|
|
2014-03-18 21:27:55 +01:00
|
|
|
if ($this->phids) {
|
|
|
|
$where[] = qsprintf(
|
|
|
|
$conn_r,
|
|
|
|
'phid IN (%Ls)',
|
|
|
|
$this->phids);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->creatorPHIDs) {
|
2012-04-05 02:51:16 +02:00
|
|
|
$where[] = qsprintf(
|
|
|
|
$conn_r,
|
|
|
|
'creatorPHID IN (%Ls)',
|
2014-03-18 21:27:55 +01:00
|
|
|
$this->creatorPHIDs);
|
2012-04-05 02:51:16 +02:00
|
|
|
}
|
|
|
|
|
2014-03-18 21:27:55 +01:00
|
|
|
$where[] = $this->buildPagingClause($conn_r);
|
|
|
|
|
2012-04-05 02:51:16 +02:00
|
|
|
return $this->formatWhereClause($where);
|
|
|
|
}
|
2014-03-18 21:27:55 +01:00
|
|
|
|
|
|
|
public function getQueryApplicationClass() {
|
2014-07-23 02:03:09 +02:00
|
|
|
return 'PhabricatorOAuthServerApplication';
|
2014-03-18 21:27:55 +01:00
|
|
|
}
|
|
|
|
|
2012-04-05 02:51:16 +02:00
|
|
|
}
|