From 629fa368cb9ae2331028e1504bb95f55a50d7d4b Mon Sep 17 00:00:00 2001 From: Valerio Bozzolan Date: Wed, 25 Oct 2023 19:07:44 +0200 Subject: [PATCH] Calendar: fix creation of ICS Files Summary: It seems that, in an attempt to make ICS URI(s) editable, we broke the ability to manually import ICS files. Whops. The cause is, the URI needs to be put inside its dedicated import engine, and not the general one. Since the intention of T15137 was to be able to edit this field, we have done that in the right way this time. So, you see the field, not just in creation mode. Thanks to the kind aklapper for reporting. Ref T15137 Closes T15619 Rollback 02a4f8b0c8f1279fc0040ad8077942fd8b0d948b Test Plan: - visit /calendar/import/ and: - create/edit an ICS File Import (now works again) - create/edit an ICS URI Import (still work) - try looking at an "ICS Import page" as author (URI still visible) - try looking at an "ICS Import page" without Edit permissions (URI still omitted correctly) Reviewers: aklapper, O1 Blessed Committers, 20after4 Reviewed By: aklapper, O1 Blessed Committers, 20after4 Subscribers: 20after4, tobiaswiese, Matthew, Cigaryno Maniphest Tasks: T15619, T15137 Differential Revision: https://we.phorge.it/D25448 --- .../PhabricatorCalendarImportEditEngine.php | 15 ------------ .../PhabricatorCalendarICSURIImportEngine.php | 23 +++++++++++-------- 2 files changed, 13 insertions(+), 25 deletions(-) diff --git a/src/applications/calendar/editor/PhabricatorCalendarImportEditEngine.php b/src/applications/calendar/editor/PhabricatorCalendarImportEditEngine.php index 9a4a7c0107..7be3969671 100644 --- a/src/applications/calendar/editor/PhabricatorCalendarImportEditEngine.php +++ b/src/applications/calendar/editor/PhabricatorCalendarImportEditEngine.php @@ -83,12 +83,6 @@ final class PhabricatorCalendarImportEditEngine $engine = $object->getEngine(); $can_trigger = $engine->supportsTriggers($object); - // calendar URI import - // note that it can contains a secret token - // if we are here you have enough privileges to edit and see the value - $uri_key = PhabricatorCalendarImportICSURITransaction::PARAMKEY_URI; - $uri = $object->getParameter($uri_key); - $fields = array( id(new PhabricatorTextEditField()) ->setKey('name') @@ -100,15 +94,6 @@ final class PhabricatorCalendarImportEditEngine ->setConduitTypeDescription(pht('New import name.')) ->setPlaceholder($object->getDisplayName()) ->setValue($object->getName()), - id(new PhabricatorTextEditField()) - ->setKey('uri') - ->setLabel(pht('URI')) - ->setDescription(pht('URI to import.')) - ->setTransactionType( - PhabricatorCalendarImportICSURITransaction::TRANSACTIONTYPE) - ->setConduitDescription(pht('URI to import.')) - ->setConduitTypeDescription(pht('New URI.')) - ->setValue($uri), id(new PhabricatorBoolEditField()) ->setKey('disabled') ->setOptions(pht('Active'), pht('Disabled')) diff --git a/src/applications/calendar/import/PhabricatorCalendarICSURIImportEngine.php b/src/applications/calendar/import/PhabricatorCalendarICSURIImportEngine.php index bd52ec5bc2..6c992e0836 100644 --- a/src/applications/calendar/import/PhabricatorCalendarICSURIImportEngine.php +++ b/src/applications/calendar/import/PhabricatorCalendarICSURIImportEngine.php @@ -58,16 +58,19 @@ final class PhabricatorCalendarICSURIImportEngine PhabricatorCalendarImport $import) { $fields = array(); - if ($engine->getIsCreate()) { - $fields[] = id(new PhabricatorTextEditField()) - ->setKey('uri') - ->setLabel(pht('URI')) - ->setDescription(pht('URI to import.')) - ->setTransactionType( - PhabricatorCalendarImportICSURITransaction::TRANSACTIONTYPE) - ->setConduitDescription(pht('URI to import.')) - ->setConduitTypeDescription(pht('New URI.')); - } + // If you are here, you already have the "can edit" capability. + // So you are supposed to be able to edit again your Calendar import URI. + $uri_key = PhabricatorCalendarImportICSURITransaction::PARAMKEY_URI; + $uri = $import->getParameter($uri_key); + $fields[] = id(new PhabricatorTextEditField()) + ->setKey('uri') + ->setLabel(pht('URI')) + ->setDescription(pht('URI to import.')) + ->setTransactionType( + PhabricatorCalendarImportICSURITransaction::TRANSACTIONTYPE) + ->setConduitDescription(pht('URI to import.')) + ->setConduitTypeDescription(pht('New URI.')) + ->setValue($uri); return $fields; }