Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / dashboard / controller / panel / PhabricatorDashboardPanelArchiveController.php
blob05171e086d3ea11ed34f6975ace8ba7c2f731a5c
1 <?php
3 final class PhabricatorDashboardPanelArchiveController
4 extends PhabricatorDashboardController {
6 public function handleRequest(AphrontRequest $request) {
7 $viewer = $request->getViewer();
8 $id = $request->getURIData('id');
10 $panel = id(new PhabricatorDashboardPanelQuery())
11 ->setViewer($viewer)
12 ->withIDs(array($id))
13 ->requireCapabilities(
14 array(
15 PhabricatorPolicyCapability::CAN_VIEW,
16 PhabricatorPolicyCapability::CAN_EDIT,
18 ->executeOne();
19 if (!$panel) {
20 return new Aphront404Response();
23 $next_uri = '/'.$panel->getMonogram();
25 if ($request->isFormPost()) {
26 $xactions = array();
27 $xactions[] = id(new PhabricatorDashboardPanelTransaction())
28 ->setTransactionType(
29 PhabricatorDashboardPanelStatusTransaction::TRANSACTIONTYPE)
30 ->setNewValue((int)!$panel->getIsArchived());
32 id(new PhabricatorDashboardPanelTransactionEditor())
33 ->setActor($viewer)
34 ->setContentSourceFromRequest($request)
35 ->applyTransactions($panel, $xactions);
37 return id(new AphrontRedirectResponse())->setURI($next_uri);
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');
54 return $this->newDialog()
55 ->setTitle($title)
56 ->appendParagraph($body)
57 ->addSubmitButton($submit_text)
58 ->addCancelButton($next_uri);