@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
fork

Configure Feed

Select the types of activity you want to include in your feed.

Allow Calendar exports to be disabled

Summary:
Ref T10747. This adds disable/enable to exports.

Mostly useful if you leak a URI by accident.

Test Plan:
- Disabled and enabled exports.
- Verified that disabled exports don't actually export any data.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10747

Differential Revision: https://secure.phabricator.com/D16681

+99 -5
+2
src/__phutil_library_map__.php
··· 2076 2076 'PhabricatorCalendarEventUntilDateTransaction' => 'applications/calendar/xaction/PhabricatorCalendarEventUntilDateTransaction.php', 2077 2077 'PhabricatorCalendarEventViewController' => 'applications/calendar/controller/PhabricatorCalendarEventViewController.php', 2078 2078 'PhabricatorCalendarExport' => 'applications/calendar/storage/PhabricatorCalendarExport.php', 2079 + 'PhabricatorCalendarExportDisableController' => 'applications/calendar/controller/PhabricatorCalendarExportDisableController.php', 2079 2080 'PhabricatorCalendarExportDisableTransaction' => 'applications/calendar/xaction/PhabricatorCalendarExportDisableTransaction.php', 2080 2081 'PhabricatorCalendarExportEditController' => 'applications/calendar/controller/PhabricatorCalendarExportEditController.php', 2081 2082 'PhabricatorCalendarExportEditEngine' => 'applications/calendar/editor/PhabricatorCalendarExportEditEngine.php', ··· 6849 6850 'PhabricatorApplicationTransactionInterface', 6850 6851 'PhabricatorDestructibleInterface', 6851 6852 ), 6853 + 'PhabricatorCalendarExportDisableController' => 'PhabricatorCalendarController', 6852 6854 'PhabricatorCalendarExportDisableTransaction' => 'PhabricatorCalendarExportTransactionType', 6853 6855 'PhabricatorCalendarExportEditController' => 'PhabricatorCalendarController', 6854 6856 'PhabricatorCalendarExportEditEngine' => 'PhabricatorEditEngine',
+3
src/applications/calendar/application/PhabricatorCalendarApplication.php
··· 71 71 => 'PhabricatorCalendarExportViewController', 72 72 'ics/(?P<secretKey>[^/]+)/(?P<filename>[^/]*)' 73 73 => 'PhabricatorCalendarExportICSController', 74 + 'disable/(?P<id>[1-9]\d*)/' 75 + => 'PhabricatorCalendarExportDisableController', 76 + 74 77 ), 75 78 ), 76 79 );
+63
src/applications/calendar/controller/PhabricatorCalendarExportDisableController.php
··· 1 + <?php 2 + 3 + final 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 + }
+4
src/applications/calendar/controller/PhabricatorCalendarExportICSController.php
··· 24 24 return new Aphront404Response(); 25 25 } 26 26 27 + if ($export->getIsDisabled()) { 28 + return new Aphront404Response(); 29 + } 30 + 27 31 $author = id(new PhabricatorPeopleQuery()) 28 32 ->setViewer($omnipotent) 29 33 ->withPHIDs(array($export->getAuthorPHID()))
+27 -5
src/applications/calendar/controller/PhabricatorCalendarExportViewController.php
··· 55 55 56 56 if ($export->getIsDisabled()) { 57 57 $icon = 'fa-ban'; 58 - $color = 'grey'; 58 + $color = 'red'; 59 59 $status = pht('Disabled'); 60 60 } else { 61 61 $icon = 'fa-check'; ··· 102 102 ->setIcon('fa-download') 103 103 ->setHref($ics_uri)); 104 104 105 + $disable_uri = "export/disable/{$id}/"; 106 + $disable_uri = $this->getApplicationURI($disable_uri); 107 + if ($export->getIsDisabled()) { 108 + $disable_name = pht('Enable Export'); 109 + $disable_icon = 'fa-check'; 110 + } else { 111 + $disable_name = pht('Disable Export'); 112 + $disable_icon = 'fa-ban'; 113 + } 114 + 115 + $curtain->addAction( 116 + id(new PhabricatorActionView()) 117 + ->setName($disable_name) 118 + ->setIcon($disable_icon) 119 + ->setDisabled(!$can_edit) 120 + ->setWorkflow(true) 121 + ->setHref($disable_uri)); 122 + 105 123 return $curtain; 106 124 } 107 125 ··· 140 158 $ics_uri = $export->getICSURI(); 141 159 $ics_uri = PhabricatorEnv::getURI($ics_uri); 142 160 143 - $properties->addProperty( 144 - pht('ICS URI'), 145 - phutil_tag( 161 + if ($export->getIsDisabled()) { 162 + $ics_href = phutil_tag('em', array(), $ics_uri); 163 + } else { 164 + $ics_href = phutil_tag( 146 165 'a', 147 166 array( 148 167 'href' => $ics_uri, 149 168 ), 150 - $ics_uri)); 169 + $ics_uri); 170 + } 171 + 172 + $properties->addProperty(pht('ICS URI'), $ics_href); 151 173 152 174 return $properties; 153 175 }