Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14017036
D13203.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
14 KB
Referenced Files
None
Subscribers
None
D13203.diff
View Options
Index: src/applications/maniphest/query/ManiphestTaskSearchEngine.php
===================================================================
--- src/applications/maniphest/query/ManiphestTaskSearchEngine.php
+++ src/applications/maniphest/query/ManiphestTaskSearchEngine.php
@@ -43,28 +43,89 @@
->needProjectPHIDs(true);
}
- public function buildSavedQueryFromRequest(AphrontRequest $request) {
- $saved = new PhabricatorSavedQuery();
+ public function buildCustomSearchFields() {
+ return array(
+ id(new PhabricatorSearchOwnersField())
+ ->setLabel(pht('Assigned To'))
+ ->setKey('assignedPHIDs')
+ ->setAliases(array('assigned')),
+ id(new PhabricatorSearchUsersField())
+ ->setLabel(pht('Authors'))
+ ->setKey('authorPHIDs')
+ ->setAliases(array('author', 'authors')),
+ id(new PhabricatorSearchDatasourceField())
+ ->setLabel(pht('Statuses'))
+ ->setKey('statuses')
+ ->setAliases(array('status'))
+ ->setDatasource(new ManiphestTaskStatusFunctionDatasource()),
+ id(new PhabricatorSearchDatasourceField())
+ ->setLabel(pht('Priorities'))
+ ->setKey('priorities')
+ ->setAliases(array('priority'))
+ ->setDatasource(new ManiphestTaskPriorityDatasource()),
+ id(new PhabricatorSearchDateField())
+ ->setLabel(pht('Created After'))
+ ->setKey('createdStart'),
+ id(new PhabricatorSearchDateField())
+ ->setLabel(pht('Created Before'))
+ ->setKey('createdEnd'),
+ id(new PhabricatorSearchDateField())
+ ->setLabel(pht('Updated After'))
+ ->setKey('modifiedStart'),
+ id(new PhabricatorSearchDateField())
+ ->setLabel(pht('Updated Before'))
+ ->setKey('modifiedEnd'),
+ );
+ }
- $saved->setParameter(
- 'assignedPHIDs',
- $this->readUsersFromRequest($request, 'assigned'));
+ public function buildQueryFromParameters(array $map) {
+ $query = id(new ManiphestTaskQuery())
+ ->needProjectPHIDs(true);
- $saved->setParameter(
- 'authorPHIDs',
- $this->readUsersFromRequest($request, 'authors'));
+ if ($map['assignedPHIDs']) {
+ $query->withOwners($map['assignedPHIDs']);
+ }
- $saved->setParameter(
- 'subscriberPHIDs',
- $this->readSubscribersFromRequest($request, 'subscribers'));
+ if ($map['authorPHIDs']) {
+ $query->withAuthors($map['authorPHIDs']);
+ }
- $saved->setParameter(
- 'statuses',
- $this->readListFromRequest($request, 'statuses'));
+ if ($map['statuses']) {
+ $query->withStatuses($map['statuses']);
+ }
+
+ if ($map['priorities']) {
+ $query->withPriorities($map['priorities']);
+ }
+
+ if ($map['createdStart']) {
+ $query->withDateCreatedAfter($map['createdStart']);
+ }
+
+ if ($map['createdEnd']) {
+ $query->withDateCreatedBefore($map['createdEnd']);
+ }
+
+ if ($map['modifiedStart']) {
+ $query->withDateModifiedAfter($map['modifiedStart']);
+ }
+
+ if ($map['modifiedEnd']) {
+ $query->withDateModifiedBefore($map['modifiedEnd']);
+ }
+
+ return $query;
+ }
+
+/*
+
+/*
+ public function buildSavedQueryFromRequest(AphrontRequest $request) {
+ $saved = new PhabricatorSavedQuery();
$saved->setParameter(
- 'priorities',
- $this->readListFromRequest($request, 'priorities'));
+ 'subscriberPHIDs',
+ $this->readSubscribersFromRequest($request, 'subscribers'));
$saved->setParameter(
'blocking',
@@ -89,14 +150,6 @@
$saved->setParameter('fulltext', $request->getStr('fulltext'));
- $saved->setParameter(
- 'projects',
- $this->readProjectsFromRequest($request, 'projects'));
-
- $saved->setParameter('createdStart', $request->getStr('createdStart'));
- $saved->setParameter('createdEnd', $request->getStr('createdEnd'));
- $saved->setParameter('modifiedStart', $request->getStr('modifiedStart'));
- $saved->setParameter('modifiedEnd', $request->getStr('modifiedEnd'));
$limit = $request->getInt('limit');
if ($limit > 0) {
@@ -116,12 +169,6 @@
$datasource = id(new PhabricatorPeopleUserFunctionDatasource())
->setViewer($viewer);
- $author_phids = $saved->getParameter('authorPHIDs', array());
- $author_phids = $datasource->evaluateTokens($author_phids);
- if ($author_phids) {
- $query->withAuthors($author_phids);
- }
-
$datasource = id(new PhabricatorMetaMTAMailableFunctionDatasource())
->setViewer($viewer);
$subscriber_phids = $saved->getParameter('subscriberPHIDs', array());
@@ -130,29 +177,6 @@
$query->withSubscribers($subscriber_phids);
}
- $datasource = id(new PhabricatorPeopleOwnerDatasource())
- ->setViewer($this->requireViewer());
-
- $assigned_phids = $this->readAssignedPHIDs($saved);
- $assigned_phids = $datasource->evaluateTokens($assigned_phids);
- if ($assigned_phids) {
- $query->withOwners($assigned_phids);
- }
-
- $datasource = id(new ManiphestTaskStatusFunctionDatasource())
- ->setViewer($this->requireViewer());
- $statuses = $saved->getParameter('statuses', array());
- $statuses = $datasource->evaluateTokens($statuses);
- if ($statuses) {
- $query->withStatuses($statuses);
- }
-
- $priorities = $saved->getParameter('priorities', array());
- if ($priorities) {
- $query->withPriorities($priorities);
- }
-
-
$query->withBlockingTasks($saved->getParameter('blocking'));
$query->withBlockedTasks($saved->getParameter('blocked'));
@@ -183,51 +207,23 @@
$query->withFullTextSearch($fulltext);
}
- $projects = $this->readProjectTokens($saved);
- $adjusted = id(clone $saved)->setParameter('projects', $projects);
- $this->setQueryProjects($query, $adjusted);
-
- $start = $this->parseDateTime($saved->getParameter('createdStart'));
- $end = $this->parseDateTime($saved->getParameter('createdEnd'));
-
- if ($start) {
- $query->withDateCreatedAfter($start);
- }
-
- if ($end) {
- $query->withDateCreatedBefore($end);
- }
-
- $mod_start = $this->parseDateTime($saved->getParameter('modifiedStart'));
- $mod_end = $this->parseDateTime($saved->getParameter('modifiedEnd'));
-
- if ($mod_start) {
- $query->withDateModifiedAfter($mod_start);
- }
-
- if ($mod_end) {
- $query->withDateModifiedBefore($mod_end);
- }
-
$this->applyCustomFieldsToQuery($query, $saved);
return $query;
}
+*/
+
+
+/*
public function buildSearchForm(
AphrontFormView $form,
PhabricatorSavedQuery $saved) {
- $assigned_phids = $this->readAssignedPHIDs($saved);
-
- $author_phids = $saved->getParameter('authorPHIDs', array());
$projects = $this->readProjectTokens($saved);
$subscriber_phids = $saved->getParameter('subscriberPHIDs', array());
- $statuses = $saved->getParameter('statuses', array());
- $priorities = $saved->getParameter('priorities', array());
-
$blocking_control = id(new AphrontFormSelectControl())
->setLabel(pht('Blocking'))
->setName('blocking')
@@ -255,40 +251,10 @@
$form
->appendControl(
id(new AphrontFormTokenizerControl())
- ->setDatasource(new PhabricatorPeopleOwnerDatasource())
- ->setName('assigned')
- ->setLabel(pht('Assigned To'))
- ->setValue($assigned_phids))
- ->appendControl(
- id(new AphrontFormTokenizerControl())
- ->setDatasource(new PhabricatorProjectLogicalDatasource())
- ->setName('projects')
- ->setLabel(pht('Projects'))
- ->setValue($projects))
- ->appendControl(
- id(new AphrontFormTokenizerControl())
- ->setDatasource(new PhabricatorPeopleUserFunctionDatasource())
- ->setName('authors')
- ->setLabel(pht('Authors'))
- ->setValue($author_phids))
- ->appendControl(
- id(new AphrontFormTokenizerControl())
->setDatasource(new PhabricatorMetaMTAMailableFunctionDatasource())
->setName('subscribers')
->setLabel(pht('Subscribers'))
->setValue($subscriber_phids))
- ->appendControl(
- id(new AphrontFormTokenizerControl())
- ->setDatasource(new ManiphestTaskStatusFunctionDatasource())
- ->setLabel(pht('Statuses'))
- ->setName('statuses')
- ->setValue($statuses))
- ->appendControl(
- id(new AphrontFormTokenizerControl())
- ->setDatasource(new ManiphestTaskPriorityDatasource())
- ->setLabel(pht('Priorities'))
- ->setName('priorities')
- ->setValue($priorities))
->appendChild(
id(new AphrontFormTextControl())
->setName('fulltext')
@@ -322,21 +288,6 @@
$this->appendCustomFieldsToForm($form, $saved);
- $this->buildDateRange(
- $form,
- $saved,
- 'createdStart',
- pht('Created After'),
- 'createdEnd',
- pht('Created Before'));
-
- $this->buildDateRange(
- $form,
- $saved,
- 'modifiedStart',
- pht('Updated After'),
- 'modifiedEnd',
- pht('Updated Before'));
if (!$this->getIsBoardView()) {
$form
@@ -348,6 +299,8 @@
}
}
+*/
+
protected function getURI($path) {
if ($this->baseURI) {
return $this->baseURI.$path;
@@ -458,48 +411,52 @@
->setShowBatchControls($this->showBatchControls);
}
- private function readAssignedPHIDs(PhabricatorSavedQuery $saved) {
- $assigned_phids = $saved->getParameter('assignedPHIDs', array());
+ protected function willUseSavedQuery(PhabricatorSavedQuery $saved) {
- // This may be present in old saved queries from before parameterized
- // typeaheads, and is retained for compatibility. We could remove it by
- // migrating old saved queries.
+ // The 'withUnassigned' parameter may be present in old saved queries from
+ // before parameterized typeaheads, and is retained for compatibility. We
+ // could remove it by migrating old saved queries.
+ $assigned_phids = $saved->getParameter('assignedPHIDs', array());
if ($saved->getParameter('withUnassigned')) {
$assigned_phids[] = PhabricatorPeopleNoOwnerDatasource::FUNCTION_TOKEN;
}
+ $saved->setParameter('assignedPHIDs', array());
- return $assigned_phids;
- }
+ // The 'projects' and other parameters may be present in old saved queries
+ // from before parameterized typeaheads.
+ $project_phids = $saved->getParameter('projectPHIDs', array());
- private function readProjectTokens(PhabricatorSavedQuery $saved) {
- $projects = $saved->getParameter('projects', array());
+ $old = $saved->getParameter('projects', array());
+ foreach ($old as $phid) {
+ $project_phids[] = $phid;
+ }
$all = $saved->getParameter('allProjectPHIDs', array());
foreach ($all as $phid) {
- $projects[] = $phid;
+ $project_phids[] = $phid;
}
$any = $saved->getParameter('anyProjectPHIDs', array());
foreach ($any as $phid) {
- $projects[] = 'any('.$phid.')';
+ $project_phids[] = 'any('.$phid.')';
}
$not = $saved->getParameter('excludeProjectPHIDs', array());
foreach ($not as $phid) {
- $projects[] = 'not('.$phid.')';
+ $project_phids[] = 'not('.$phid.')';
}
$users = $saved->getParameter('userProjectPHIDs', array());
foreach ($users as $phid) {
- $projects[] = 'projects('.$phid.')';
+ $project_phids[] = 'projects('.$phid.')';
}
$no = $saved->getParameter('withNoProject');
if ($no) {
- $projects[] = 'null()';
+ $project_phids[] = 'null()';
}
- return $projects;
+ $saved->setParameter('projectPHIDs', $project_phids);
}
}
Index: src/applications/search/engine/PhabricatorApplicationSearchEngine.php
===================================================================
--- src/applications/search/engine/PhabricatorApplicationSearchEngine.php
+++ src/applications/search/engine/PhabricatorApplicationSearchEngine.php
@@ -1061,68 +1061,6 @@
}
- /**
- * Moves data from the request into a saved query.
- *
- * @param AphrontRequest Request to read.
- * @param PhabricatorSavedQuery Query to write to.
- * @return void
- * @task appsearch
- */
- protected function readCustomFieldsFromRequest(
- AphrontRequest $request,
- PhabricatorSavedQuery $saved) {
-
- $list = $this->getCustomFieldList();
- if (!$list) {
- return;
- }
-
- foreach ($list->getFields() as $field) {
- $key = $this->getKeyForCustomField($field);
- $value = $field->readApplicationSearchValueFromRequest(
- $this,
- $request);
- $saved->setParameter($key, $value);
- }
- }
-
-
- /**
- * Applies data from a saved query to an executable query.
- *
- * @param PhabricatorCursorPagedPolicyAwareQuery Query to constrain.
- * @param PhabricatorSavedQuery Saved query to read.
- * @return void
- */
- protected function applyCustomFieldsToQuery(
- PhabricatorCursorPagedPolicyAwareQuery $query,
- PhabricatorSavedQuery $saved) {
-
- $list = $this->getCustomFieldList();
- if (!$list) {
- return;
- }
-
- foreach ($list->getFields() as $field) {
- $key = $this->getKeyForCustomField($field);
- $value = $field->applyApplicationSearchConstraintToQuery(
- $this,
- $query,
- $saved->getParameter($key));
- }
- }
-
- /**
- * Get a unique key identifying a field.
- *
- * @param PhabricatorCustomField Field to identify.
- * @return string Unique identifier, suitable for use as an input name.
- */
- public function getKeyForCustomField(PhabricatorCustomField $field) {
- return 'custom:'.$field->getFieldIndex();
- }
-
private function buildCustomFieldSearchFields() {
$list = $this->getCustomFieldList();
if (!$list) {
@@ -1135,24 +1073,8 @@
->setSearchEngine($this)
->setCustomField($field);
}
- return $fields;
- }
-
- // TODO: Remove.
- protected function appendCustomFieldsToForm(
- AphrontFormView $form,
- PhabricatorSavedQuery $saved) {
-
- $list = $this->getCustomFieldList();
- if (!$list) {
- return;
- }
- foreach ($list->getFields() as $field) {
- $key = $this->getKeyForCustomField($field);
- $value = $saved->getParameter($key);
- $field->appendToApplicationSearchForm($this, $form, $value);
- }
+ return $fields;
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 5, 1:51 PM (1 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6755692
Default Alt Text
D13203.diff (14 KB)
Attached To
Mode
D13203: New Revision via Web UI
Attached
Detach File
Event Timeline
Log In to Comment