mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-19 03:50:54 +01:00
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
This commit is contained in:
parent
ff97ed2195
commit
bc6e6c0500
5 changed files with 99 additions and 5 deletions
|
@ -2076,6 +2076,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorCalendarEventUntilDateTransaction' => 'applications/calendar/xaction/PhabricatorCalendarEventUntilDateTransaction.php',
|
||||
'PhabricatorCalendarEventViewController' => 'applications/calendar/controller/PhabricatorCalendarEventViewController.php',
|
||||
'PhabricatorCalendarExport' => 'applications/calendar/storage/PhabricatorCalendarExport.php',
|
||||
'PhabricatorCalendarExportDisableController' => 'applications/calendar/controller/PhabricatorCalendarExportDisableController.php',
|
||||
'PhabricatorCalendarExportDisableTransaction' => 'applications/calendar/xaction/PhabricatorCalendarExportDisableTransaction.php',
|
||||
'PhabricatorCalendarExportEditController' => 'applications/calendar/controller/PhabricatorCalendarExportEditController.php',
|
||||
'PhabricatorCalendarExportEditEngine' => 'applications/calendar/editor/PhabricatorCalendarExportEditEngine.php',
|
||||
|
@ -6849,6 +6850,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorApplicationTransactionInterface',
|
||||
'PhabricatorDestructibleInterface',
|
||||
),
|
||||
'PhabricatorCalendarExportDisableController' => 'PhabricatorCalendarController',
|
||||
'PhabricatorCalendarExportDisableTransaction' => 'PhabricatorCalendarExportTransactionType',
|
||||
'PhabricatorCalendarExportEditController' => 'PhabricatorCalendarController',
|
||||
'PhabricatorCalendarExportEditEngine' => 'PhabricatorEditEngine',
|
||||
|
|
|
@ -71,6 +71,9 @@ final class PhabricatorCalendarApplication extends PhabricatorApplication {
|
|||
=> 'PhabricatorCalendarExportViewController',
|
||||
'ics/(?P<secretKey>[^/]+)/(?P<filename>[^/]*)'
|
||||
=> 'PhabricatorCalendarExportICSController',
|
||||
'disable/(?P<id>[1-9]\d*)/'
|
||||
=> 'PhabricatorCalendarExportDisableController',
|
||||
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorCalendarExportDisableController
|
||||
extends PhabricatorCalendarController {
|
||||
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
$viewer = $request->getViewer();
|
||||
|
||||
$export = id(new PhabricatorCalendarExportQuery())
|
||||
->setViewer($viewer)
|
||||
->withIDs(array($request->getURIData('id')))
|
||||
->requireCapabilities(
|
||||
array(
|
||||
PhabricatorPolicyCapability::CAN_VIEW,
|
||||
PhabricatorPolicyCapability::CAN_EDIT,
|
||||
))
|
||||
->executeOne();
|
||||
if (!$export) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
|
||||
$export_uri = $export->getURI();
|
||||
$is_disable = !$export->getIsDisabled();
|
||||
|
||||
if ($request->isFormPost()) {
|
||||
$xactions = array();
|
||||
$xactions[] = id(new PhabricatorCalendarExportTransaction())
|
||||
->setTransactionType(
|
||||
PhabricatorCalendarExportDisableTransaction::TRANSACTIONTYPE)
|
||||
->setNewValue($is_disable ? 1 : 0);
|
||||
|
||||
$editor = id(new PhabricatorCalendarExportEditor())
|
||||
->setActor($viewer)
|
||||
->setContinueOnNoEffect(true)
|
||||
->setContinueOnMissingFields(true)
|
||||
->setContentSourceFromRequest($request);
|
||||
|
||||
$editor->applyTransactions($export, $xactions);
|
||||
|
||||
return id(new AphrontRedirectResponse())->setURI($export_uri);
|
||||
}
|
||||
|
||||
if ($is_disable) {
|
||||
$title = pht('Disable Export');
|
||||
$body = pht(
|
||||
'Disable this export? The export URI will no longer function.');
|
||||
$button = pht('Disable Export');
|
||||
} else {
|
||||
$title = pht('Enable Export');
|
||||
$body = pht(
|
||||
'Enable this export? Anyone who knows the export URI will be able '.
|
||||
'to export the data.');
|
||||
$button = pht('Enable Export');
|
||||
}
|
||||
|
||||
return $this->newDialog()
|
||||
->setTitle($title)
|
||||
->appendParagraph($body)
|
||||
->addCancelButton($export_uri)
|
||||
->addSubmitButton($button);
|
||||
}
|
||||
|
||||
}
|
|
@ -24,6 +24,10 @@ final class PhabricatorCalendarExportICSController
|
|||
return new Aphront404Response();
|
||||
}
|
||||
|
||||
if ($export->getIsDisabled()) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
|
||||
$author = id(new PhabricatorPeopleQuery())
|
||||
->setViewer($omnipotent)
|
||||
->withPHIDs(array($export->getAuthorPHID()))
|
||||
|
|
|
@ -55,7 +55,7 @@ final class PhabricatorCalendarExportViewController
|
|||
|
||||
if ($export->getIsDisabled()) {
|
||||
$icon = 'fa-ban';
|
||||
$color = 'grey';
|
||||
$color = 'red';
|
||||
$status = pht('Disabled');
|
||||
} else {
|
||||
$icon = 'fa-check';
|
||||
|
@ -102,6 +102,24 @@ final class PhabricatorCalendarExportViewController
|
|||
->setIcon('fa-download')
|
||||
->setHref($ics_uri));
|
||||
|
||||
$disable_uri = "export/disable/{$id}/";
|
||||
$disable_uri = $this->getApplicationURI($disable_uri);
|
||||
if ($export->getIsDisabled()) {
|
||||
$disable_name = pht('Enable Export');
|
||||
$disable_icon = 'fa-check';
|
||||
} else {
|
||||
$disable_name = pht('Disable Export');
|
||||
$disable_icon = 'fa-ban';
|
||||
}
|
||||
|
||||
$curtain->addAction(
|
||||
id(new PhabricatorActionView())
|
||||
->setName($disable_name)
|
||||
->setIcon($disable_icon)
|
||||
->setDisabled(!$can_edit)
|
||||
->setWorkflow(true)
|
||||
->setHref($disable_uri));
|
||||
|
||||
return $curtain;
|
||||
}
|
||||
|
||||
|
@ -140,14 +158,18 @@ final class PhabricatorCalendarExportViewController
|
|||
$ics_uri = $export->getICSURI();
|
||||
$ics_uri = PhabricatorEnv::getURI($ics_uri);
|
||||
|
||||
$properties->addProperty(
|
||||
pht('ICS URI'),
|
||||
phutil_tag(
|
||||
if ($export->getIsDisabled()) {
|
||||
$ics_href = phutil_tag('em', array(), $ics_uri);
|
||||
} else {
|
||||
$ics_href = phutil_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => $ics_uri,
|
||||
),
|
||||
$ics_uri));
|
||||
$ics_uri);
|
||||
}
|
||||
|
||||
$properties->addProperty(pht('ICS URI'), $ics_href);
|
||||
|
||||
return $properties;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue