@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 PhabricatorProjectColumnBulkEditController
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 $layout_engine = $state->getLayoutEngine();
19
20 $board_phid = $project->getPHID();
21 $columns = $layout_engine->getColumns($board_phid);
22 $columns = mpull($columns, null, 'getID');
23
24 $column_id = $request->getURIData('columnID');
25 $bulk_column = idx($columns, $column_id);
26 if (!$bulk_column) {
27 return new Aphront404Response();
28 }
29
30 $bulk_task_phids = $layout_engine->getColumnObjectPHIDs(
31 $board_phid,
32 $bulk_column->getPHID());
33
34 $tasks = $state->getObjects();
35
36 $bulk_tasks = array_select_keys($tasks, $bulk_task_phids);
37
38 $bulk_tasks = id(new PhabricatorPolicyFilter())
39 ->setViewer($viewer)
40 ->requireCapabilities(array(PhabricatorPolicyCapability::CAN_EDIT))
41 ->apply($bulk_tasks);
42
43 if (!$bulk_tasks) {
44 return $this->newDialog()
45 ->setTitle(pht('No Editable Tasks'))
46 ->appendParagraph(
47 pht(
48 'The selected column contains no visible tasks which you '.
49 'have permission to edit.'))
50 ->addCancelButton($board_uri);
51 }
52
53 // Create a saved query to hold the working set. This allows us to get
54 // around URI length limitations with a long "?ids=..." query string.
55 // For details, see T10268.
56 $search_engine = id(new ManiphestTaskSearchEngine())
57 ->setViewer($viewer);
58
59 $saved_query = $search_engine->newSavedQuery();
60 $saved_query->setParameter('ids', mpull($bulk_tasks, 'getID'));
61 $search_engine->saveQuery($saved_query);
62
63 $query_key = $saved_query->getQueryKey();
64
65 $bulk_uri = new PhutilURI("/maniphest/bulk/query/{$query_key}/");
66 $bulk_uri->replaceQueryParam('board', $project->getID());
67
68 return id(new AphrontRedirectResponse())
69 ->setURI($bulk_uri);
70 }
71
72}