Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / spaces / controller / PhabricatorSpacesArchiveController.php
blobb0ab8cd45be00a336517716ae75ad2c12f7ba766
1 <?php
3 final class PhabricatorSpacesArchiveController
4 extends PhabricatorSpacesController {
6 public function handleRequest(AphrontRequest $request) {
7 $viewer = $request->getUser();
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,
17 ->executeOne();
18 if (!$space) {
19 return new Aphront404Response();
22 $is_archive = ($request->getURIData('action') == 'archive');
23 $cancel_uri = '/'.$space->getMonogram();
25 if ($request->isFormPost()) {
26 $type_archive =
27 PhabricatorSpacesNamespaceArchiveTransaction::TRANSACTIONTYPE;
29 $xactions = array();
30 $xactions[] = id(new PhabricatorSpacesNamespaceTransaction())
31 ->setTransactionType($type_archive)
32 ->setNewValue($is_archive ? 1 : 0);
34 $editor = id(new PhabricatorSpacesNamespaceEditor())
35 ->setActor($viewer)
36 ->setContinueOnNoEffect(true)
37 ->setContinueOnMissingFields(true)
38 ->setContentSourceFromRequest($request);
40 $editor->applyTransactions($space, $xactions);
42 return id(new AphrontRedirectResponse())->setURI($cancel_uri);
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');
66 $dialog = $this->newDialog()
67 ->setTitle($title)
68 ->addCancelButton($cancel_uri)
69 ->addSubmitButton($button);
71 foreach ($body as $paragraph) {
72 $dialog->appendParagraph($paragraph);
75 return $dialog;