@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 77 lines 2.3 kB view raw
1<?php 2 3final class PhabricatorSpacesArchiveController 4 extends PhabricatorSpacesController { 5 6 public function handleRequest(AphrontRequest $request) { 7 $viewer = $request->getUser(); 8 9 $space = id(new PhabricatorSpacesNamespaceQuery()) 10 ->setViewer($viewer) 11 ->withIDs(array($request->getURIData('id'))) 12 ->requireCapabilities( 13 array( 14 PhabricatorPolicyCapability::CAN_VIEW, 15 PhabricatorPolicyCapability::CAN_EDIT, 16 )) 17 ->executeOne(); 18 if (!$space) { 19 return new Aphront404Response(); 20 } 21 22 $is_archive = ($request->getURIData('action') == 'archive'); 23 $cancel_uri = '/'.$space->getMonogram(); 24 25 if ($request->isFormPost()) { 26 $type_archive = 27 PhabricatorSpacesNamespaceArchiveTransaction::TRANSACTIONTYPE; 28 29 $xactions = array(); 30 $xactions[] = id(new PhabricatorSpacesNamespaceTransaction()) 31 ->setTransactionType($type_archive) 32 ->setNewValue($is_archive ? 1 : 0); 33 34 $editor = id(new PhabricatorSpacesNamespaceEditor()) 35 ->setActor($viewer) 36 ->setContinueOnNoEffect(true) 37 ->setContinueOnMissingFields(true) 38 ->setContentSourceFromRequest($request); 39 40 $editor->applyTransactions($space, $xactions); 41 42 return id(new AphrontRedirectResponse())->setURI($cancel_uri); 43 } 44 45 $body = array(); 46 if ($is_archive) { 47 $title = pht('Archive Space: %s', $space->getNamespaceName()); 48 $body[] = pht( 49 'If you archive this Space, you will no longer be able to create '. 50 'new objects inside it.'); 51 $body[] = pht( 52 'Existing objects in this Space will be hidden from query results '. 53 'by default.'); 54 $button = pht('Archive Space'); 55 } else { 56 $title = pht('Activate Space: %s', $space->getNamespaceName()); 57 $body[] = pht( 58 'If you activate this space, you will be able to create objects '. 59 'inside it again.'); 60 $body[] = pht( 61 'Existing objects will no longer be hidden from query results.'); 62 $button = pht('Activate Space'); 63 } 64 65 66 $dialog = $this->newDialog() 67 ->setTitle($title) 68 ->addCancelButton($cancel_uri) 69 ->addSubmitButton($button); 70 71 foreach ($body as $paragraph) { 72 $dialog->appendParagraph($paragraph); 73 } 74 75 return $dialog; 76 } 77}