@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 57 lines 1.7 kB view raw
1<?php 2 3final class PhabricatorMacroDisableController 4 extends PhabricatorMacroController { 5 6 public function handleRequest(AphrontRequest $request) { 7 $viewer = $request->getViewer(); 8 $id = $request->getURIData('id'); 9 10 $this->requireApplicationCapability( 11 PhabricatorMacroManageCapability::CAPABILITY); 12 13 $macro = id(new PhabricatorMacroQuery()) 14 ->setViewer($viewer) 15 ->withIDs(array($id)) 16 ->executeOne(); 17 if (!$macro) { 18 return new Aphront404Response(); 19 } 20 21 $view_uri = $this->getApplicationURI('/view/'.$id.'/'); 22 23 if ($request->isDialogFormPost() || $macro->getIsDisabled()) { 24 $xaction = id(new PhabricatorMacroTransaction()) 25 ->setTransactionType( 26 PhabricatorMacroDisabledTransaction::TRANSACTIONTYPE) 27 ->setNewValue($macro->getIsDisabled() ? 0 : 1); 28 29 $editor = id(new PhabricatorMacroEditor()) 30 ->setActor($viewer) 31 ->setContentSourceFromRequest($request); 32 33 $xactions = $editor->applyTransactions($macro, array($xaction)); 34 35 return id(new AphrontRedirectResponse())->setURI($view_uri); 36 } 37 38 $dialog = new AphrontDialogView(); 39 $dialog 40 ->setUser($request->getUser()) 41 ->setTitle(pht('Really disable macro?')) 42 ->appendChild( 43 phutil_tag( 44 'p', 45 array(), 46 pht( 47 'Really disable the much-beloved image macro %s? '. 48 'It will be sorely missed.', 49 $macro->getName()))) 50 ->setSubmitURI($this->getApplicationURI('/disable/'.$id.'/')) 51 ->addSubmitButton(pht('Disable')) 52 ->addCancelButton($view_uri); 53 54 return id(new AphrontDialogResponse())->setDialog($dialog); 55 } 56 57}