forked from phacility/phabricator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPhabricatorDashboardPanelArchiveController.php
66 lines (54 loc) · 1.82 KB
/
PhabricatorDashboardPanelArchiveController.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
<?php
final class PhabricatorDashboardPanelArchiveController
extends PhabricatorDashboardController {
private $id;
public function willProcessRequest(array $data) {
$this->id = $data['id'];
}
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
$panel = id(new PhabricatorDashboardPanelQuery())
->setViewer($viewer)
->withIDs(array($this->id))
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_VIEW,
PhabricatorPolicyCapability::CAN_EDIT,
))
->executeOne();
if (!$panel) {
return new Aphront404Response();
}
$next_uri = '/'.$panel->getMonogram();
if ($request->isFormPost()) {
$xactions = array();
$xactions[] = id(new PhabricatorDashboardPanelTransaction())
->setTransactionType(PhabricatorDashboardPanelTransaction::TYPE_ARCHIVE)
->setNewValue((int)!$panel->getIsArchived());
id(new PhabricatorDashboardPanelTransactionEditor())
->setActor($viewer)
->setContentSourceFromRequest($request)
->applyTransactions($panel, $xactions);
return id(new AphrontRedirectResponse())->setURI($next_uri);
}
if ($panel->getIsArchived()) {
$title = pht('Activate Panel?');
$body = pht(
'This panel will be reactivated and appear in other interfaces as '.
'an active panel.');
$submit_text = pht('Activate Panel');
} else {
$title = pht('Archive Panel?');
$body = pht(
'This panel will be archived and no longer appear in lists of active '.
'panels.');
$submit_text = pht('Archive Panel');
}
return $this->newDialog()
->setTitle($title)
->appendParagraph($body)
->addSubmitButton($submit_text)
->addCancelButton($next_uri);
}
}