@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 "Any User Projects" to Maniphest Custom Query

Summary: Added a new way of filtering projects in Maniphest custom queries. This will filter on any project that a user is associated with.

Test Plan:
- Create some tasks.
- Create a project (auto join).
- Add the project to some of the tasks.
- Run custom query, see the correct task.
- Save custom query, check the same tasks are there.
- Add the project to another task, check task was added in the custom query list view.
- Remove the project from a task and check the task disappeared from the custom query list view.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

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

authored by

Gareth Evans and committed by
epriestley
81377dd9 74609d93

+74 -21
+36 -11
src/applications/maniphest/ManiphestTaskQuery.php
··· 8 8 */ 9 9 final class ManiphestTaskQuery extends PhabricatorQuery { 10 10 11 - private $taskIDs = array(); 12 - private $taskPHIDs = array(); 13 - private $authorPHIDs = array(); 14 - private $ownerPHIDs = array(); 15 - private $includeUnowned = null; 16 - private $projectPHIDs = array(); 17 - private $xprojectPHIDs = array(); 18 - private $subscriberPHIDs = array(); 19 - private $anyProjectPHIDs = array(); 20 - private $includeNoProject = null; 11 + private $taskIDs = array(); 12 + private $taskPHIDs = array(); 13 + private $authorPHIDs = array(); 14 + private $ownerPHIDs = array(); 15 + private $includeUnowned = null; 16 + private $projectPHIDs = array(); 17 + private $xprojectPHIDs = array(); 18 + private $subscriberPHIDs = array(); 19 + private $anyProjectPHIDs = array(); 20 + private $anyUserProjectPHIDs = array(); 21 + private $includeNoProject = null; 21 22 22 23 private $fullTextSearch = ''; 23 24 ··· 183 184 return $this; 184 185 } 185 186 187 + public function withAnyUserProjects(array $users) { 188 + $this->anyUserProjectPHIDs = $users; 189 + return $this; 190 + } 191 + 186 192 public function execute() { 187 193 188 194 $task_dao = new ManiphestTask(); ··· 204 210 $where[] = $this->buildSubscriberWhereClause($conn); 205 211 $where[] = $this->buildProjectWhereClause($conn); 206 212 $where[] = $this->buildAnyProjectWhereClause($conn); 213 + $where[] = $this->buildAnyUserProjectWhereClause($conn); 207 214 $where[] = $this->buildXProjectWhereClause($conn); 208 215 $where[] = $this->buildFullTextWhereClause($conn); 209 216 ··· 475 482 $this->anyProjectPHIDs); 476 483 } 477 484 485 + private function buildAnyUserProjectWhereClause( 486 + AphrontDatabaseConnection $conn) { 487 + if (!$this->anyUserProjectPHIDs) { 488 + return null; 489 + } 490 + 491 + $projects = id(new PhabricatorProjectQuery()) 492 + ->setViewer($this->viewer) 493 + ->withMemberPHIDs($this->anyUserProjectPHIDs) 494 + ->execute(); 495 + $any_user_project_phids = mpull($projects, 'getPHID'); 496 + 497 + return qsprintf( 498 + $conn, 499 + 'anyproject.projectPHID IN (%Ls)', 500 + $any_user_project_phids); 501 + } 502 + 478 503 private function buildAnyProjectJoinClause(AphrontDatabaseConnection $conn) { 479 - if (!$this->anyProjectPHIDs) { 504 + if (!$this->anyProjectPHIDs && !$this->anyUserProjectPHIDs) { 480 505 return null; 481 506 } 482 507
+38 -10
src/applications/maniphest/controller/ManiphestTaskListController.php
··· 37 37 $max_priority = $request->getInt('set_hpriority'); 38 38 39 39 $uri = $request->getRequestURI() 40 - ->alter('users', $this->getArrToStrList('set_users')) 41 - ->alter('projects', $this->getArrToStrList('set_projects')) 42 - ->alter('aprojects', $this->getArrToStrList('set_aprojects')) 43 - ->alter('xprojects', $this->getArrToStrList('set_xprojects')) 44 - ->alter('owners', $this->getArrToStrList('set_owners')) 45 - ->alter('authors', $this->getArrToStrList('set_authors')) 46 - ->alter('lpriority', $min_priority) 47 - ->alter('hpriority', $max_priority) 48 - ->alter('tasks', $task_ids) 49 - ->alter('search', $search_text); 40 + ->alter('users', $this->getArrToStrList('set_users')) 41 + ->alter('projects', $this->getArrToStrList('set_projects')) 42 + ->alter('aprojects', $this->getArrToStrList('set_aprojects')) 43 + ->alter('useraprojects', $this->getArrToStrList('set_useraprojects')) 44 + ->alter('xprojects', $this->getArrToStrList('set_xprojects')) 45 + ->alter('owners', $this->getArrToStrList('set_owners')) 46 + ->alter('authors', $this->getArrToStrList('set_authors')) 47 + ->alter('lpriority', $min_priority) 48 + ->alter('hpriority', $max_priority) 49 + ->alter('tasks', $task_ids) 50 + ->alter('search', $search_text); 50 51 51 52 return id(new AphrontRedirectResponse())->setURI($uri); 52 53 } ··· 104 105 $project_phids = $query->getParameter('projectPHIDs', array()); 105 106 $any_project_phids = $query->getParameter( 106 107 'anyProjectPHIDs', 108 + array()); 109 + $any_user_project_phids = $query->getParameter( 110 + 'anyUserProjectPHIDs', 107 111 array()); 108 112 $exclude_project_phids = $query->getParameter( 109 113 'excludeProjectPHIDs', ··· 216 220 ->setValue($atokens)); 217 221 218 222 $tokens = array(); 223 + foreach ($any_user_project_phids as $phid) { 224 + $tokens[$phid] = $handles[$phid]->getFullName(); 225 + } 226 + $form->appendChild( 227 + id(new AphrontFormTokenizerControl()) 228 + ->setDatasource('/typeahead/common/users/') 229 + ->setName('set_useraprojects') 230 + ->setLabel(pht('Any User Projects')) 231 + ->setCaption( 232 + pht('Find tasks in ANY of these users\' projects ("OR" query).')) 233 + ->setValue($tokens)); 234 + 235 + $tokens = array(); 219 236 foreach ($exclude_project_phids as $phid) { 220 237 $tokens[$phid] = $handles[$phid]->getFullName(); 221 238 } ··· 427 444 $any_project_phids = $search_query->getParameter( 428 445 'anyProjectPHIDs', 429 446 array()); 447 + $any_user_project_phids = $search_query->getParameter( 448 + 'anyUserProjectPHIDs', 449 + array()); 430 450 $xproject_phids = $search_query->getParameter( 431 451 'excludeProjectPHIDs', 432 452 array()); ··· 463 483 $query->withAuthors($author_phids); 464 484 } 465 485 486 + if ($any_user_project_phids) { 487 + $query->setViewer($viewer); 488 + $query->withAnyUserProjects($any_user_project_phids); 489 + } 490 + 466 491 $status = $search_query->getParameter('status', 'all'); 467 492 if (!empty($status['open']) && !empty($status['closed'])) { 468 493 $query->withStatus(ManiphestTaskQuery::STATUS_ANY); ··· 740 765 ->withMemberPHIDs($user_phids) 741 766 ->execute(); 742 767 $any_project_phids = mpull($projects, 'getPHID'); 768 + $any_user_project_phids = array(); 743 769 } else { 744 770 $any_project_phids = $request->getStrList('aprojects'); 771 + $any_user_project_phids = $request->getStrList('useraprojects'); 745 772 } 746 773 747 774 $project_phids = $request->getStrList('projects'); ··· 787 814 'userPHIDs' => $user_phids, 788 815 'projectPHIDs' => $project_phids, 789 816 'anyProjectPHIDs' => $any_project_phids, 817 + 'anyUserProjectPHIDs' => $any_user_project_phids, 790 818 'excludeProjectPHIDs' => $exclude_project_phids, 791 819 'ownerPHIDs' => $owner_phids, 792 820 'authorPHIDs' => $author_phids,