@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 upstream/main 69 lines 2.0 kB view raw
1<?php 2 3final class PhabricatorProjectArchiveController 4 extends PhabricatorProjectController { 5 6 public function handleRequest(AphrontRequest $request) { 7 $viewer = $request->getViewer(); 8 $id = $request->getURIData('id'); 9 10 $project = id(new PhabricatorProjectQuery()) 11 ->setViewer($viewer) 12 ->withIDs(array($id)) 13 ->requireCapabilities( 14 array( 15 PhabricatorPolicyCapability::CAN_VIEW, 16 PhabricatorPolicyCapability::CAN_EDIT, 17 )) 18 ->executeOne(); 19 if (!$project) { 20 return new Aphront404Response(); 21 } 22 23 $edit_uri = $this->getApplicationURI('manage/'.$project->getID().'/'); 24 25 if ($request->isFormPost()) { 26 if ($project->isArchived()) { 27 $new_status = PhabricatorProjectStatus::STATUS_ACTIVE; 28 } else { 29 $new_status = PhabricatorProjectStatus::STATUS_ARCHIVED; 30 } 31 32 $xactions = array(); 33 34 $xactions[] = id(new PhabricatorProjectTransaction()) 35 ->setTransactionType( 36 PhabricatorProjectStatusTransaction::TRANSACTIONTYPE) 37 ->setNewValue($new_status); 38 39 id(new PhabricatorProjectTransactionEditor()) 40 ->setActor($viewer) 41 ->setContentSourceFromRequest($request) 42 ->setContinueOnNoEffect(true) 43 ->setContinueOnMissingFields(true) 44 ->applyTransactions($project, $xactions); 45 46 return id(new AphrontRedirectResponse())->setURI($edit_uri); 47 } 48 49 if ($project->isArchived()) { 50 $title = pht('Really activate project?'); 51 $body = pht('This project will become active again.'); 52 $button = pht('Activate Project'); 53 } else { 54 $title = pht('Really archive project?'); 55 $body = pht('This project will be moved to the archive.'); 56 $button = pht('Archive Project'); 57 } 58 59 $dialog = id(new AphrontDialogView()) 60 ->setUser($viewer) 61 ->setTitle($title) 62 ->appendChild($body) 63 ->addCancelButton($edit_uri) 64 ->addSubmitButton($button); 65 66 return id(new AphrontDialogResponse())->setDialog($dialog); 67 } 68 69}