Page MenuHomePhabricator

D13384.id32404.diff
No OneTemporary

D13384.id32404.diff

diff --git a/src/applications/passphrase/query/PassphraseCredentialQuery.php b/src/applications/passphrase/query/PassphraseCredentialQuery.php
--- a/src/applications/passphrase/query/PassphraseCredentialQuery.php
+++ b/src/applications/passphrase/query/PassphraseCredentialQuery.php
@@ -53,19 +53,12 @@
return $this;
}
+ public function newResultObject() {
+ return new PassphraseCredential();
+ }
+
protected function loadPage() {
- $table = new PassphraseCredential();
- $conn_r = $table->establishConnection('r');
-
- $rows = queryfx_all(
- $conn_r,
- 'SELECT * FROM %T %Q %Q %Q',
- $table->getTableName(),
- $this->buildWhereClause($conn_r),
- $this->buildOrderClause($conn_r),
- $this->buildLimitClause($conn_r));
-
- return $table->loadAllFromArray($rows);
+ return $this->loadStandardPage($this->newResultObject());
}
protected function willFilterPage(array $page) {
@@ -99,61 +92,59 @@
return $page;
}
- protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
- $where = array();
-
- $where[] = $this->buildPagingClause($conn_r);
+ protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
+ $where = parent::buildWhereClauseParts($conn);
- if ($this->ids) {
+ if ($this->ids !== null) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'id IN (%Ld)',
$this->ids);
}
- if ($this->phids) {
+ if ($this->phids !== null) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'phid IN (%Ls)',
$this->phids);
}
- if ($this->credentialTypes) {
+ if ($this->credentialTypes !== null) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'credentialType in (%Ls)',
$this->credentialTypes);
}
- if ($this->providesTypes) {
+ if ($this->providesTypes !== null) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'providesType IN (%Ls)',
$this->providesTypes);
}
if ($this->isDestroyed !== null) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'isDestroyed = %d',
(int)$this->isDestroyed);
}
if ($this->allowConduit !== null) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'allowConduit = %d',
(int)$this->allowConduit);
}
if (strlen($this->nameContains)) {
$where[] = qsprintf(
- $conn_r,
- 'name LIKE %~',
- $this->nameContains);
+ $conn,
+ 'LOWER(name) LIKE %~',
+ phutil_utf8_strtolower($this->nameContains));
}
- return $this->formatWhereClause($where);
+ return $where;
}
public function getQueryApplicationClass() {
diff --git a/src/applications/passphrase/query/PassphraseCredentialSearchEngine.php b/src/applications/passphrase/query/PassphraseCredentialSearchEngine.php
--- a/src/applications/passphrase/query/PassphraseCredentialSearchEngine.php
+++ b/src/applications/passphrase/query/PassphraseCredentialSearchEngine.php
@@ -11,58 +11,39 @@
return 'PhabricatorPassphraseApplication';
}
- public function buildSavedQueryFromRequest(AphrontRequest $request) {
- $saved = new PhabricatorSavedQuery();
-
- $saved->setParameter(
- 'isDestroyed',
- $this->readBoolFromRequest($request, 'isDestroyed'));
- $saved->setParameter('name', $request->getStr('name'));
+ public function newQuery() {
+ return new PassphraseCredentialQuery();
+ }
- return $saved;
+ protected function buildCustomSearchFields() {
+ return array(
+ id(new PhabricatorSearchThreeStateField())
+ ->setLabel(pht('Status'))
+ ->setKey('isDestroyed')
+ ->setOptions(
+ pht('Show All'),
+ pht('Show Only Destroyed Credentials'),
+ pht('Show Only Active Credentials')),
+ id(new PhabricatorSearchTextField())
+ ->setLabel(pht('Name Contains'))
+ ->setKey('name'),
+ );
}
- public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
- $query = id(new PassphraseCredentialQuery());
+ protected function buildQueryFromParameters(array $map) {
+ $query = $this->newQuery();
- $destroyed = $saved->getParameter('isDestroyed');
- if ($destroyed !== null) {
- $query->withIsDestroyed($destroyed);
+ if ($map['isDestroyed'] !== null) {
+ $query->withIsDestroyed($map['isDestroyed']);
}
- $name = $saved->getParameter('name');
- if (strlen($name)) {
- $query->withNameContains($name);
+ if (strlen($map['name'])) {
+ $query->withNameContains($map['name']);
}
return $query;
}
- public function buildSearchForm(
- AphrontFormView $form,
- PhabricatorSavedQuery $saved_query) {
-
- $name = $saved_query->getParameter('name');
-
- $form
- ->appendChild(
- id(new AphrontFormSelectControl())
- ->setName('isDestroyed')
- ->setLabel(pht('Status'))
- ->setValue($this->getBoolFromQuery($saved_query, 'isDestroyed'))
- ->setOptions(
- array(
- '' => pht('Show All Credentials'),
- 'false' => pht('Show Only Active Credentials'),
- 'true' => pht('Show Only Destroyed Credentials'),
- )))
- ->appendChild(
- id(new AphrontFormTextControl())
- ->setName('name')
- ->setLabel(pht('Name Contains'))
- ->setValue($name));
- }
-
protected function getURI($path) {
return '/passphrase/'.$path;
}

File Metadata

Mime Type
text/plain
Expires
Sat, May 18, 12:44 AM (4 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6285574
Default Alt Text
D13384.id32404.diff (5 KB)

Event Timeline