Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / transactions / controller / PhabricatorApplicationTransactionValueController.php
blobef5e168898ee1a0ce5e3cdbacbfe48f9d2155da8
1 <?php
3 final class PhabricatorApplicationTransactionValueController
4 extends PhabricatorApplicationTransactionController {
6 public function shouldAllowPublic() {
7 return true;
10 public function handleRequest(AphrontRequest $request) {
11 $viewer = $this->getViewer();
12 $phid = $request->getURIData('phid');
13 $type = $request->getURIData('value');
15 $xaction = id(new PhabricatorObjectQuery())
16 ->setViewer($viewer)
17 ->withPHIDs(array($phid))
18 ->executeOne();
19 if (!$xaction) {
20 return new Aphront404Response();
23 // For now, this pathway only supports policy transactions
24 // to show the details of custom policies. If / when this pathway
25 // supports more transaction types, rendering coding should be moved
26 // into PhabricatorTransactions e.g. feed rendering code.
28 // TODO: This should be some kind of "hey do you support this?" thing on
29 // the transactions themselves.
31 switch ($xaction->getTransactionType()) {
32 case PhabricatorTransactions::TYPE_VIEW_POLICY:
33 case PhabricatorTransactions::TYPE_EDIT_POLICY:
34 case PhabricatorTransactions::TYPE_JOIN_POLICY:
35 case PhabricatorRepositoryPushPolicyTransaction::TRANSACTIONTYPE:
36 case PhabricatorApplicationPolicyChangeTransaction::TRANSACTIONTYPE:
37 break;
38 default:
39 return new Aphront404Response();
40 break;
43 if ($type == 'old') {
44 $value = $xaction->getOldValue();
45 } else {
46 $value = $xaction->getNewValue();
49 $policy = id(new PhabricatorPolicyQuery())
50 ->setViewer($viewer)
51 ->withPHIDs(array($value))
52 ->executeOne();
53 if (!$policy) {
54 return new Aphront404Response();
57 if ($policy->getType() != PhabricatorPolicyType::TYPE_CUSTOM) {
58 return new Aphront404Response();
61 $rules_view = id(new PhabricatorPolicyRulesView())
62 ->setViewer($viewer)
63 ->setPolicy($policy);
65 $cancel_uri = $this->guessCancelURI($viewer, $xaction);
67 return $this->newDialog()
68 ->setTitle($policy->getFullName())
69 ->setWidth(AphrontDialogView::WIDTH_FORM)
70 ->appendChild($rules_view)
71 ->addCancelButton($cancel_uri, pht('Close'));