Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/dashboard/controller/panel/PhabricatorDashboardPanelArchiveController.php
12242 views
1
<?php
2
3
final class PhabricatorDashboardPanelArchiveController
4
extends PhabricatorDashboardController {
5
6
public function handleRequest(AphrontRequest $request) {
7
$viewer = $request->getViewer();
8
$id = $request->getURIData('id');
9
10
$panel = id(new PhabricatorDashboardPanelQuery())
11
->setViewer($viewer)
12
->withIDs(array($id))
13
->requireCapabilities(
14
array(
15
PhabricatorPolicyCapability::CAN_VIEW,
16
PhabricatorPolicyCapability::CAN_EDIT,
17
))
18
->executeOne();
19
if (!$panel) {
20
return new Aphront404Response();
21
}
22
23
$next_uri = '/'.$panel->getMonogram();
24
25
if ($request->isFormPost()) {
26
$xactions = array();
27
$xactions[] = id(new PhabricatorDashboardPanelTransaction())
28
->setTransactionType(
29
PhabricatorDashboardPanelStatusTransaction::TRANSACTIONTYPE)
30
->setNewValue((int)!$panel->getIsArchived());
31
32
id(new PhabricatorDashboardPanelTransactionEditor())
33
->setActor($viewer)
34
->setContentSourceFromRequest($request)
35
->applyTransactions($panel, $xactions);
36
37
return id(new AphrontRedirectResponse())->setURI($next_uri);
38
}
39
40
if ($panel->getIsArchived()) {
41
$title = pht('Activate Panel?');
42
$body = pht(
43
'This panel will be reactivated and appear in other interfaces as '.
44
'an active panel.');
45
$submit_text = pht('Activate Panel');
46
} else {
47
$title = pht('Archive Panel?');
48
$body = pht(
49
'This panel will be archived and no longer appear in lists of active '.
50
'panels.');
51
$submit_text = pht('Archive Panel');
52
}
53
54
return $this->newDialog()
55
->setTitle($title)
56
->appendParagraph($body)
57
->addSubmitButton($submit_text)
58
->addCancelButton($next_uri);
59
}
60
61
}
62
63