From 21650c47b6191052630fe20077d4fa19cc737fb1 Mon Sep 17 00:00:00 2001 From: epriestley Date: Fri, 18 Feb 2011 17:36:25 -0800 Subject: [PATCH] Make owner search queries work. Summary: Test Plan: Reviewers: CC: --- .../search/PhabricatorSearchController.php | 28 +++++++++++++++---- .../mysql/PhabricatorSearchMySQLExecutor.php | 6 ++++ 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/applications/search/controller/search/PhabricatorSearchController.php b/src/applications/search/controller/search/PhabricatorSearchController.php index 738420cdde..08ad26ff8a 100644 --- a/src/applications/search/controller/search/PhabricatorSearchController.php +++ b/src/applications/search/controller/search/PhabricatorSearchController.php @@ -47,6 +47,10 @@ class PhabricatorSearchController extends PhabricatorSearchBaseController { $query->setParameter('author', $request->getArr('author')); } + if ($request->getArr('owner')) { + $query->setParameter('owner', $request->getArr('owner')); + } + if ($request->getInt('open')) { $query->setParameter('open', $request->getInt('open')); } @@ -69,7 +73,8 @@ class PhabricatorSearchController extends PhabricatorSearchBaseController { ); $phids = array_merge( - $query->getParameter('author', array()) + $query->getParameter('author', array()), + $query->getParameter('owner', array()) ); $handles = id(new PhabricatorObjectHandleData($phids)) @@ -79,6 +84,11 @@ class PhabricatorSearchController extends PhabricatorSearchBaseController { $handles, $query->getParameter('author', array())); $author_value = mpull($author_value, 'getFullName', 'getPHID'); + + $owner_value = array_select_keys( + $handles, + $query->getParameter('owner', array())); + $owner_value = mpull($owner_value, 'getFullName', 'getPHID'); $search_form = new AphrontFormView(); $search_form @@ -95,6 +105,12 @@ class PhabricatorSearchController extends PhabricatorSearchBaseController { ->setName('type') ->setOptions($options) ->setValue($query->getParameter('type'))) + ->appendChild( + id(new AphrontFormSelectControl()) + ->setLabel('Document Status') + ->setName('open') + ->setOptions($status_options) + ->setValue($query->getParameter('open'))) ->appendChild( id(new AphrontFormTokenizerControl()) ->setName('author') @@ -102,11 +118,11 @@ class PhabricatorSearchController extends PhabricatorSearchBaseController { ->setDatasource('/typeahead/common/users/') ->setValue($author_value)) ->appendChild( - id(new AphrontFormSelectControl()) - ->setLabel('Document Status') - ->setName('open') - ->setOptions($status_options) - ->setValue($query->getParameter('open'))) + id(new AphrontFormTokenizerControl()) + ->setName('owner') + ->setLabel('Owner') + ->setDatasource('/typeahead/common/users/') + ->setValue($owner_value)) ->appendChild( id(new AphrontFormSubmitControl()) ->setValue('Search')); diff --git a/src/applications/search/execute/mysql/PhabricatorSearchMySQLExecutor.php b/src/applications/search/execute/mysql/PhabricatorSearchMySQLExecutor.php index d967c35b1f..673a518d52 100644 --- a/src/applications/search/execute/mysql/PhabricatorSearchMySQLExecutor.php +++ b/src/applications/search/execute/mysql/PhabricatorSearchMySQLExecutor.php @@ -86,6 +86,12 @@ class PhabricatorSearchMySQLExecutor extends PhabricatorSearchExecutor { 'open', PhabricatorSearchRelationship::RELATIONSHIP_OPEN); + $join[] = $this->joinRelationship( + $conn_r, + $query, + 'owner', + PhabricatorSearchRelationship::RELATIONSHIP_OWNER); + /* $join[] = $this->joinRelationship( $conn_r,