2012-04-05 02:51:16 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorOAuthServerClientQuery
|
2014-03-18 21:27:55 +01:00
|
|
|
extends PhabricatorCursorPagedPolicyAwareQuery {
|
|
|
|
|
|
|
|
private $phids;
|
2012-04-05 02:51:16 +02:00
|
|
|
private $creatorPHIDs;
|
|
|
|
|
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');
|
|
|
|
|
|
|
|
$where_clause = $this->buildWhereClause($conn_r);
|
|
|
|
$limit_clause = $this->buildLimitClause($conn_r);
|
|
|
|
|
|
|
|
$data = queryfx_all(
|
|
|
|
$conn_r,
|
|
|
|
'SELECT * FROM %T client %Q %Q',
|
|
|
|
$table->getTableName(),
|
|
|
|
$where_clause,
|
|
|
|
$limit_clause);
|
|
|
|
|
|
|
|
return $table->loadAllFromArray($data);
|
|
|
|
}
|
|
|
|
|
|
|
|
private function buildWhereClause($conn_r) {
|
|
|
|
$where = array();
|
|
|
|
|
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() {
|
|
|
|
return 'PhabricatorApplicationOAuthServer';
|
|
|
|
}
|
|
|
|
|
2012-04-05 02:51:16 +02:00
|
|
|
}
|