mirror of
https://we.phorge.it/source/phorge.git
synced 2025-03-08 10:24:48 +01:00
Modernize Transaction value controller, fixing logged-out policy issue
Summary: Fixes T9869. This specific transaction endpoint was missing `shouldAllowPublic()`. Also modernize things a little. Test Plan: Viewed a policy change by clicking the policy name from the transaction record on a public object while logged out. Reviewers: chad Reviewed By: chad Maniphest Tasks: T9869 Differential Revision: https://secure.phabricator.com/D14606
This commit is contained in:
parent
b9fcaadce8
commit
b35f578ae9
1 changed files with 13 additions and 15 deletions
|
@ -3,21 +3,20 @@
|
||||||
final class PhabricatorApplicationTransactionValueController
|
final class PhabricatorApplicationTransactionValueController
|
||||||
extends PhabricatorApplicationTransactionController {
|
extends PhabricatorApplicationTransactionController {
|
||||||
|
|
||||||
private $value;
|
public function shouldAllowPublic() {
|
||||||
private $phid;
|
return true;
|
||||||
|
|
||||||
public function willProcessRequest(array $data) {
|
|
||||||
$this->phid = $data['phid'];
|
|
||||||
$this->value = $data['value'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function processRequest() {
|
public function handleRequest(AphrontRequest $request) {
|
||||||
$request = $this->getRequest();
|
$request = $this->getRequest();
|
||||||
$viewer = $request->getUser();
|
$viewer = $request->getUser();
|
||||||
|
|
||||||
|
$phid = $request->getURIData('phid');
|
||||||
|
$type = $request->getURIData('value');
|
||||||
|
|
||||||
$xaction = id(new PhabricatorObjectQuery())
|
$xaction = id(new PhabricatorObjectQuery())
|
||||||
->setViewer($viewer)
|
->setViewer($viewer)
|
||||||
->withPHIDs(array($this->phid))
|
->withPHIDs(array($phid))
|
||||||
->executeOne();
|
->executeOne();
|
||||||
if (!$xaction) {
|
if (!$xaction) {
|
||||||
return new Aphront404Response();
|
return new Aphront404Response();
|
||||||
|
@ -42,11 +41,12 @@ final class PhabricatorApplicationTransactionValueController
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->value == 'old') {
|
if ($type == 'old') {
|
||||||
$value = $xaction->getOldValue();
|
$value = $xaction->getOldValue();
|
||||||
} else {
|
} else {
|
||||||
$value = $xaction->getNewValue();
|
$value = $xaction->getNewValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
$policy = id(new PhabricatorPolicyQuery())
|
$policy = id(new PhabricatorPolicyQuery())
|
||||||
->setViewer($viewer)
|
->setViewer($viewer)
|
||||||
->withPHIDs(array($value))
|
->withPHIDs(array($value))
|
||||||
|
@ -54,6 +54,7 @@ final class PhabricatorApplicationTransactionValueController
|
||||||
if (!$policy) {
|
if (!$policy) {
|
||||||
return new Aphront404Response();
|
return new Aphront404Response();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($policy->getType() != PhabricatorPolicyType::TYPE_CUSTOM) {
|
if ($policy->getType() != PhabricatorPolicyType::TYPE_CUSTOM) {
|
||||||
return new Aphront404Response();
|
return new Aphront404Response();
|
||||||
}
|
}
|
||||||
|
@ -66,15 +67,12 @@ final class PhabricatorApplicationTransactionValueController
|
||||||
|
|
||||||
$this->requireResource('policy-transaction-detail-css');
|
$this->requireResource('policy-transaction-detail-css');
|
||||||
$cancel_uri = $this->guessCancelURI($viewer, $xaction);
|
$cancel_uri = $this->guessCancelURI($viewer, $xaction);
|
||||||
$dialog = id(new AphrontDialogView())
|
|
||||||
->setUser($viewer)
|
return $this->newDialog()
|
||||||
->setTitle($policy->getFullName())
|
->setTitle($policy->getFullName())
|
||||||
->setWidth(AphrontDialogView::WIDTH_FORM)
|
->setWidth(AphrontDialogView::WIDTH_FORM)
|
||||||
->appendChild(
|
->appendChild($this->renderPolicyDetails($policy, $rule_objects))
|
||||||
$this->renderPolicyDetails($policy, $rule_objects))
|
|
||||||
->addCancelButton($cancel_uri, pht('Close'));
|
->addCancelButton($cancel_uri, pht('Close'));
|
||||||
|
|
||||||
return id(new AphrontDialogResponse())->setDialog($dialog);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function extractPHIDs(
|
private function extractPHIDs(
|
||||||
|
|
Loading…
Add table
Reference in a new issue