Page MenuHomePhabricator

D14945.id36121.diff
No OneTemporary

D14945.id36121.diff

diff --git a/src/applications/diffusion/controller/DiffusionController.php b/src/applications/diffusion/controller/DiffusionController.php
--- a/src/applications/diffusion/controller/DiffusionController.php
+++ b/src/applications/diffusion/controller/DiffusionController.php
@@ -52,7 +52,18 @@
return $this->processDiffusionRequest($request);
}
+ protected function loadDiffusionContextForEdit() {
+ return $this->loadContext(
+ array(
+ 'edit' => true,
+ ));
+ }
+
protected function loadDiffusionContext() {
+ return $this->loadContext(array());
+ }
+
+ private function loadContext(array $options) {
$request = $this->getRequest();
$viewer = $this->getViewer();
@@ -61,7 +72,7 @@
$identifier = (int)$request->getURIData('repositoryID');
}
- $params = array(
+ $params = $options + array(
'repository' => $identifier,
'user' => $viewer,
'blob' => $request->getURIData('dblob'),
diff --git a/src/applications/diffusion/controller/DiffusionMirrorDeleteController.php b/src/applications/diffusion/controller/DiffusionMirrorDeleteController.php
--- a/src/applications/diffusion/controller/DiffusionMirrorDeleteController.php
+++ b/src/applications/diffusion/controller/DiffusionMirrorDeleteController.php
@@ -33,16 +33,12 @@
return id(new AphrontReloadResponse())->setURI($edit_uri);
}
- $dialog = id(new AphrontDialogView())
- ->setUser($viewer)
+ return $this->newDialog()
->setTitle(pht('Really delete mirror?'))
->appendChild(
pht('Phabricator will stop pushing updates to this mirror.'))
->addSubmitButton(pht('Delete Mirror'))
->addCancelButton($edit_uri);
-
- return id(new AphrontDialogResponse())
- ->setDialog($dialog);
}
diff --git a/src/applications/diffusion/controller/DiffusionMirrorEditController.php b/src/applications/diffusion/controller/DiffusionMirrorEditController.php
--- a/src/applications/diffusion/controller/DiffusionMirrorEditController.php
+++ b/src/applications/diffusion/controller/DiffusionMirrorEditController.php
@@ -117,17 +117,13 @@
->setError($e_credentials)
->setOptions($credentials));
- $dialog = id(new AphrontDialogView())
- ->setUser($viewer)
+ return $this->newDialog()
->setTitle($title)
->setWidth(AphrontDialogView::WIDTH_FORM)
->appendChild($form_errors)
->appendChild($form)
->addSubmitButton($submit)
->addCancelButton($edit_uri);
-
- return id(new AphrontDialogResponse())
- ->setDialog($dialog);
}
diff --git a/src/applications/diffusion/controller/DiffusionRepositoryCreateController.php b/src/applications/diffusion/controller/DiffusionRepositoryCreateController.php
--- a/src/applications/diffusion/controller/DiffusionRepositoryCreateController.php
+++ b/src/applications/diffusion/controller/DiffusionRepositoryCreateController.php
@@ -6,7 +6,7 @@
private $edit;
private $repository;
- protected function processDiffusionRequest(AphrontRequest $request) {
+ public function handleRequest(AphrontRequest $request) {
$viewer = $request->getUser();
$this->edit = $request->getURIData('edit');
@@ -19,6 +19,11 @@
switch ($this->edit) {
case 'remote':
case 'policy':
+ $response = $this->loadDiffusionContextForEdit();
+ if ($response) {
+ return $response;
+ }
+
$repository = $this->getDiffusionRequest()->getRepository();
// Make sure we have CAN_EDIT.
@@ -275,14 +280,10 @@
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb($title);
- return $this->buildApplicationPage(
- array(
- $crumbs,
- $form,
- ),
- array(
- 'title' => $title,
- ));
+ return $this->newPage()
+ ->setTitle($title)
+ ->setCrumbs($crumbs)
+ ->appendChild($form);
}
diff --git a/src/applications/diffusion/controller/DiffusionRepositoryDefaultController.php b/src/applications/diffusion/controller/DiffusionRepositoryDefaultController.php
--- a/src/applications/diffusion/controller/DiffusionRepositoryDefaultController.php
+++ b/src/applications/diffusion/controller/DiffusionRepositoryDefaultController.php
@@ -2,7 +2,12 @@
final class DiffusionRepositoryDefaultController extends DiffusionController {
- protected function processDiffusionRequest(AphrontRequest $request) {
+ public function handleRequest(AphrontRequest $request) {
+ $response = $this->loadDiffusionContext();
+ if ($response) {
+ return $response;
+ }
+
// NOTE: This controller is just here to make sure we call
// willBeginExecution() on any /diffusion/X/ URI, so we can intercept
// `git`, `hg` and `svn` HTTP protocol requests.
@@ -11,7 +16,10 @@
// clone URI with "/anything.git" at the end into their web browser.
// Send them to the canonical repository URI.
+ $drequest = $this->getDiffusionRequest();
+ $repository = $drequest->getRepository();
+
return id(new AphrontRedirectResponse())
- ->setURI($this->getDiffusionRequest()->getRepository()->getURI());
+ ->setURI($repository->getURI());
}
}
diff --git a/src/applications/diffusion/controller/DiffusionRepositoryEditActionsController.php b/src/applications/diffusion/controller/DiffusionRepositoryEditActionsController.php
--- a/src/applications/diffusion/controller/DiffusionRepositoryEditActionsController.php
+++ b/src/applications/diffusion/controller/DiffusionRepositoryEditActionsController.php
@@ -3,25 +3,16 @@
final class DiffusionRepositoryEditActionsController
extends DiffusionRepositoryEditController {
- protected function processDiffusionRequest(AphrontRequest $request) {
- $viewer = $request->getUser();
- $drequest = $this->diffusionRequest;
- $repository = $drequest->getRepository();
-
- $repository = id(new PhabricatorRepositoryQuery())
- ->setViewer($viewer)
- ->requireCapabilities(
- array(
- PhabricatorPolicyCapability::CAN_VIEW,
- PhabricatorPolicyCapability::CAN_EDIT,
- ))
- ->withIDs(array($repository->getID()))
- ->executeOne();
-
- if (!$repository) {
- return new Aphront404Response();
+ public function handleRequest(AphrontRequest $request) {
+ $response = $this->loadDiffusionContextForEdit();
+ if ($response) {
+ return $response;
}
+ $viewer = $this->getViewer();
+ $drequest = $this->getDiffusionRequest();
+ $repository = $drequest->getRepository();
+
$edit_uri = $this->getRepositoryControllerURI($repository, 'edit/');
// NOTE: We're inverting these here, because the storage is silly.
@@ -109,14 +100,10 @@
->setHeaderText($title)
->setForm($form);
- return $this->buildApplicationPage(
- array(
- $crumbs,
- $form_box,
- ),
- array(
- 'title' => $title,
- ));
+ return $this->newPage()
+ ->setTitle($title)
+ ->setCrumbs($crumbs)
+ ->appendChild($form_box);
}
}
diff --git a/src/applications/diffusion/controller/DiffusionRepositoryEditActivateController.php b/src/applications/diffusion/controller/DiffusionRepositoryEditActivateController.php
--- a/src/applications/diffusion/controller/DiffusionRepositoryEditActivateController.php
+++ b/src/applications/diffusion/controller/DiffusionRepositoryEditActivateController.php
@@ -3,25 +3,16 @@
final class DiffusionRepositoryEditActivateController
extends DiffusionRepositoryEditController {
- protected function processDiffusionRequest(AphrontRequest $request) {
- $viewer = $request->getUser();
- $drequest = $this->diffusionRequest;
- $repository = $drequest->getRepository();
-
- $repository = id(new PhabricatorRepositoryQuery())
- ->setViewer($viewer)
- ->requireCapabilities(
- array(
- PhabricatorPolicyCapability::CAN_VIEW,
- PhabricatorPolicyCapability::CAN_EDIT,
- ))
- ->withIDs(array($repository->getID()))
- ->executeOne();
-
- if (!$repository) {
- return new Aphront404Response();
+ public function handleRequest(AphrontRequest $request) {
+ $response = $this->loadDiffusionContextForEdit();
+ if ($response) {
+ return $response;
}
+ $viewer = $this->getViewer();
+ $drequest = $this->getDiffusionRequest();
+ $repository = $drequest->getRepository();
+
$edit_uri = $this->getRepositoryControllerURI($repository, 'edit/');
if ($request->isFormPost()) {
@@ -38,28 +29,21 @@
return id(new AphrontReloadResponse())->setURI($edit_uri);
}
- $dialog = id(new AphrontDialogView())
- ->setUser($viewer);
-
if ($repository->isTracked()) {
- $dialog
+ return $this->newDialog()
->setTitle(pht('Deactivate Repository?'))
->appendChild(
pht('Deactivate this repository?'))
->addSubmitButton(pht('Deactivate Repository'))
->addCancelButton($edit_uri);
} else {
- $dialog
+ return $this->newDialog()
->setTitle(pht('Activate Repository?'))
->appendChild(
pht('Activate this repository?'))
->addSubmitButton(pht('Activate Repository'))
->addCancelButton($edit_uri);
}
-
- return id(new AphrontDialogResponse())
- ->setDialog($dialog);
}
-
}
diff --git a/src/applications/diffusion/controller/DiffusionRepositoryEditAutomationController.php b/src/applications/diffusion/controller/DiffusionRepositoryEditAutomationController.php
--- a/src/applications/diffusion/controller/DiffusionRepositoryEditAutomationController.php
+++ b/src/applications/diffusion/controller/DiffusionRepositoryEditAutomationController.php
@@ -3,24 +3,16 @@
final class DiffusionRepositoryEditAutomationController
extends DiffusionRepositoryEditController {
- protected function processDiffusionRequest(AphrontRequest $request) {
+ public function handleRequest(AphrontRequest $request) {
+ $response = $this->loadDiffusionContextForEdit();
+ if ($response) {
+ return $response;
+ }
+
$viewer = $this->getViewer();
- $drequest = $this->diffusionRequest;
+ $drequest = $this->getDiffusionRequest();
$repository = $drequest->getRepository();
- $repository = id(new PhabricatorRepositoryQuery())
- ->setViewer($viewer)
- ->requireCapabilities(
- array(
- PhabricatorPolicyCapability::CAN_VIEW,
- PhabricatorPolicyCapability::CAN_EDIT,
- ))
- ->withIDs(array($repository->getID()))
- ->executeOne();
- if (!$repository) {
- return new Aphront404Response();
- }
-
if (!$repository->supportsAutomation()) {
return new Aphront404Response();
}
@@ -81,14 +73,10 @@
->setHeaderText($title)
->setForm($form);
- return $this->buildApplicationPage(
- array(
- $crumbs,
- $object_box,
- ),
- array(
- 'title' => $title,
- ));
+ return $this->newPage()
+ ->setTitle($title)
+ ->setCrumbs($crumbs)
+ ->appendChild($object_box);
}
}
diff --git a/src/applications/diffusion/controller/DiffusionRepositoryEditBasicController.php b/src/applications/diffusion/controller/DiffusionRepositoryEditBasicController.php
--- a/src/applications/diffusion/controller/DiffusionRepositoryEditBasicController.php
+++ b/src/applications/diffusion/controller/DiffusionRepositoryEditBasicController.php
@@ -3,31 +3,24 @@
final class DiffusionRepositoryEditBasicController
extends DiffusionRepositoryEditController {
- protected function processDiffusionRequest(AphrontRequest $request) {
- $user = $request->getUser();
- $drequest = $this->diffusionRequest;
- $repository = $drequest->getRepository();
-
- $repository = id(new PhabricatorRepositoryQuery())
- ->setViewer($user)
- ->requireCapabilities(
- array(
- PhabricatorPolicyCapability::CAN_VIEW,
- PhabricatorPolicyCapability::CAN_EDIT,
- ))
- ->needProjectPHIDs(true)
- ->withIDs(array($repository->getID()))
- ->executeOne();
-
- if (!$repository) {
- return new Aphront404Response();
+ public function handleRequest(AphrontRequest $request) {
+ $response = $this->loadDiffusionContextForEdit();
+ if ($response) {
+ return $response;
}
+ $viewer = $request->getUser();
+ $drequest = $this->getDiffusionRequest();
+ $repository = $drequest->getRepository();
+
$edit_uri = $this->getRepositoryControllerURI($repository, 'edit/');
$v_name = $repository->getName();
$v_desc = $repository->getDetail('description');
$v_clone_name = $repository->getDetail('clone-name');
+ $v_projects = PhabricatorEdgeQuery::loadDestinationPHIDs(
+ $repository->getPHID(),
+ PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
$e_name = true;
$errors = array();
@@ -81,7 +74,7 @@
id(new PhabricatorRepositoryEditor())
->setContinueOnNoEffect(true)
->setContentSourceFromRequest($request)
- ->setActor($user)
+ ->setActor($viewer)
->applyTransactions($repository, $xactions);
return id(new AphrontRedirectResponse())->setURI($edit_uri);
@@ -94,7 +87,7 @@
$title = pht('Edit %s', $repository->getName());
$form = id(new AphrontFormView())
- ->setUser($user)
+ ->setUser($viewer)
->appendChild(
id(new AphrontFormTextControl())
->setName('name')
@@ -118,7 +111,7 @@
$form
->appendChild(
id(new PhabricatorRemarkupControl())
- ->setUser($user)
+ ->setUser($viewer)
->setName('description')
->setLabel(pht('Description'))
->setValue($v_desc))
@@ -127,7 +120,7 @@
->setDatasource(new PhabricatorProjectDatasource())
->setName('projectPHIDs')
->setLabel(pht('Projects'))
- ->setValue($repository->getProjectPHIDs()))
+ ->setValue($v_projects))
->appendChild(
id(new AphrontFormSubmitControl())
->setValue(pht('Save'))
@@ -140,14 +133,10 @@
->setForm($form)
->setFormErrors($errors);
- return $this->buildApplicationPage(
- array(
- $crumbs,
- $object_box,
- ),
- array(
- 'title' => $title,
- ));
+ return $this->newPage()
+ ->setTitle($title)
+ ->setCrumbs($crumbs)
+ ->appendChild($object_box);
}
private function getReadmeInstructions() {
diff --git a/src/applications/diffusion/controller/DiffusionRepositoryEditBranchesController.php b/src/applications/diffusion/controller/DiffusionRepositoryEditBranchesController.php
--- a/src/applications/diffusion/controller/DiffusionRepositoryEditBranchesController.php
+++ b/src/applications/diffusion/controller/DiffusionRepositoryEditBranchesController.php
@@ -3,25 +3,16 @@
final class DiffusionRepositoryEditBranchesController
extends DiffusionRepositoryEditController {
- protected function processDiffusionRequest(AphrontRequest $request) {
- $request = $this->getRequest();
- $viewer = $request->getUser();
- $drequest = $this->diffusionRequest;
- $repository = $drequest->getRepository();
-
- $repository = id(new PhabricatorRepositoryQuery())
- ->setViewer($viewer)
- ->requireCapabilities(
- array(
- PhabricatorPolicyCapability::CAN_VIEW,
- PhabricatorPolicyCapability::CAN_EDIT,
- ))
- ->withIDs(array($repository->getID()))
- ->executeOne();
- if (!$repository) {
- return new Aphront404Response();
+ public function handleRequest(AphrontRequest $request) {
+ $response = $this->loadDiffusionContextForEdit();
+ if ($response) {
+ return $response;
}
+ $viewer = $this->getViewer();
+ $drequest = $this->getDiffusionRequest();
+ $repository = $drequest->getRepository();
+
$is_git = false;
$is_hg = false;
@@ -226,14 +217,10 @@
->setHeaderText($title)
->setForm($form);
- return $this->buildApplicationPage(
- array(
- $crumbs,
- $form_box,
- ),
- array(
- 'title' => $title,
- ));
+ return $this->newPage()
+ ->setTitle($title)
+ ->setCrumbs($crumbs)
+ ->appendChild($form_box);
}
private function processBranches($string) {
diff --git a/src/applications/diffusion/controller/DiffusionRepositoryEditDangerousController.php b/src/applications/diffusion/controller/DiffusionRepositoryEditDangerousController.php
--- a/src/applications/diffusion/controller/DiffusionRepositoryEditDangerousController.php
+++ b/src/applications/diffusion/controller/DiffusionRepositoryEditDangerousController.php
@@ -3,25 +3,16 @@
final class DiffusionRepositoryEditDangerousController
extends DiffusionRepositoryEditController {
- protected function processDiffusionRequest(AphrontRequest $request) {
- $viewer = $request->getUser();
- $drequest = $this->diffusionRequest;
- $repository = $drequest->getRepository();
-
- $repository = id(new PhabricatorRepositoryQuery())
- ->setViewer($viewer)
- ->requireCapabilities(
- array(
- PhabricatorPolicyCapability::CAN_VIEW,
- PhabricatorPolicyCapability::CAN_EDIT,
- ))
- ->withIDs(array($repository->getID()))
- ->executeOne();
-
- if (!$repository) {
- return new Aphront404Response();
+ public function handleRequest(AphrontRequest $request) {
+ $response = $this->loadDiffusionContextForEdit();
+ if ($response) {
+ return $response;
}
+ $viewer = $this->getViewer();
+ $drequest = $this->getDiffusionRequest();
+ $repository = $drequest->getRepository();
+
if (!$repository->canAllowDangerousChanges()) {
return new Aphront400Response();
}
@@ -42,13 +33,10 @@
return id(new AphrontReloadResponse())->setURI($edit_uri);
}
- $dialog = id(new AphrontDialogView())
- ->setUser($viewer);
-
$force = phutil_tag('tt', array(), '--force');
if ($repository->shouldAllowDangerousChanges()) {
- $dialog
+ return $this->newDialog()
->setTitle(pht('Prevent Dangerous changes?'))
->appendChild(
pht(
@@ -58,7 +46,7 @@
->addSubmitButton(pht('Prevent Dangerous Changes'))
->addCancelButton($edit_uri);
} else {
- $dialog
+ return $this->newDialog()
->setTitle(pht('Allow Dangerous Changes?'))
->appendChild(
pht(
@@ -69,9 +57,6 @@
->addSubmitButton(pht('Allow Dangerous Changes'))
->addCancelButton($edit_uri);
}
-
- return id(new AphrontDialogResponse())
- ->setDialog($dialog);
}
}
diff --git a/src/applications/diffusion/controller/DiffusionRepositoryEditDeleteController.php b/src/applications/diffusion/controller/DiffusionRepositoryEditDeleteController.php
--- a/src/applications/diffusion/controller/DiffusionRepositoryEditDeleteController.php
+++ b/src/applications/diffusion/controller/DiffusionRepositoryEditDeleteController.php
@@ -3,24 +3,16 @@
final class DiffusionRepositoryEditDeleteController
extends DiffusionRepositoryEditController {
- protected function processDiffusionRequest(AphrontRequest $request) {
- $viewer = $request->getUser();
- $drequest = $this->diffusionRequest;
- $repository = $drequest->getRepository();
-
- $repository = id(new PhabricatorRepositoryQuery())
- ->setViewer($viewer)
- ->requireCapabilities(
- array(
- PhabricatorPolicyCapability::CAN_VIEW,
- PhabricatorPolicyCapability::CAN_EDIT,
- ))
- ->withIDs(array($repository->getID()))
- ->executeOne();
- if (!$repository) {
- return new Aphront404Response();
+ public function handleRequest(AphrontRequest $request) {
+ $response = $this->loadDiffusionContextForEdit();
+ if ($response) {
+ return $response;
}
+ $viewer = $this->getViewer();
+ $drequest = $this->getDiffusionRequest();
+ $repository = $drequest->getRepository();
+
$edit_uri = $this->getRepositoryControllerURI($repository, 'edit/');
$dialog = new AphrontDialogView();
@@ -45,14 +37,10 @@
phutil_tag('p', array(), $text_2),
));
- $dialog = id(new AphrontDialogView())
- ->setUser($request->getUser())
+ return $this->newDialog()
->setTitle(pht('Really want to delete the repository?'))
->appendChild($body)
->addCancelButton($edit_uri, pht('Okay'));
-
- return id(new AphrontDialogResponse())->setDialog($dialog);
}
-
}
diff --git a/src/applications/diffusion/controller/DiffusionRepositoryEditEncodingController.php b/src/applications/diffusion/controller/DiffusionRepositoryEditEncodingController.php
--- a/src/applications/diffusion/controller/DiffusionRepositoryEditEncodingController.php
+++ b/src/applications/diffusion/controller/DiffusionRepositoryEditEncodingController.php
@@ -3,25 +3,16 @@
final class DiffusionRepositoryEditEncodingController
extends DiffusionRepositoryEditController {
- protected function processDiffusionRequest(AphrontRequest $request) {
- $user = $request->getUser();
- $drequest = $this->diffusionRequest;
- $repository = $drequest->getRepository();
-
- $repository = id(new PhabricatorRepositoryQuery())
- ->setViewer($user)
- ->requireCapabilities(
- array(
- PhabricatorPolicyCapability::CAN_VIEW,
- PhabricatorPolicyCapability::CAN_EDIT,
- ))
- ->withIDs(array($repository->getID()))
- ->executeOne();
-
- if (!$repository) {
- return new Aphront404Response();
+ public function handleRequest(AphrontRequest $request) {
+ $response = $this->loadDiffusionContextForEdit();
+ if ($response) {
+ return $response;
}
+ $user = $this->getViewer();
+ $drequest = $this->getDiffusionRequest();
+ $repository = $drequest->getRepository();
+
$edit_uri = $this->getRepositoryControllerURI($repository, 'edit/');
$v_encoding = $repository->getDetail('encoding');
@@ -79,14 +70,10 @@
->setForm($form)
->setFormErrors($errors);
- return $this->buildApplicationPage(
- array(
- $crumbs,
- $object_box,
- ),
- array(
- 'title' => $title,
- ));
+ return $this->newPage()
+ ->setTitle($title)
+ ->setCrumbs($crumbs)
+ ->appendChild($object_box);
}
private function getEncodingInstructions() {
diff --git a/src/applications/diffusion/controller/DiffusionRepositoryEditHostingController.php b/src/applications/diffusion/controller/DiffusionRepositoryEditHostingController.php
--- a/src/applications/diffusion/controller/DiffusionRepositoryEditHostingController.php
+++ b/src/applications/diffusion/controller/DiffusionRepositoryEditHostingController.php
@@ -5,24 +5,16 @@
private $serve;
- protected function processDiffusionRequest(AphrontRequest $request) {
- $user = $request->getUser();
- $drequest = $this->diffusionRequest;
+ public function handleRequest(AphrontRequest $request) {
+ $response = $this->loadDiffusionContextForEdit();
+ if ($response) {
+ return $response;
+ }
+
+ $drequest = $this->getDiffusionRequest();
$repository = $drequest->getRepository();
- $this->serve = $request->getURIData('serve');
- $repository = id(new PhabricatorRepositoryQuery())
- ->setViewer($user)
- ->requireCapabilities(
- array(
- PhabricatorPolicyCapability::CAN_VIEW,
- PhabricatorPolicyCapability::CAN_EDIT,
- ))
- ->withIDs(array($repository->getID()))
- ->executeOne();
- if (!$repository) {
- return new Aphront404Response();
- }
+ $this->serve = $request->getURIData('serve');
if (!$this->serve) {
return $this->handleHosting($repository);
@@ -107,14 +99,10 @@
->setHeaderText($title)
->setForm($form);
- return $this->buildApplicationPage(
- array(
- $crumbs,
- $object_box,
- ),
- array(
- 'title' => $title,
- ));
+ return $this->newPage()
+ ->setTitle($title)
+ ->setCrumbs($crumbs)
+ ->appendChild($object_box);
}
public function handleProtocols(PhabricatorRepository $repository) {
@@ -272,14 +260,10 @@
->setHeaderText($title)
->setForm($form);
- return $this->buildApplicationPage(
- array(
- $crumbs,
- $object_box,
- ),
- array(
- 'title' => $title,
- ));
+ return $this->newPage()
+ ->setTitle($title)
+ ->setCrumbs($crumbs)
+ ->appendChild($object_box);
}
}
diff --git a/src/applications/diffusion/controller/DiffusionRepositoryEditMainController.php b/src/applications/diffusion/controller/DiffusionRepositoryEditMainController.php
--- a/src/applications/diffusion/controller/DiffusionRepositoryEditMainController.php
+++ b/src/applications/diffusion/controller/DiffusionRepositoryEditMainController.php
@@ -3,15 +3,15 @@
final class DiffusionRepositoryEditMainController
extends DiffusionRepositoryEditController {
- protected function processDiffusionRequest(AphrontRequest $request) {
- $viewer = $request->getUser();
- $drequest = $this->diffusionRequest;
- $repository = $drequest->getRepository();
+ public function handleRequest(AphrontRequest $request) {
+ $response = $this->loadDiffusionContextForEdit();
+ if ($response) {
+ return $response;
+ }
- PhabricatorPolicyFilter::requireCapability(
- $viewer,
- $repository,
- PhabricatorPolicyCapability::CAN_EDIT);
+ $viewer = $this->getViewer();
+ $drequest = $this->getDiffusionRequest();
+ $repository = $drequest->getRepository();
$is_svn = false;
$is_git = false;
diff --git a/src/applications/diffusion/controller/DiffusionRepositoryEditStagingController.php b/src/applications/diffusion/controller/DiffusionRepositoryEditStagingController.php
--- a/src/applications/diffusion/controller/DiffusionRepositoryEditStagingController.php
+++ b/src/applications/diffusion/controller/DiffusionRepositoryEditStagingController.php
@@ -3,23 +3,16 @@
final class DiffusionRepositoryEditStagingController
extends DiffusionRepositoryEditController {
- protected function processDiffusionRequest(AphrontRequest $request) {
- $user = $request->getUser();
- $drequest = $this->diffusionRequest;
+ public function handleRequest(AphrontRequest $request) {
+ $response = $this->loadDiffusionContextForEdit();
+ if ($response) {
+ return $response;
+ }
+
+ $viewer = $this->getViewer();
+ $drequest = $this->getDiffusionRequest();
$repository = $drequest->getRepository();
- $repository = id(new PhabricatorRepositoryQuery())
- ->setViewer($user)
- ->requireCapabilities(
- array(
- PhabricatorPolicyCapability::CAN_VIEW,
- PhabricatorPolicyCapability::CAN_EDIT,
- ))
- ->withIDs(array($repository->getID()))
- ->executeOne();
- if (!$repository) {
- return new Aphront404Response();
- }
if (!$repository->supportsStaging()) {
return new Aphront404Response();
@@ -43,7 +36,7 @@
id(new PhabricatorRepositoryEditor())
->setContinueOnNoEffect(true)
->setContentSourceFromRequest($request)
- ->setActor($user)
+ ->setActor($viewer)
->applyTransactions($repository, $xactions);
return id(new AphrontRedirectResponse())->setURI($edit_uri);
@@ -55,7 +48,7 @@
$title = pht('Edit %s', $repository->getName());
$form = id(new AphrontFormView())
- ->setUser($user)
+ ->setUser($viewer)
->appendRemarkupInstructions(
pht(
"To make it easier to run integration tests and builds on code ".
@@ -79,14 +72,10 @@
->setHeaderText($title)
->setForm($form);
- return $this->buildApplicationPage(
- array(
- $crumbs,
- $object_box,
- ),
- array(
- 'title' => $title,
- ));
+ return $this->newPage()
+ ->setTitle($title)
+ ->setCrumbs($crumbs)
+ ->appendChild($object_box);
}
}
diff --git a/src/applications/diffusion/controller/DiffusionRepositoryEditStorageController.php b/src/applications/diffusion/controller/DiffusionRepositoryEditStorageController.php
--- a/src/applications/diffusion/controller/DiffusionRepositoryEditStorageController.php
+++ b/src/applications/diffusion/controller/DiffusionRepositoryEditStorageController.php
@@ -3,25 +3,16 @@
final class DiffusionRepositoryEditStorageController
extends DiffusionRepositoryEditController {
- protected function processDiffusionRequest(AphrontRequest $request) {
- $user = $request->getUser();
- $drequest = $this->diffusionRequest;
- $repository = $drequest->getRepository();
-
- $repository = id(new PhabricatorRepositoryQuery())
- ->setViewer($user)
- ->requireCapabilities(
- array(
- PhabricatorPolicyCapability::CAN_VIEW,
- PhabricatorPolicyCapability::CAN_EDIT,
- ))
- ->withIDs(array($repository->getID()))
- ->executeOne();
-
- if (!$repository) {
- return new Aphront404Response();
+ public function handleRequest(AphrontRequest $request) {
+ $response = $this->loadDiffusionContextForEdit();
+ if ($response) {
+ return $response;
}
+ $viewer = $this->getViewer();
+ $drequest = $this->getDiffusionRequest();
+ $repository = $drequest->getRepository();
+
$edit_uri = $this->getRepositoryControllerURI($repository, 'edit/');
$v_local = $repository->getHumanReadableDetail('local-path');
@@ -44,7 +35,7 @@
}
$form = id(new AphrontFormView())
- ->setUser($user)
+ ->setUser($viewer)
->appendChild(
id(new AphrontFormMarkupControl())
->setLabel(pht('Storage Service'))
@@ -61,7 +52,7 @@
sprintf(
'phabricator/ $ ./bin/repository edit %s --as %s --local-path ...',
$repository->getMonogram(),
- $user->getUsername())))
+ $viewer->getUsername())))
->appendChild(
id(new AphrontFormSubmitControl())
->addCancelButton($edit_uri, pht('Done')));
@@ -71,14 +62,10 @@
->setForm($form)
->setFormErrors($errors);
- return $this->buildApplicationPage(
- array(
- $crumbs,
- $object_box,
- ),
- array(
- 'title' => $title,
- ));
+ return $this->newPage()
+ ->setTitle($title)
+ ->setCrumbs($crumbs)
+ ->appendChild($object_box);
}
}
diff --git a/src/applications/diffusion/controller/DiffusionRepositoryEditSubversionController.php b/src/applications/diffusion/controller/DiffusionRepositoryEditSubversionController.php
--- a/src/applications/diffusion/controller/DiffusionRepositoryEditSubversionController.php
+++ b/src/applications/diffusion/controller/DiffusionRepositoryEditSubversionController.php
@@ -3,25 +3,16 @@
final class DiffusionRepositoryEditSubversionController
extends DiffusionRepositoryEditController {
- protected function processDiffusionRequest(AphrontRequest $request) {
- $viewer = $request->getUser();
- $drequest = $this->diffusionRequest;
- $repository = $drequest->getRepository();
-
- $repository = id(new PhabricatorRepositoryQuery())
- ->setViewer($viewer)
- ->requireCapabilities(
- array(
- PhabricatorPolicyCapability::CAN_VIEW,
- PhabricatorPolicyCapability::CAN_EDIT,
- ))
- ->withIDs(array($repository->getID()))
- ->executeOne();
-
- if (!$repository) {
- return new Aphront404Response();
+ public function handleRequest(AphrontRequest $request) {
+ $response = $this->loadDiffusionContextForEdit();
+ if ($response) {
+ return $response;
}
+ $viewer = $this->getViewer();
+ $drequest = $this->getDiffusionRequest();
+ $repository = $drequest->getRepository();
+
switch ($repository->getVersionControlSystem()) {
case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
@@ -108,14 +99,10 @@
->setHeaderText($title)
->setForm($form);
- return $this->buildApplicationPage(
- array(
- $crumbs,
- $form_box,
- ),
- array(
- 'title' => $title,
- ));
+ return $this->newPage()
+ ->setTitle($title)
+ ->setCrumbs($crumbs)
+ ->appendChild($form_box);
}
}
diff --git a/src/applications/diffusion/controller/DiffusionRepositoryEditUpdateController.php b/src/applications/diffusion/controller/DiffusionRepositoryEditUpdateController.php
--- a/src/applications/diffusion/controller/DiffusionRepositoryEditUpdateController.php
+++ b/src/applications/diffusion/controller/DiffusionRepositoryEditUpdateController.php
@@ -3,24 +3,16 @@
final class DiffusionRepositoryEditUpdateController
extends DiffusionRepositoryEditController {
- protected function processDiffusionRequest(AphrontRequest $request) {
- $viewer = $request->getUser();
- $drequest = $this->diffusionRequest;
- $repository = $drequest->getRepository();
-
- $repository = id(new PhabricatorRepositoryQuery())
- ->setViewer($viewer)
- ->requireCapabilities(
- array(
- PhabricatorPolicyCapability::CAN_VIEW,
- PhabricatorPolicyCapability::CAN_EDIT,
- ))
- ->withIDs(array($repository->getID()))
- ->executeOne();
- if (!$repository) {
- return new Aphront404Response();
+ public function handleRequest(AphrontRequest $request) {
+ $response = $this->loadDiffusionContextForEdit();
+ if ($response) {
+ return $response;
}
+ $viewer = $this->getViewer();
+ $drequest = $this->getDiffusionRequest();
+ $repository = $drequest->getRepository();
+
$edit_uri = $this->getRepositoryControllerURI($repository, 'edit/');
if ($request->isFormPost()) {
diff --git a/src/applications/diffusion/controller/DiffusionRepositorySymbolsController.php b/src/applications/diffusion/controller/DiffusionRepositorySymbolsController.php
--- a/src/applications/diffusion/controller/DiffusionRepositorySymbolsController.php
+++ b/src/applications/diffusion/controller/DiffusionRepositorySymbolsController.php
@@ -3,25 +3,16 @@
final class DiffusionRepositorySymbolsController
extends DiffusionRepositoryEditController {
- protected function processDiffusionRequest(AphrontRequest $request) {
- $user = $request->getUser();
- $drequest = $this->diffusionRequest;
- $repository = $drequest->getRepository();
-
- $repository = id(new PhabricatorRepositoryQuery())
- ->setViewer($user)
- ->requireCapabilities(
- array(
- PhabricatorPolicyCapability::CAN_VIEW,
- PhabricatorPolicyCapability::CAN_EDIT,
- ))
- ->withIDs(array($repository->getID()))
- ->executeOne();
-
- if (!$repository) {
- return new Aphront404Response();
+ public function handleRequest(AphrontRequest $request) {
+ $response = $this->loadDiffusionContextForEdit();
+ if ($response) {
+ return $response;
}
+ $viewer = $this->getViewer();
+ $drequest = $this->getDiffusionRequest();
+ $repository = $drequest->getRepository();
+
$edit_uri = $this->getRepositoryControllerURI($repository, 'edit/');
$v_sources = $repository->getSymbolSources();
@@ -55,7 +46,7 @@
id(new PhabricatorRepositoryEditor())
->setContinueOnNoEffect(true)
->setContentSourceFromRequest($request)
- ->setActor($user)
+ ->setActor($viewer)
->applyTransactions($repository, $xactions);
return id(new AphrontRedirectResponse())->setURI($edit_uri);
@@ -71,7 +62,7 @@
$title = pht('Edit %s', $repository->getName());
$form = id(new AphrontFormView())
- ->setUser($user)
+ ->setUser($viewer)
->appendRemarkupInstructions($this->getInstructions())
->appendChild(
id(new AphrontFormTextControl())
@@ -99,14 +90,10 @@
->setForm($form)
->setFormErrors($errors);
- return $this->buildApplicationPage(
- array(
- $crumbs,
- $object_box,
- ),
- array(
- 'title' => $title,
- ));
+ return $this->newPage()
+ ->setTitle($title)
+ ->setCrumbs($crumbs)
+ ->appendChild($object_box);
}
private function getInstructions() {
diff --git a/src/applications/diffusion/controller/DiffusionRepositoryTestAutomationController.php b/src/applications/diffusion/controller/DiffusionRepositoryTestAutomationController.php
--- a/src/applications/diffusion/controller/DiffusionRepositoryTestAutomationController.php
+++ b/src/applications/diffusion/controller/DiffusionRepositoryTestAutomationController.php
@@ -4,7 +4,7 @@
extends DiffusionRepositoryEditController {
public function handleRequest(AphrontRequest $request) {
- $response = $this->loadDiffusionContext();
+ $response = $this->loadDiffusionContextForEdit();
if ($response) {
return $response;
}
@@ -13,19 +13,6 @@
$drequest = $this->getDiffusionRequest();
$repository = $drequest->getRepository();
- $repository = id(new PhabricatorRepositoryQuery())
- ->setViewer($viewer)
- ->requireCapabilities(
- array(
- PhabricatorPolicyCapability::CAN_VIEW,
- PhabricatorPolicyCapability::CAN_EDIT,
- ))
- ->withIDs(array($repository->getID()))
- ->executeOne();
- if (!$repository) {
- return new Aphront404Response();
- }
-
$edit_uri = $this->getRepositoryControllerURI($repository, 'edit/');
if (!$repository->canPerformAutomation()) {
diff --git a/src/applications/diffusion/request/DiffusionRequest.php b/src/applications/diffusion/request/DiffusionRequest.php
--- a/src/applications/diffusion/request/DiffusionRequest.php
+++ b/src/applications/diffusion/request/DiffusionRequest.php
@@ -100,7 +100,10 @@
}
if ($identifier !== null) {
- $object = self::newFromIdentifier($identifier, $data[$viewer_key]);
+ $object = self::newFromIdentifier(
+ $identifier,
+ $data[$viewer_key],
+ idx($data, 'edit'));
} else {
$object = self::newFromRepository($repository);
}
@@ -171,12 +174,22 @@
*/
final private static function newFromIdentifier(
$identifier,
- PhabricatorUser $viewer) {
+ PhabricatorUser $viewer,
+ $need_edit = false) {
- $repository = id(new PhabricatorRepositoryQuery())
+ $query = id(new PhabricatorRepositoryQuery())
->setViewer($viewer)
- ->withIdentifiers(array($identifier))
- ->executeOne();
+ ->withIdentifiers(array($identifier));
+
+ if ($need_edit) {
+ $query->requireCapabilities(
+ array(
+ PhabricatorPolicyCapability::CAN_VIEW,
+ PhabricatorPolicyCapability::CAN_EDIT,
+ ));
+ }
+
+ $repository = $query->executeOne();
if (!$repository) {
return null;

File Metadata

Mime Type
text/plain
Expires
Wed, Apr 2, 5:37 AM (4 d, 2 h ago)
Storage Engine
amazon-s3
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
phabricator/secure/na/hq/myi5wgtzm7llmw2h
Default Alt Text
D14945.id36121.diff (38 KB)

Event Timeline