Path: blob/master/src/applications/diffusion/controller/DiffusionRepositoryEditDangerousController.php
12242 views
<?php12final class DiffusionRepositoryEditDangerousController3extends DiffusionRepositoryManageController {45public function handleRequest(AphrontRequest $request) {6$response = $this->loadDiffusionContextForEdit();7if ($response) {8return $response;9}1011$viewer = $this->getViewer();12$drequest = $this->getDiffusionRequest();13$repository = $drequest->getRepository();1415$panel_uri = id(new DiffusionRepositoryBasicsManagementPanel())16->setRepository($repository)17->getPanelURI();1819if (!$repository->canAllowDangerousChanges()) {20return $this->newDialog()21->setTitle(pht('Unprotectable Repository'))22->appendParagraph(23pht(24'This repository can not be protected from dangerous changes '.25'because this server does not control what users are allowed '.26'to push to it.'))27->addCancelButton($panel_uri);28}2930if ($request->isFormPost()) {31$xaction = id(new PhabricatorRepositoryTransaction())32->setTransactionType(33PhabricatorRepositoryDangerousTransaction::TRANSACTIONTYPE)34->setNewValue(!$repository->shouldAllowDangerousChanges());3536$editor = id(new PhabricatorRepositoryEditor())37->setContinueOnNoEffect(true)38->setContentSourceFromRequest($request)39->setActor($viewer)40->applyTransactions($repository, array($xaction));4142return id(new AphrontReloadResponse())->setURI($panel_uri);43}4445$force = phutil_tag('tt', array(), '--force');4647if ($repository->shouldAllowDangerousChanges()) {48$title = pht('Prevent Dangerous Changes');4950if ($repository->isSVN()) {51$body = pht(52'It will no longer be possible to edit revprops in this '.53'repository.');54} else {55$body = pht(56'It will no longer be possible to delete branches from this '.57'repository, or %s push to this repository.',58$force);59}6061$submit = pht('Prevent Dangerous Changes');62} else {63$title = pht('Allow Dangerous Changes');64if ($repository->isSVN()) {65$body = pht(66'If you allow dangerous changes, it will be possible to edit '.67'reprops in this repository, including arbitrarily rewriting '.68'commit messages. These operations can alter a repository in a '.69'way that is difficult to recover from.');70} else {71$body = pht(72'If you allow dangerous changes, it will be possible to delete '.73'branches and %s push this repository. These operations can '.74'alter a repository in a way that is difficult to recover from.',75$force);76}77$submit = pht('Allow Dangerous Changes');78}7980return $this->newDialog()81->setTitle($title)82->appendParagraph($body)83->addSubmitButton($submit)84->addCancelButton($panel_uri);85}8687}888990