Differential D8904 Diff 21133 src/applications/search/query/PhabricatorSearchApplicationSearchEngine.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/search/query/PhabricatorSearchApplicationSearchEngine.php
Show First 20 Lines • Show All 90 Lines • ▼ Show 20 Lines | foreach ($statuses as $status => $name) { | ||||
$status, | $status, | ||||
$name, | $name, | ||||
isset($status_values[$status])); | isset($status_values[$status])); | ||||
} | } | ||||
$type_values = $saved->getParameter('types', array()); | $type_values = $saved->getParameter('types', array()); | ||||
$type_values = array_fuse($type_values); | $type_values = array_fuse($type_values); | ||||
$types = self::getIndexableDocumentTypes(); | $types = self::getIndexableDocumentTypes($this->requireViewer()); | ||||
$types_control = id(new AphrontFormCheckboxControl()) | $types_control = id(new AphrontFormCheckboxControl()) | ||||
->setLabel(pht('Document Types')); | ->setLabel(pht('Document Types')); | ||||
foreach ($types as $type => $name) { | foreach ($types as $type => $name) { | ||||
$types_control->addCheckbox( | $types_control->addCheckbox( | ||||
'types[]', | 'types[]', | ||||
$type, | $type, | ||||
$name, | $name, | ||||
▲ Show 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | switch ($query_key) { | ||||
return $query | return $query | ||||
->setParameter('statuses', array('open')) | ->setParameter('statuses', array('open')) | ||||
->setParameter('types', array(ManiphestPHIDTypeTask::TYPECONST)); | ->setParameter('types', array(ManiphestPHIDTypeTask::TYPECONST)); | ||||
} | } | ||||
return parent::buildSavedQueryFromBuiltin($query_key); | return parent::buildSavedQueryFromBuiltin($query_key); | ||||
} | } | ||||
public static function getIndexableDocumentTypes() { | public static function getIndexableDocumentTypes( | ||||
PhabricatorUser $viewer = null) { | |||||
// TODO: This is inelegant and not very efficient, but gets us reasonable | // TODO: This is inelegant and not very efficient, but gets us reasonable | ||||
// results. It would be nice to do this more elegantly. | // results. It would be nice to do this more elegantly. | ||||
// TODO: We should hide types associated with applications the user can | |||||
// not access. There's no reasonable way to do this right now. | |||||
$indexers = id(new PhutilSymbolLoader()) | $indexers = id(new PhutilSymbolLoader()) | ||||
->setAncestorClass('PhabricatorSearchDocumentIndexer') | ->setAncestorClass('PhabricatorSearchDocumentIndexer') | ||||
->loadObjects(); | ->loadObjects(); | ||||
if ($viewer) { | |||||
$types = PhabricatorPHIDType::getAllInstalledTypes($viewer); | |||||
} else { | |||||
$types = PhabricatorPHIDType::getAllTypes(); | $types = PhabricatorPHIDType::getAllTypes(); | ||||
} | |||||
$results = array(); | $results = array(); | ||||
foreach ($types as $type) { | foreach ($types as $type) { | ||||
$typeconst = $type->getTypeConstant(); | $typeconst = $type->getTypeConstant(); | ||||
foreach ($indexers as $indexer) { | foreach ($indexers as $indexer) { | ||||
$fake_phid = 'PHID-'.$typeconst.'-fake'; | $fake_phid = 'PHID-'.$typeconst.'-fake'; | ||||
if ($indexer->shouldIndexDocumentByPHID($fake_phid)) { | if ($indexer->shouldIndexDocumentByPHID($fake_phid)) { | ||||
$results[$typeconst] = $type->getTypeName(); | $results[$typeconst] = $type->getTypeName(); | ||||
Show All 18 Lines |