@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
at recaptime-dev/main 81 lines 2.6 kB view raw
1<?php 2 3final class PhabricatorProjectBoardDefaultController 4 extends PhabricatorProjectBoardController { 5 6 public function handleRequest(AphrontRequest $request) { 7 $viewer = $request->getViewer(); 8 9 $response = $this->loadProjectForEdit(); 10 if ($response) { 11 return $response; 12 } 13 14 $project = $this->getProject(); 15 $state = $this->getViewState(); 16 $board_uri = $state->newWorkboardURI(); 17 $remove_param = null; 18 19 $target = $request->getURIData('target'); 20 switch ($target) { 21 case 'filter': 22 $title = pht('Set Board Default Filter'); 23 $body = pht( 24 'Make the current filter the new default filter for this board? '. 25 'All users will see the new filter as the default when they view '. 26 'the board.'); 27 $button = pht('Save Default Filter'); 28 29 $xaction_value = $state->getQueryKey(); 30 $xaction_type = PhabricatorProjectFilterTransaction::TRANSACTIONTYPE; 31 32 $remove_param = 'filter'; 33 break; 34 case 'sort': 35 $title = pht('Set Board Default Order'); 36 $body = pht( 37 'Make the current sort order the new default order for this board? '. 38 'All users will see the new order as the default when they view '. 39 'the board.'); 40 $button = pht('Save Default Order'); 41 42 $xaction_value = $state->getOrder(); 43 $xaction_type = PhabricatorProjectSortTransaction::TRANSACTIONTYPE; 44 45 $remove_param = 'order'; 46 break; 47 default: 48 return new Aphront404Response(); 49 } 50 51 $id = $project->getID(); 52 53 if ($request->isFormPost()) { 54 $xactions = array(); 55 56 $xactions[] = id(new PhabricatorProjectTransaction()) 57 ->setTransactionType($xaction_type) 58 ->setNewValue($xaction_value); 59 60 id(new PhabricatorProjectTransactionEditor()) 61 ->setActor($viewer) 62 ->setContentSourceFromRequest($request) 63 ->setContinueOnNoEffect(true) 64 ->setContinueOnMissingFields(true) 65 ->applyTransactions($project, $xactions); 66 67 // If the parameter we just modified is present in the query string, 68 // throw it away so the user is redirected back to the default view of 69 // the board, allowing them to see the new default behavior. 70 $board_uri->removeQueryParam($remove_param); 71 72 return id(new AphrontRedirectResponse())->setURI($board_uri); 73 } 74 75 return $this->newWorkboardDialog() 76 ->setTitle($title) 77 ->appendChild($body) 78 ->addCancelButton($board_uri) 79 ->addSubmitButton($title); 80 } 81}