Changeset View
Changeset View
Standalone View
Standalone View
src/applications/maniphest/query/ManiphestTaskSearchEngine.php
Show First 20 Lines • Show All 83 Lines • ▼ Show 20 Lines | foreach ($ids as $key => $id) { | ||||
$ids[$key] = $id; | $ids[$key] = $id; | ||||
} | } | ||||
} | } | ||||
$saved->setParameter('ids', $ids); | $saved->setParameter('ids', $ids); | ||||
$saved->setParameter('fulltext', $request->getStr('fulltext')); | $saved->setParameter('fulltext', $request->getStr('fulltext')); | ||||
$saved->setParameter( | $saved->setParameter( | ||||
'allProjectPHIDs', | 'projects', | ||||
$this->readPHIDsFromRequest($request, 'allProjects')); | $this->readProjectsFromRequest($request, 'projects')); | ||||
$saved->setParameter( | |||||
'withNoProject', | |||||
$request->getBool('withNoProject')); | |||||
$saved->setParameter( | |||||
'anyProjectPHIDs', | |||||
$this->readPHIDsFromRequest($request, 'anyProjects')); | |||||
$saved->setParameter( | |||||
'excludeProjectPHIDs', | |||||
$this->readPHIDsFromRequest($request, 'excludeProjects')); | |||||
$saved->setParameter( | |||||
'userProjectPHIDs', | |||||
$this->readUsersFromRequest($request, 'userProjects')); | |||||
$saved->setParameter('createdStart', $request->getStr('createdStart')); | $saved->setParameter('createdStart', $request->getStr('createdStart')); | ||||
$saved->setParameter('createdEnd', $request->getStr('createdEnd')); | $saved->setParameter('createdEnd', $request->getStr('createdEnd')); | ||||
$saved->setParameter('modifiedStart', $request->getStr('modifiedStart')); | $saved->setParameter('modifiedStart', $request->getStr('modifiedStart')); | ||||
$saved->setParameter('modifiedEnd', $request->getStr('modifiedEnd')); | $saved->setParameter('modifiedEnd', $request->getStr('modifiedEnd')); | ||||
$limit = $request->getInt('limit'); | $limit = $request->getInt('limit'); | ||||
if ($limit > 0) { | if ($limit > 0) { | ||||
▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | if ($ids) { | ||||
$query->withIDs($ids); | $query->withIDs($ids); | ||||
} | } | ||||
$fulltext = $saved->getParameter('fulltext'); | $fulltext = $saved->getParameter('fulltext'); | ||||
if (strlen($fulltext)) { | if (strlen($fulltext)) { | ||||
$query->withFullTextSearch($fulltext); | $query->withFullTextSearch($fulltext); | ||||
} | } | ||||
$with_no_project = $saved->getParameter('withNoProject'); | $projects = $this->readProjectTokens($saved); | ||||
if ($with_no_project) { | $adjusted = id(clone $saved)->setParameter('projects', $projects); | ||||
$query->withAllProjects(array(ManiphestTaskOwner::PROJECT_NO_PROJECT)); | $this->setQueryProjects($query, $adjusted); | ||||
} else { | |||||
$project_phids = $saved->getParameter('allProjectPHIDs'); | |||||
if ($project_phids) { | |||||
$query->withAllProjects($project_phids); | |||||
} | |||||
} | |||||
$any_project_phids = $saved->getParameter('anyProjectPHIDs'); | |||||
if ($any_project_phids) { | |||||
$query->withAnyProjects($any_project_phids); | |||||
} | |||||
$exclude_project_phids = $saved->getParameter('excludeProjectPHIDs'); | |||||
if ($exclude_project_phids) { | |||||
$query->withoutProjects($exclude_project_phids); | |||||
} | |||||
$user_project_phids = $saved->getParameter('userProjectPHIDs'); | |||||
if ($user_project_phids) { | |||||
$query->withAnyUserProjects($user_project_phids); | |||||
} | |||||
$start = $this->parseDateTime($saved->getParameter('createdStart')); | $start = $this->parseDateTime($saved->getParameter('createdStart')); | ||||
$end = $this->parseDateTime($saved->getParameter('createdEnd')); | $end = $this->parseDateTime($saved->getParameter('createdEnd')); | ||||
if ($start) { | if ($start) { | ||||
$query->withDateCreatedAfter($start); | $query->withDateCreatedAfter($start); | ||||
} | } | ||||
Show All 19 Lines | final class ManiphestTaskSearchEngine | ||||
public function buildSearchForm( | public function buildSearchForm( | ||||
AphrontFormView $form, | AphrontFormView $form, | ||||
PhabricatorSavedQuery $saved) { | PhabricatorSavedQuery $saved) { | ||||
$assigned_phids = $this->readAssignedPHIDs($saved); | $assigned_phids = $this->readAssignedPHIDs($saved); | ||||
$author_phids = $saved->getParameter('authorPHIDs', array()); | $author_phids = $saved->getParameter('authorPHIDs', array()); | ||||
$all_project_phids = $saved->getParameter( | $projects = $this->readProjectTokens($saved); | ||||
'allProjectPHIDs', | |||||
array()); | |||||
$any_project_phids = $saved->getParameter( | |||||
'anyProjectPHIDs', | |||||
array()); | |||||
$exclude_project_phids = $saved->getParameter( | |||||
'excludeProjectPHIDs', | |||||
array()); | |||||
$user_project_phids = $saved->getParameter( | |||||
'userProjectPHIDs', | |||||
array()); | |||||
$subscriber_phids = $saved->getParameter('subscriberPHIDs', array()); | |||||
$with_no_projects = $saved->getParameter('withNoProject'); | $subscriber_phids = $saved->getParameter('subscriberPHIDs', array()); | ||||
$statuses = $saved->getParameter('statuses', array()); | $statuses = $saved->getParameter('statuses', array()); | ||||
$statuses = array_fuse($statuses); | $statuses = array_fuse($statuses); | ||||
$status_control = id(new AphrontFormCheckboxControl()) | $status_control = id(new AphrontFormCheckboxControl()) | ||||
->setLabel(pht('Status')); | ->setLabel(pht('Status')); | ||||
foreach (ManiphestTaskStatus::getTaskStatusMap() as $status => $name) { | foreach (ManiphestTaskStatus::getTaskStatusMap() as $status => $name) { | ||||
$status_control->addCheckbox( | $status_control->addCheckbox( | ||||
'statuses[]', | 'statuses[]', | ||||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | $form | ||||
->appendControl( | ->appendControl( | ||||
id(new AphrontFormTokenizerControl()) | id(new AphrontFormTokenizerControl()) | ||||
->setDatasource(new PhabricatorPeopleOwnerDatasource()) | ->setDatasource(new PhabricatorPeopleOwnerDatasource()) | ||||
->setName('assigned') | ->setName('assigned') | ||||
->setLabel(pht('Assigned To')) | ->setLabel(pht('Assigned To')) | ||||
->setValue($assigned_phids)) | ->setValue($assigned_phids)) | ||||
->appendControl( | ->appendControl( | ||||
id(new AphrontFormTokenizerControl()) | id(new AphrontFormTokenizerControl()) | ||||
->setDatasource(new PhabricatorProjectDatasource()) | ->setDatasource(new PhabricatorProjectLogicalDatasource()) | ||||
->setName('allProjects') | ->setName('projects') | ||||
->setLabel(pht('In All Projects')) | ->setLabel(pht('Projects')) | ||||
->setValue($all_project_phids)); | ->setValue($projects)) | ||||
if (!$this->getIsBoardView()) { | |||||
$form | |||||
->appendChild( | |||||
id(new AphrontFormCheckboxControl()) | |||||
->addCheckbox( | |||||
'withNoProject', | |||||
1, | |||||
pht('Show only tasks with no projects.'), | |||||
$with_no_projects)); | |||||
} | |||||
$form | |||||
->appendControl( | |||||
id(new AphrontFormTokenizerControl()) | |||||
->setDatasource(new PhabricatorProjectDatasource()) | |||||
->setName('anyProjects') | |||||
->setLabel(pht('In Any Project')) | |||||
->setValue($any_project_phids)) | |||||
->appendControl( | |||||
id(new AphrontFormTokenizerControl()) | |||||
->setDatasource(new PhabricatorProjectDatasource()) | |||||
->setName('excludeProjects') | |||||
->setLabel(pht('Not In Projects')) | |||||
->setValue($exclude_project_phids)) | |||||
->appendControl( | |||||
id(new AphrontFormTokenizerControl()) | |||||
->setDatasource(new PhabricatorPeopleDatasource()) | |||||
->setName('userProjects') | |||||
->setLabel(pht('In Users\' Projects')) | |||||
->setValue($user_project_phids)) | |||||
->appendControl( | ->appendControl( | ||||
id(new AphrontFormTokenizerControl()) | id(new AphrontFormTokenizerControl()) | ||||
->setDatasource(new PhabricatorPeopleDatasource()) | ->setDatasource(new PhabricatorPeopleDatasource()) | ||||
->setName('authors') | ->setName('authors') | ||||
->setLabel(pht('Authors')) | ->setLabel(pht('Authors')) | ||||
->setValue($author_phids)) | ->setValue($author_phids)) | ||||
->appendControl( | ->appendControl( | ||||
id(new AphrontFormTokenizerControl()) | id(new AphrontFormTokenizerControl()) | ||||
▲ Show 20 Lines • Show All 198 Lines • ▼ Show 20 Lines | private function readAssignedPHIDs(PhabricatorSavedQuery $saved) { | ||||
// migrating old saved queries. | // migrating old saved queries. | ||||
if ($saved->getParameter('withUnassigned')) { | if ($saved->getParameter('withUnassigned')) { | ||||
$assigned_phids[] = PhabricatorPeopleNoOwnerDatasource::FUNCTION_TOKEN; | $assigned_phids[] = PhabricatorPeopleNoOwnerDatasource::FUNCTION_TOKEN; | ||||
} | } | ||||
return $assigned_phids; | return $assigned_phids; | ||||
} | } | ||||
private function readProjectTokens(PhabricatorSavedQuery $saved) { | |||||
$projects = $saved->getParameter('projects', array()); | |||||
$all = $saved->getParameter('allProjectPHIDs', array()); | |||||
foreach ($all as $phid) { | |||||
$projects[] = $phid; | |||||
} | |||||
$any = $saved->getParameter('anyProjectPHIDs', array()); | |||||
foreach ($any as $phid) { | |||||
$projects[] = 'any('.$phid.')'; | |||||
} | |||||
$not = $saved->getParameter('excludeProjectPHIDs', array()); | |||||
foreach ($not as $phid) { | |||||
$projects[] = 'not('.$phid.')'; | |||||
} | |||||
$users = $saved->getParameter('userProjectPHIDs', array()); | |||||
foreach ($users as $phid) { | |||||
$projects[] = 'projects('.$phid.')'; | |||||
} | |||||
$no = $saved->getParameter('withNoProject'); | |||||
if ($no) { | |||||
$projects[] = 'null()'; | |||||
} | |||||
return $projects; | |||||
} | |||||
} | } |