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