Path: blob/master/src/applications/calendar/controller/PhabricatorCalendarExportDisableController.php
12256 views
<?php12final class PhabricatorCalendarExportDisableController3extends PhabricatorCalendarController {45public function handleRequest(AphrontRequest $request) {6$viewer = $request->getViewer();78$export = id(new PhabricatorCalendarExportQuery())9->setViewer($viewer)10->withIDs(array($request->getURIData('id')))11->requireCapabilities(12array(13PhabricatorPolicyCapability::CAN_VIEW,14PhabricatorPolicyCapability::CAN_EDIT,15))16->executeOne();17if (!$export) {18return new Aphront404Response();19}2021$export_uri = $export->getURI();22$is_disable = !$export->getIsDisabled();2324if ($request->isFormPost()) {25$xactions = array();26$xactions[] = id(new PhabricatorCalendarExportTransaction())27->setTransactionType(28PhabricatorCalendarExportDisableTransaction::TRANSACTIONTYPE)29->setNewValue($is_disable ? 1 : 0);3031$editor = id(new PhabricatorCalendarExportEditor())32->setActor($viewer)33->setContinueOnNoEffect(true)34->setContinueOnMissingFields(true)35->setContentSourceFromRequest($request);3637$editor->applyTransactions($export, $xactions);3839return id(new AphrontRedirectResponse())->setURI($export_uri);40}4142if ($is_disable) {43$title = pht('Disable Export');44$body = pht(45'Disable this export? The export URI will no longer function.');46$button = pht('Disable Export');47} else {48$title = pht('Enable Export');49$body = pht(50'Enable this export? Anyone who knows the export URI will be able '.51'to export the data.');52$button = pht('Enable Export');53}5455return $this->newDialog()56->setTitle($title)57->appendParagraph($body)58->addCancelButton($export_uri)59->addSubmitButton($button);60}6162}636465