mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-25 08:12:40 +01:00
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
This commit is contained in:
parent
d5040f9a8f
commit
02a4f8b0c8
2 changed files with 43 additions and 1 deletions
|
@ -8,7 +8,22 @@ final class PhabricatorCalendarImportEditController
|
|||
->setController($this);
|
||||
|
||||
$id = $request->getURIData('id');
|
||||
if (!$id) {
|
||||
if ($id) {
|
||||
|
||||
// edit a specific entry
|
||||
|
||||
$calendar_import = self::queryImportByID($request, $id);
|
||||
if (!$calendar_import) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
|
||||
// pass the correct import engine to build the response
|
||||
$engine->setImportEngine($calendar_import->getEngine());
|
||||
|
||||
} else {
|
||||
|
||||
// create an entry
|
||||
|
||||
$list_uri = $this->getApplicationURI('import/');
|
||||
|
||||
$import_type = $request->getStr('importType');
|
||||
|
@ -27,6 +42,18 @@ final class PhabricatorCalendarImportEditController
|
|||
return $engine->buildResponse();
|
||||
}
|
||||
|
||||
private static function queryImportByID(AphrontRequest $request, int $id) {
|
||||
return id(new PhabricatorCalendarImportQuery())
|
||||
->setViewer($request->getViewer())
|
||||
->withIDs(array($id))
|
||||
->requireCapabilities(
|
||||
array(
|
||||
PhabricatorPolicyCapability::CAN_VIEW,
|
||||
PhabricatorPolicyCapability::CAN_EDIT,
|
||||
))
|
||||
->executeOne();
|
||||
}
|
||||
|
||||
private function buildEngineTypeResponse($cancel_uri) {
|
||||
$import_engines = PhabricatorCalendarImportEngine::getAllImportEngines();
|
||||
|
||||
|
|
|
@ -83,6 +83,12 @@ 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')
|
||||
|
@ -94,6 +100,15 @@ 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'))
|
||||
|
|
Loading…
Reference in a new issue