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

Fix editing a Calendar import ICS URI

Summary:
Before this change it was only possible to create a Calendar import ICS URI.
After this change it's possible to also edit already-existing elements.

This change fixes this specific exception when visiting similar pages:

/calendar/import/edit/5/

Argument 2 passed to PhabricatorCalendarImport::initializeNewCalendarImport()
must be an instance of PhabricatorCalendarImportEngine, null given, called in
phorge/src/applications/calendar/editor/PhabricatorCalendarImportEditEngine.php
on line 45

Before this change it was only theorically possible to edit the name, policies, etc.
but not the URI.

This change also introduces the ability to edit the specific ICS URI,
in order to change legitimate parts of the URI, like the secret token.

Closes T15137

Test Plan:
I tested in my own installation with success lints.

To test, visit the Calendar, create an import ICS URI, and then try to edit it again.
It will work only after this change.

I was not able to conclude the "arc diff" since it tries to connect
to an unexisting database owned by root.

Reviewers: O1 Blessed Committers, avivey

Reviewed By: O1 Blessed Committers, avivey

Subscribers: avivey, Cigaryno, speck, tobiaswiese, Matthew

Maniphest Tasks: T15137

Differential Revision: https://we.phorge.it/D25061

+43 -1
+28 -1
src/applications/calendar/controller/PhabricatorCalendarImportEditController.php
··· 8 8 ->setController($this); 9 9 10 10 $id = $request->getURIData('id'); 11 - if (!$id) { 11 + if ($id) { 12 + 13 + // edit a specific entry 14 + 15 + $calendar_import = self::queryImportByID($request, $id); 16 + if (!$calendar_import) { 17 + return new Aphront404Response(); 18 + } 19 + 20 + // pass the correct import engine to build the response 21 + $engine->setImportEngine($calendar_import->getEngine()); 22 + 23 + } else { 24 + 25 + // create an entry 26 + 12 27 $list_uri = $this->getApplicationURI('import/'); 13 28 14 29 $import_type = $request->getStr('importType'); ··· 25 40 } 26 41 27 42 return $engine->buildResponse(); 43 + } 44 + 45 + private static function queryImportByID(AphrontRequest $request, int $id) { 46 + return id(new PhabricatorCalendarImportQuery()) 47 + ->setViewer($request->getViewer()) 48 + ->withIDs(array($id)) 49 + ->requireCapabilities( 50 + array( 51 + PhabricatorPolicyCapability::CAN_VIEW, 52 + PhabricatorPolicyCapability::CAN_EDIT, 53 + )) 54 + ->executeOne(); 28 55 } 29 56 30 57 private function buildEngineTypeResponse($cancel_uri) {
+15
src/applications/calendar/editor/PhabricatorCalendarImportEditEngine.php
··· 83 83 $engine = $object->getEngine(); 84 84 $can_trigger = $engine->supportsTriggers($object); 85 85 86 + // calendar URI import 87 + // note that it can contains a secret token 88 + // if we are here you have enough privileges to edit and see the value 89 + $uri_key = PhabricatorCalendarImportICSURITransaction::PARAMKEY_URI; 90 + $uri = $object->getParameter($uri_key); 91 + 86 92 $fields = array( 87 93 id(new PhabricatorTextEditField()) 88 94 ->setKey('name') ··· 94 100 ->setConduitTypeDescription(pht('New import name.')) 95 101 ->setPlaceholder($object->getDisplayName()) 96 102 ->setValue($object->getName()), 103 + id(new PhabricatorTextEditField()) 104 + ->setKey('uri') 105 + ->setLabel(pht('URI')) 106 + ->setDescription(pht('URI to import.')) 107 + ->setTransactionType( 108 + PhabricatorCalendarImportICSURITransaction::TRANSACTIONTYPE) 109 + ->setConduitDescription(pht('URI to import.')) 110 + ->setConduitTypeDescription(pht('New URI.')) 111 + ->setValue($uri), 97 112 id(new PhabricatorBoolEditField()) 98 113 ->setKey('disabled') 99 114 ->setOptions(pht('Active'), pht('Disabled'))