@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add "assigned" and "authors" to Maniphest pro search

Summary: Ref T2625. Moves this a step toward being able to replace the current search.

Test Plan: Used search interface.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2625

Differential Revision: https://secure.phabricator.com/D6934

+71 -3
+71 -3
src/applications/maniphest/query/ManiphestTaskSearchEngine.php
··· 6 6 public function buildSavedQueryFromRequest(AphrontRequest $request) { 7 7 $saved = new PhabricatorSavedQuery(); 8 8 9 + $saved->setParameter( 10 + 'assignedPHIDs', 11 + $this->readUsersFromRequest($request, 'assigned')); 12 + 13 + $saved->setParameter('withUnassigned', $request->getBool('withUnassigned')); 14 + 15 + $saved->setParameter( 16 + 'authorPHIDs', 17 + $this->readUsersFromRequest($request, 'authors')); 18 + 9 19 return $saved; 10 20 } 11 21 12 22 public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) { 13 23 $query = id(new ManiphestTaskQuery()); 14 24 25 + $author_phids = $saved->getParameter('authorPHIDs'); 26 + if ($author_phids) { 27 + $query->withAuthors($author_phids); 28 + } 29 + 30 + $with_unassigned = $saved->getParameter('withUnassigned'); 31 + if ($with_unassigned) { 32 + $query->withOwners(array(null)); 33 + } else { 34 + $assigned_phids = $saved->getParameter('assignedPHIDs', array()); 35 + if ($assigned_phids) { 36 + $query->withOwners($assigned_phids); 37 + } 38 + } 15 39 16 40 return $query; 17 41 } 18 42 19 43 public function buildSearchForm( 20 44 AphrontFormView $form, 21 - PhabricatorSavedQuery $saved_query) { 45 + PhabricatorSavedQuery $saved) { 22 46 47 + $assigned_phids = $saved->getParameter('assignedPHIDs', array()); 48 + $author_phids = $saved->getParameter('authorPHIDs', array()); 49 + 50 + $all_phids = array_merge($assigned_phids, $author_phids); 51 + 52 + if ($all_phids) { 53 + $handles = id(new PhabricatorHandleQuery()) 54 + ->setViewer($this->requireViewer()) 55 + ->withPHIDs($all_phids) 56 + ->execute(); 57 + } else { 58 + $handles = array(); 59 + } 60 + 61 + $assigned_tokens = array_select_keys($handles, $assigned_phids); 62 + $assigned_tokens = mpull($assigned_tokens, 'getFullName', 'getPHID'); 63 + 64 + $author_tokens = array_select_keys($handles, $author_phids); 65 + $author_tokens = mpull($author_tokens, 'getFullName', 'getPHID'); 66 + 67 + $with_unassigned = $saved->getParameter('withUnassigned'); 68 + 69 + $form 70 + ->appendChild( 71 + id(new AphrontFormTokenizerControl()) 72 + ->setDatasource('/typeahead/common/accounts/') 73 + ->setName('assigned') 74 + ->setLabel(pht('Assigned To')) 75 + ->setValue($assigned_tokens)) 76 + ->appendChild( 77 + id(new AphrontFormCheckboxControl()) 78 + ->addCheckbox( 79 + 'withUnassigned', 80 + 1, 81 + pht('Show only unassigned tasks.'), 82 + $with_unassigned)) 83 + ->appendChild( 84 + id(new AphrontFormTokenizerControl()) 85 + ->setDatasource('/typeahead/common/accounts/') 86 + ->setName('authors') 87 + ->setLabel(pht('Authors')) 88 + ->setValue($author_tokens)); 23 89 } 24 90 25 91 protected function getURI($path) { ··· 44 110 $query = $this->newSavedQuery(); 45 111 $query->setQueryKey($query_key); 46 112 113 + $viewer_phid = $this->requireViewer()->getPHID(); 114 + 47 115 switch ($query_key) { 48 116 case 'all': 49 117 return $query; 50 118 case 'assigned': 51 - return $query; 119 + return $query->setParameter('assignedPHIDs', array($viewer_phid)); 52 120 case 'authored': 53 - return $query; 121 + return $query->setParameter('authorPHIDs', array($viewer_phid)); 54 122 } 55 123 56 124 return parent::buildSavedQueryFromBuiltin($query_key);