@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 PhabricatorCalendarExportDisableController
4 extends PhabricatorCalendarController {
5
6 public function handleRequest(AphrontRequest $request) {
7 $viewer = $request->getViewer();
8
9 $export = id(new PhabricatorCalendarExportQuery())
10 ->setViewer($viewer)
11 ->withIDs(array($request->getURIData('id')))
12 ->requireCapabilities(
13 array(
14 PhabricatorPolicyCapability::CAN_VIEW,
15 PhabricatorPolicyCapability::CAN_EDIT,
16 ))
17 ->executeOne();
18 if (!$export) {
19 return new Aphront404Response();
20 }
21
22 $export_uri = $export->getURI();
23 $is_disable = !$export->getIsDisabled();
24
25 if ($request->isFormPost()) {
26 $xactions = array();
27 $xactions[] = id(new PhabricatorCalendarExportTransaction())
28 ->setTransactionType(
29 PhabricatorCalendarExportDisableTransaction::TRANSACTIONTYPE)
30 ->setNewValue($is_disable ? 1 : 0);
31
32 $editor = id(new PhabricatorCalendarExportEditor())
33 ->setActor($viewer)
34 ->setContinueOnNoEffect(true)
35 ->setContinueOnMissingFields(true)
36 ->setContentSourceFromRequest($request);
37
38 $editor->applyTransactions($export, $xactions);
39
40 return id(new AphrontRedirectResponse())->setURI($export_uri);
41 }
42
43 if ($is_disable) {
44 $title = pht('Disable Export');
45 $body = pht(
46 'Disable this export? The export URI will no longer function.');
47 $button = pht('Disable Export');
48 } else {
49 $title = pht('Enable Export');
50 $body = pht(
51 'Enable this export? Anyone who knows the export URI will be able '.
52 'to export the data.');
53 $button = pht('Enable Export');
54 }
55
56 return $this->newDialog()
57 ->setTitle($title)
58 ->appendParagraph($body)
59 ->addCancelButton($export_uri)
60 ->addSubmitButton($button);
61 }
62
63}