1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 00:42:41 +01:00

Update Search for handleRequest

Summary: Ref T8628. Updates Search.

Test Plan: Did various searches, saved new queries, reordered, ran new queries.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T8628

Differential Revision: https://secure.phabricator.com/D14268
This commit is contained in:
Chad Little 2015-10-20 09:02:55 -07:00
parent 22b9b76079
commit 09ab82faef
5 changed files with 30 additions and 60 deletions

View file

@ -5,19 +5,12 @@ final class PhabricatorSearchController
const SCOPE_CURRENT_APPLICATION = 'application';
private $queryKey;
public function shouldAllowPublic() {
return true;
}
public function willProcessRequest(array $data) {
$this->queryKey = idx($data, 'queryKey');
}
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
public function handleRequest(AphrontRequest $request) {
$viewer = $this->getViewer();
if ($request->getStr('jump') != 'no') {
$pref_jump = PhabricatorUserPreferences::PREFERENCE_SEARCHBAR_JUMP;
@ -97,7 +90,7 @@ final class PhabricatorSearchController
}
$controller = id(new PhabricatorApplicationSearchController())
->setQueryKey($this->queryKey)
->setQueryKey($request->getURIData('queryKey'))
->setSearchEngine($engine)
->setNavigation($this->buildSideNavView());
@ -105,7 +98,7 @@ final class PhabricatorSearchController
}
public function buildSideNavView($for_app = false) {
$viewer = $this->getRequest()->getUser();
$viewer = $this->getViewer();
$nav = new AphrontSideNavFilterView();
$nav->setBaseURI(new PhutilURI($this->getApplicationURI()));

View file

@ -3,33 +3,24 @@
final class PhabricatorSearchDeleteController
extends PhabricatorSearchBaseController {
private $queryKey;
private $engineClass;
public function willProcessRequest(array $data) {
$this->queryKey = idx($data, 'queryKey');
$this->engineClass = idx($data, 'engine');
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$key = $this->queryKey;
public function handleRequest(AphrontRequest $request) {
$viewer = $this->getViewer();
$key = $request->getURIData('queryKey');
$engine_class = $request->getURIData('engine');
$base_class = 'PhabricatorApplicationSearchEngine';
if (!is_subclass_of($this->engineClass, $base_class)) {
if (!is_subclass_of($engine_class, $base_class)) {
return new Aphront400Response();
}
$engine = newv($this->engineClass, array());
$engine->setViewer($user);
$engine = newv($engine_class, array());
$engine->setViewer($viewer);
$named_query = id(new PhabricatorNamedQueryQuery())
->setViewer($user)
->withEngineClassNames(array($this->engineClass))
->setViewer($viewer)
->withEngineClassNames(array($engine_class))
->withQueryKeys(array($key))
->withUserPHIDs(array($user->getPHID()))
->withUserPHIDs(array($viewer->getPHID()))
->executeOne();
if (!$named_query && $engine->isBuiltinQuery($key)) {
@ -84,7 +75,7 @@ final class PhabricatorSearchDeleteController
}
$dialog = id(new AphrontDialogView())
->setUser($user)
->setUser($viewer)
->setTitle($title)
->appendChild($desc)
->addCancelButton($return_uri)

View file

@ -3,38 +3,31 @@
final class PhabricatorSearchEditController
extends PhabricatorSearchBaseController {
private $queryKey;
public function willProcessRequest(array $data) {
$this->queryKey = idx($data, 'queryKey');
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
public function handleRequest(AphrontRequest $request) {
$viewer = $this->getViewer();
$saved_query = id(new PhabricatorSavedQueryQuery())
->setViewer($user)
->withQueryKeys(array($this->queryKey))
->setViewer($viewer)
->withQueryKeys(array($request->getURIData('queryKey')))
->executeOne();
if (!$saved_query) {
return new Aphront404Response();
}
$engine = $saved_query->newEngine()->setViewer($user);
$engine = $saved_query->newEngine()->setViewer($viewer);
$complete_uri = $engine->getQueryManagementURI();
$cancel_uri = $complete_uri;
$named_query = id(new PhabricatorNamedQueryQuery())
->setViewer($user)
->setViewer($viewer)
->withQueryKeys(array($saved_query->getQueryKey()))
->withUserPHIDs(array($user->getPHID()))
->withUserPHIDs(array($viewer->getPHID()))
->executeOne();
if (!$named_query) {
$named_query = id(new PhabricatorNamedQuery())
->setUserPHID($user->getPHID())
->setUserPHID($viewer->getPHID())
->setQueryKey($saved_query->getQueryKey())
->setEngineClassName($saved_query->getEngineClassName());
@ -64,7 +57,7 @@ final class PhabricatorSearchEditController
}
$form = id(new AphrontFormView())
->setUser($user);
->setUser($viewer);
$form->appendChild(
id(new AphrontFormTextControl())

View file

@ -9,7 +9,6 @@ final class PhabricatorSearchHovercardController
public function handleRequest(AphrontRequest $request) {
$viewer = $this->getViewer();
$phids = $request->getArr('phids');
$handles = id(new PhabricatorHandleQuery())

View file

@ -3,25 +3,19 @@
final class PhabricatorSearchOrderController
extends PhabricatorSearchBaseController {
private $engineClass;
public function willProcessRequest(array $data) {
$this->engineClass = idx($data, 'engine');
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
public function handleRequest(AphrontRequest $request) {
$viewer = $this->getViewer();
$engine_class = $request->getURIData('engine');
$request->validateCSRF();
$base_class = 'PhabricatorApplicationSearchEngine';
if (!is_subclass_of($this->engineClass, $base_class)) {
if (!is_subclass_of($engine_class, $base_class)) {
return new Aphront400Response();
}
$engine = newv($this->engineClass, array());
$engine->setViewer($user);
$engine = newv($engine_class, array());
$engine->setViewer($viewer);
$queries = $engine->loadAllNamedQueries();
$queries = mpull($queries, null, 'getQueryKey');