Use a policy-aware query for Project typeahead

Summary: Fixes T2677. Currently, you can typeahead projects you can't see.

Test Plan: Typeahead'ed projects. Verified active projects appeared; archived did not.

Reviewers: chad

Reviewed By: chad

CC: aran

Maniphest Tasks: T2677

Differential Revision: https://secure.phabricator.com/D5242
This commit is contained in:
epriestley
2013-03-05 14:12:11 -08:00
parent aab0fb0e74
commit c23a9c9fde

View File

@@ -12,6 +12,7 @@ final class PhabricatorTypeaheadCommonDatasourceController
public function processRequest() { public function processRequest() {
$request = $this->getRequest(); $request = $this->getRequest();
$viewer = $request->getUser();
$query = $request->getStr('q'); $query = $request->getStr('q');
$need_rich_data = false; $need_rich_data = false;
@@ -199,9 +200,10 @@ final class PhabricatorTypeaheadCommonDatasourceController
} }
if ($need_projs) { if ($need_projs) {
$projs = id(new PhabricatorProject())->loadAllWhere( $projs = id(new PhabricatorProjectQuery())
'status != %d', ->setViewer($viewer)
PhabricatorProjectStatus::STATUS_ARCHIVED); ->withStatus(PhabricatorProjectQuery::STATUS_OPEN)
->execute();
foreach ($projs as $proj) { foreach ($projs as $proj) {
$results[] = id(new PhabricatorTypeaheadResult()) $results[] = id(new PhabricatorTypeaheadResult())
->setName($proj->getName()) ->setName($proj->getName())