@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 65 lines 1.7 kB view raw
1<?php 2 3final class PholioMockArchiveController 4 extends PholioController { 5 6 public function handleRequest(AphrontRequest $request) { 7 $viewer = $request->getViewer(); 8 $id = $request->getURIData('id'); 9 10 $mock = id(new PholioMockQuery()) 11 ->setViewer($viewer) 12 ->withIDs(array($id)) 13 ->requireCapabilities( 14 array( 15 PhabricatorPolicyCapability::CAN_VIEW, 16 PhabricatorPolicyCapability::CAN_EDIT, 17 )) 18 ->executeOne(); 19 if (!$mock) { 20 return new Aphront404Response(); 21 } 22 23 $view_uri = '/M'.$mock->getID(); 24 25 if ($request->isFormPost()) { 26 if ($mock->isClosed()) { 27 $new_status = PholioMock::STATUS_OPEN; 28 } else { 29 $new_status = PholioMock::STATUS_CLOSED; 30 } 31 32 $xactions = array(); 33 34 $xactions[] = id(new PholioTransaction()) 35 ->setTransactionType(PholioMockStatusTransaction::TRANSACTIONTYPE) 36 ->setNewValue($new_status); 37 38 id(new PholioMockEditor()) 39 ->setActor($viewer) 40 ->setContentSourceFromRequest($request) 41 ->setContinueOnNoEffect(true) 42 ->setContinueOnMissingFields(true) 43 ->applyTransactions($mock, $xactions); 44 45 return id(new AphrontRedirectResponse())->setURI($view_uri); 46 } 47 48 if ($mock->isClosed()) { 49 $title = pht('Open Pholio Mock'); 50 $body = pht('This mock will become open again.'); 51 $button = pht('Open Mock'); 52 } else { 53 $title = pht('Close Pholio Mock'); 54 $body = pht('This mock will be closed.'); 55 $button = pht('Close Mock'); 56 } 57 58 return $this->newDialog() 59 ->setTitle($title) 60 ->appendChild($body) 61 ->addCancelButton($view_uri) 62 ->addSubmitButton($button); 63 } 64 65}