Page MenuHomePhabricator

D16559.diff
No OneTemporary

D16559.diff

diff --git a/src/applications/calendar/application/PhabricatorCalendarApplication.php b/src/applications/calendar/application/PhabricatorCalendarApplication.php
--- a/src/applications/calendar/application/PhabricatorCalendarApplication.php
+++ b/src/applications/calendar/application/PhabricatorCalendarApplication.php
@@ -59,7 +59,7 @@
=> 'PhabricatorCalendarEventCancelController',
'(?P<action>join|decline|accept)/(?P<id>[1-9]\d*)/'
=> 'PhabricatorCalendarEventJoinController',
- 'export/(?P<id>[1-9]\d*)/'
+ 'export/(?P<id>[1-9]\d*)/(?P<filename>[^/]*)'
=> 'PhabricatorCalendarEventExportController',
),
),
diff --git a/src/applications/calendar/controller/PhabricatorCalendarEventExportController.php b/src/applications/calendar/controller/PhabricatorCalendarEventExportController.php
--- a/src/applications/calendar/controller/PhabricatorCalendarEventExportController.php
+++ b/src/applications/calendar/controller/PhabricatorCalendarEventExportController.php
@@ -19,36 +19,22 @@
return new Aphront404Response();
}
- if ($request->isFormPost()) {
- $file_name = $event->getMonogram().'.ics';
+ $file_name = $event->getICSFilename();
+ $event_node = $event->newIntermediateEventNode($viewer);
- $event_node = $event->newIntermediateEventNode($viewer);
+ $document_node = id(new PhutilCalendarDocumentNode())
+ ->appendChild($event_node);
- $document_node = id(new PhutilCalendarDocumentNode())
- ->appendChild($event_node);
+ $root_node = id(new PhutilCalendarRootNode())
+ ->appendChild($document_node);
- $root_node = id(new PhutilCalendarRootNode())
- ->appendChild($document_node);
-
- $ics_data = id(new PhutilICSWriter())
- ->writeICSDocument($root_node);
-
- return id(new AphrontFileResponse())
- ->setDownload($file_name)
- ->setMimeType('text/calendar')
- ->setContent($ics_data);
- }
-
- return $this->newDialog()
- ->setDisableWorkflowOnSubmit(true)
- ->setTitle(pht('Export as .ics'))
- ->appendParagraph(
- pht(
- 'WARNING: This feature is a prototype and only supports a limited '.
- 'set of features. Keep your expectations low!'))
- ->addSubmitButton(pht('Download .ics'))
- ->addCancelButton($event->getURI(), pht('Close'));
+ $ics_data = id(new PhutilICSWriter())
+ ->writeICSDocument($root_node);
+ return id(new AphrontFileResponse())
+ ->setDownload($file_name)
+ ->setMimeType('text/calendar')
+ ->setContent($ics_data);
}
}
diff --git a/src/applications/calendar/controller/PhabricatorCalendarEventViewController.php b/src/applications/calendar/controller/PhabricatorCalendarEventViewController.php
--- a/src/applications/calendar/controller/PhabricatorCalendarEventViewController.php
+++ b/src/applications/calendar/controller/PhabricatorCalendarEventViewController.php
@@ -193,14 +193,14 @@
->setWorkflow(true));
}
- $export_uri = $this->getApplicationURI("event/export/{$id}/");
+ $ics_name = $event->getICSFilename();
+ $export_uri = $this->getApplicationURI("event/export/{$id}/{$ics_name}");
$curtain->addAction(
id(new PhabricatorActionView())
->setName(pht('Export as .ics'))
->setIcon('fa-download')
- ->setHref($export_uri)
- ->setWorkflow(true));
+ ->setHref($export_uri));
return $curtain;
}
diff --git a/src/applications/calendar/editor/PhabricatorCalendarEventEditor.php b/src/applications/calendar/editor/PhabricatorCalendarEventEditor.php
--- a/src/applications/calendar/editor/PhabricatorCalendarEventEditor.php
+++ b/src/applications/calendar/editor/PhabricatorCalendarEventEditor.php
@@ -285,6 +285,8 @@
pht('EVENT DETAIL'),
PhabricatorEnv::getProductionURI('/E'.$object->getID()));
+ $ics_attachment = $this->newICSAttachment($object);
+ $body->addAttachment($ics_attachment);
return $body;
}
@@ -303,5 +305,27 @@
->setObject($object);
}
+ private function newICSAttachment(
+ PhabricatorCalendarEvent $event) {
+ $actor = $this->getActor();
+
+ $event_node = $event->newIntermediateEventNode($actor);
+
+ $document_node = id(new PhutilCalendarDocumentNode())
+ ->appendChild($event_node);
+
+ $root_node = id(new PhutilCalendarRootNode())
+ ->appendChild($document_node);
+
+ $ics_data = id(new PhutilICSWriter())
+ ->writeICSDocument($root_node);
+
+ $ics_attachment = new PhabricatorMetaMTAAttachment(
+ $ics_data,
+ $event->getICSFilename(),
+ 'text/calendar');
+
+ return $ics_attachment;
+ }
}
diff --git a/src/applications/calendar/storage/PhabricatorCalendarEvent.php b/src/applications/calendar/storage/PhabricatorCalendarEvent.php
--- a/src/applications/calendar/storage/PhabricatorCalendarEvent.php
+++ b/src/applications/calendar/storage/PhabricatorCalendarEvent.php
@@ -625,6 +625,9 @@
return null;
}
+ public function getICSFilename() {
+ return $this->getMonogram().'.ics';
+ }
public function newIntermediateEventNode(PhabricatorUser $viewer) {
$base_uri = new PhutilURI(PhabricatorEnv::getProductionURI('/'));

File Metadata

Mime Type
text/plain
Expires
Sun, Mar 16, 3:59 AM (1 w, 21 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7701107
Default Alt Text
D16559.diff (5 KB)

Event Timeline