@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3final class PhabricatorEditEngineConfigurationIsEditController
4 extends PhabricatorEditEngineController {
5
6 public function handleRequest(AphrontRequest $request) {
7 $viewer = $this->getViewer();
8
9 $config = $this->loadConfigForEdit();
10 if (!$config) {
11 return id(new Aphront404Response());
12 }
13
14 $engine_key = $config->getEngineKey();
15 $key = $config->getIdentifier();
16 $cancel_uri = "/transactions/editengine/{$engine_key}/view/{$key}/";
17
18 $type = PhabricatorEditEngineIsEditTransaction::TRANSACTIONTYPE;
19 if ($request->isFormPost()) {
20 $xactions = array();
21
22 $xactions[] = id(new PhabricatorEditEngineConfigurationTransaction())
23 ->setTransactionType($type)
24 ->setNewValue(!$config->getIsEdit());
25
26 $editor = id(new PhabricatorEditEngineConfigurationEditor())
27 ->setActor($viewer)
28 ->setContentSourceFromRequest($request)
29 ->setContinueOnMissingFields(true)
30 ->setContinueOnNoEffect(true);
31
32 $editor->applyTransactions($config, $xactions);
33
34 return id(new AphrontRedirectResponse())
35 ->setURI($cancel_uri);
36 }
37
38 if ($config->getIsEdit()) {
39 $title = pht('Unmark as Edit Form');
40 $body = pht(
41 'Unmark this form as an edit form? It will no longer be able to be '.
42 'used to edit objects.');
43 $button = pht('Unmark Form');
44 } else {
45 $title = pht('Mark as Edit Form');
46 $body = pht(
47 'Mark this form as an edit form? Users who can view it will be able '.
48 'to use it to edit objects.');
49 $button = pht('Mark Form');
50 }
51
52 return $this->newDialog()
53 ->setTitle($title)
54 ->appendParagraph($body)
55 ->addSubmitButton($button)
56 ->addCancelbutton($cancel_uri);
57 }
58
59}