1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-11 08:06:13 +01:00
phorge-phorge/src/applications/transactions/controller/PhabricatorEditEngineConfigurationDisableController.php
epriestley 37893ba2e6 Allow EditEngine configurations to be disabled and marked as "Default"
Summary:
Ref T9132.

Let configurations be enabled/disabled. This doesn't do much right now.

Let configurations be marked as default entries in the application "Create" menu. This makes them show up in the application in a dropdown, so you can replace the default form and/or provide several forms.

In Maniphest, we'll do this to provide a menu something like this:

  - New Bug Report
  - New Feature Request
  - ADVANCED TASK CREATION!!11~ (only available for Community members)

Test Plan: {F1005679}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9132

Differential Revision: https://secure.phabricator.com/D14584
2015-11-29 08:27:26 -08:00

59 lines
1.7 KiB
PHP

<?php
final class PhabricatorEditEngineConfigurationDisableController
extends PhabricatorEditEngineController {
public function handleRequest(AphrontRequest $request) {
$viewer = $this->getViewer();
$config = $this->loadConfigForEdit();
if (!$config) {
return id(new Aphront404Response());
}
$engine_key = $config->getEngineKey();
$key = $config->getIdentifier();
$cancel_uri = "/transactions/editengine/{$engine_key}/view/{$key}/";
$type = PhabricatorEditEngineConfigurationTransaction::TYPE_DISABLE;
if ($request->isFormPost()) {
$xactions = array();
$xactions[] = id(new PhabricatorEditEngineConfigurationTransaction())
->setTransactionType($type)
->setNewValue(!$config->getIsDisabled());
$editor = id(new PhabricatorEditEngineConfigurationEditor())
->setActor($viewer)
->setContentSourceFromRequest($request)
->setContinueOnMissingFields(true)
->setContinueOnNoEffect(true);
$editor->applyTransactions($config, $xactions);
return id(new AphrontRedirectResponse())
->setURI($cancel_uri);
}
if ($config->getIsDisabled()) {
$title = pht('Enable Form');
$body = pht(
'Enable this form? Users who can see it will be able to use it to '.
'create objects.');
$button = pht('Enable Form');
} else {
$title = pht('Disable Form');
$body = pht(
'Disable this form? Users will no longer be able to use it.');
$button = pht('Disable Form');
}
return $this->newDialog()
->setTitle($title)
->appendParagraph($body)
->addSubmitButton($button)
->addCancelbutton($cancel_uri);
}
}