@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 PhabricatorCalendarImportDeleteController
4 extends PhabricatorCalendarController {
5
6 public function handleRequest(AphrontRequest $request) {
7 $viewer = $request->getViewer();
8
9 $import = id(new PhabricatorCalendarImportQuery())
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 (!$import) {
19 return new Aphront404Response();
20 }
21
22 $import_uri = $import->getURI();
23
24 $engine = $import->getEngine();
25 if (!$engine->canDeleteAnyEvents($viewer, $import)) {
26 return $this->newDialog()
27 ->setTitle(pht('No Imported Events'))
28 ->appendParagraph(
29 pht(
30 'No events from this source currently exist. They may have '.
31 'failed to import, have been updated by another source, or '.
32 'already have been deleted.'))
33 ->addCancelButton($import_uri, pht('Done'));
34 }
35
36 if ($request->isFormPost()) {
37 $xactions = array();
38 $xactions[] = id(new PhabricatorCalendarImportTransaction())
39 ->setTransactionType(
40 PhabricatorCalendarImportDeleteTransaction::TRANSACTIONTYPE)
41 ->setNewValue(true);
42
43 $editor = id(new PhabricatorCalendarImportEditor())
44 ->setActor($viewer)
45 ->setContinueOnNoEffect(true)
46 ->setContinueOnMissingFields(true)
47 ->setContentSourceFromRequest($request);
48
49 $editor->applyTransactions($import, $xactions);
50
51 return id(new AphrontRedirectResponse())->setURI($import_uri);
52 }
53
54 return $this->newDialog()
55 ->setTitle(pht('Delete Imported Events'))
56 ->appendParagraph(
57 pht(
58 'Delete all the events that were imported from this source? '.
59 'This action can not be undone.'))
60 ->addCancelButton($import_uri)
61 ->addSubmitButton(pht('Delete Events'));
62 }
63
64}