@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<?php
2
3final class PhabricatorProjectColumnViewQueryController
4 extends PhabricatorProjectBoardController {
5
6 public function handleRequest(AphrontRequest $request) {
7 $viewer = $request->getViewer();
8
9 $response = $this->loadProject();
10 if ($response) {
11 return $response;
12 }
13
14 $project = $this->getProject();
15 $state = $this->getViewState();
16 $board_uri = $state->newWorkboardURI();
17
18 // NOTE: We're performing layout without handing the "LayoutEngine" any
19 // object PHIDs. We only want to get access to the column object the user
20 // is trying to query, so we do not need to actually position any cards on
21 // the board.
22
23 $board_phid = $project->getPHID();
24
25 $layout_engine = id(new PhabricatorBoardLayoutEngine())
26 ->setViewer($viewer)
27 ->setBoardPHIDs(array($board_phid))
28 ->setFetchAllBoards(true)
29 ->executeLayout();
30
31 $columns = $layout_engine->getColumns($board_phid);
32 $columns = mpull($columns, null, 'getID');
33
34 $column_id = $request->getURIData('columnID');
35 $column = idx($columns, $column_id);
36 if (!$column) {
37 return new Aphront404Response();
38 }
39
40 // Create a saved query to combine the active filter on the workboard
41 // with the column filter. If the user currently has constraints on the
42 // board, we want to add a new column or project constraint, not
43 // completely replace the constraints.
44 $default_query = $state->getSavedQuery();
45 $saved_query = $default_query->newCopy();
46
47 if ($column->getProxyPHID()) {
48 $project_phids = $saved_query->getParameter('projectPHIDs');
49 if (!$project_phids) {
50 $project_phids = array();
51 }
52 $project_phids[] = $column->getProxyPHID();
53 $saved_query->setParameter('projectPHIDs', $project_phids);
54 } else {
55 $saved_query->setParameter(
56 'columnPHIDs',
57 array($column->getPHID()));
58 }
59
60 $search_engine = id(new ManiphestTaskSearchEngine())
61 ->setViewer($viewer);
62
63 $search_engine->saveQuery($saved_query);
64
65 $query_key = $saved_query->getQueryKey();
66 $query_uri = new PhutilURI("/maniphest/query/{$query_key}/#R");
67
68 return id(new AphrontRedirectResponse())
69 ->setURI($query_uri);
70 }
71
72}