@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Move Passphrase to SearchField

Summary: Prepares for bringing spaces and a new object policy here.

Test Plan: Used all search controls dozens of times.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Differential Revision: https://secure.phabricator.com/D13384

+43 -71
+21 -30
src/applications/passphrase/query/PassphraseCredentialQuery.php
··· 53 53 return $this; 54 54 } 55 55 56 + public function newResultObject() { 57 + return new PassphraseCredential(); 58 + } 59 + 56 60 protected function loadPage() { 57 - $table = new PassphraseCredential(); 58 - $conn_r = $table->establishConnection('r'); 59 - 60 - $rows = queryfx_all( 61 - $conn_r, 62 - 'SELECT * FROM %T %Q %Q %Q', 63 - $table->getTableName(), 64 - $this->buildWhereClause($conn_r), 65 - $this->buildOrderClause($conn_r), 66 - $this->buildLimitClause($conn_r)); 67 - 68 - return $table->loadAllFromArray($rows); 61 + return $this->loadStandardPage($this->newResultObject()); 69 62 } 70 63 71 64 protected function willFilterPage(array $page) { ··· 99 92 return $page; 100 93 } 101 94 102 - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { 103 - $where = array(); 95 + protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { 96 + $where = parent::buildWhereClauseParts($conn); 104 97 105 - $where[] = $this->buildPagingClause($conn_r); 106 - 107 - if ($this->ids) { 98 + if ($this->ids !== null) { 108 99 $where[] = qsprintf( 109 - $conn_r, 100 + $conn, 110 101 'id IN (%Ld)', 111 102 $this->ids); 112 103 } 113 104 114 - if ($this->phids) { 105 + if ($this->phids !== null) { 115 106 $where[] = qsprintf( 116 - $conn_r, 107 + $conn, 117 108 'phid IN (%Ls)', 118 109 $this->phids); 119 110 } 120 111 121 - if ($this->credentialTypes) { 112 + if ($this->credentialTypes !== null) { 122 113 $where[] = qsprintf( 123 - $conn_r, 114 + $conn, 124 115 'credentialType in (%Ls)', 125 116 $this->credentialTypes); 126 117 } 127 118 128 - if ($this->providesTypes) { 119 + if ($this->providesTypes !== null) { 129 120 $where[] = qsprintf( 130 - $conn_r, 121 + $conn, 131 122 'providesType IN (%Ls)', 132 123 $this->providesTypes); 133 124 } 134 125 135 126 if ($this->isDestroyed !== null) { 136 127 $where[] = qsprintf( 137 - $conn_r, 128 + $conn, 138 129 'isDestroyed = %d', 139 130 (int)$this->isDestroyed); 140 131 } 141 132 142 133 if ($this->allowConduit !== null) { 143 134 $where[] = qsprintf( 144 - $conn_r, 135 + $conn, 145 136 'allowConduit = %d', 146 137 (int)$this->allowConduit); 147 138 } 148 139 149 140 if (strlen($this->nameContains)) { 150 141 $where[] = qsprintf( 151 - $conn_r, 152 - 'name LIKE %~', 153 - $this->nameContains); 142 + $conn, 143 + 'LOWER(name) LIKE %~', 144 + phutil_utf8_strtolower($this->nameContains)); 154 145 } 155 146 156 - return $this->formatWhereClause($where); 147 + return $where; 157 148 } 158 149 159 150 public function getQueryApplicationClass() {
+22 -41
src/applications/passphrase/query/PassphraseCredentialSearchEngine.php
··· 11 11 return 'PhabricatorPassphraseApplication'; 12 12 } 13 13 14 - public function buildSavedQueryFromRequest(AphrontRequest $request) { 15 - $saved = new PhabricatorSavedQuery(); 16 - 17 - $saved->setParameter( 18 - 'isDestroyed', 19 - $this->readBoolFromRequest($request, 'isDestroyed')); 20 - $saved->setParameter('name', $request->getStr('name')); 14 + public function newQuery() { 15 + return new PassphraseCredentialQuery(); 16 + } 21 17 22 - return $saved; 18 + protected function buildCustomSearchFields() { 19 + return array( 20 + id(new PhabricatorSearchThreeStateField()) 21 + ->setLabel(pht('Status')) 22 + ->setKey('isDestroyed') 23 + ->setOptions( 24 + pht('Show All'), 25 + pht('Show Only Destroyed Credentials'), 26 + pht('Show Only Active Credentials')), 27 + id(new PhabricatorSearchTextField()) 28 + ->setLabel(pht('Name Contains')) 29 + ->setKey('name'), 30 + ); 23 31 } 24 32 25 - public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) { 26 - $query = id(new PassphraseCredentialQuery()); 33 + protected function buildQueryFromParameters(array $map) { 34 + $query = $this->newQuery(); 27 35 28 - $destroyed = $saved->getParameter('isDestroyed'); 29 - if ($destroyed !== null) { 30 - $query->withIsDestroyed($destroyed); 36 + if ($map['isDestroyed'] !== null) { 37 + $query->withIsDestroyed($map['isDestroyed']); 31 38 } 32 39 33 - $name = $saved->getParameter('name'); 34 - if (strlen($name)) { 35 - $query->withNameContains($name); 40 + if (strlen($map['name'])) { 41 + $query->withNameContains($map['name']); 36 42 } 37 43 38 44 return $query; 39 - } 40 - 41 - public function buildSearchForm( 42 - AphrontFormView $form, 43 - PhabricatorSavedQuery $saved_query) { 44 - 45 - $name = $saved_query->getParameter('name'); 46 - 47 - $form 48 - ->appendChild( 49 - id(new AphrontFormSelectControl()) 50 - ->setName('isDestroyed') 51 - ->setLabel(pht('Status')) 52 - ->setValue($this->getBoolFromQuery($saved_query, 'isDestroyed')) 53 - ->setOptions( 54 - array( 55 - '' => pht('Show All Credentials'), 56 - 'false' => pht('Show Only Active Credentials'), 57 - 'true' => pht('Show Only Destroyed Credentials'), 58 - ))) 59 - ->appendChild( 60 - id(new AphrontFormTextControl()) 61 - ->setName('name') 62 - ->setLabel(pht('Name Contains')) 63 - ->setValue($name)); 64 45 } 65 46 66 47 protected function getURI($path) {