Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15390260
D16553.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Referenced Files
None
Subscribers
None
D16553.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -2044,6 +2044,7 @@
'PhabricatorCalendarEventEditor' => 'applications/calendar/editor/PhabricatorCalendarEventEditor.php',
'PhabricatorCalendarEventEmailCommand' => 'applications/calendar/command/PhabricatorCalendarEventEmailCommand.php',
'PhabricatorCalendarEventEndDateTransaction' => 'applications/calendar/xaction/PhabricatorCalendarEventEndDateTransaction.php',
+ 'PhabricatorCalendarEventExportController' => 'applications/calendar/controller/PhabricatorCalendarEventExportController.php',
'PhabricatorCalendarEventFrequencyTransaction' => 'applications/calendar/xaction/PhabricatorCalendarEventFrequencyTransaction.php',
'PhabricatorCalendarEventFulltextEngine' => 'applications/calendar/search/PhabricatorCalendarEventFulltextEngine.php',
'PhabricatorCalendarEventHeraldAdapter' => 'applications/calendar/herald/PhabricatorCalendarEventHeraldAdapter.php',
@@ -6781,6 +6782,7 @@
'PhabricatorCalendarEventEditor' => 'PhabricatorApplicationTransactionEditor',
'PhabricatorCalendarEventEmailCommand' => 'MetaMTAEmailTransactionCommand',
'PhabricatorCalendarEventEndDateTransaction' => 'PhabricatorCalendarEventDateTransaction',
+ 'PhabricatorCalendarEventExportController' => 'PhabricatorCalendarController',
'PhabricatorCalendarEventFrequencyTransaction' => 'PhabricatorCalendarEventTransactionType',
'PhabricatorCalendarEventFulltextEngine' => 'PhabricatorFulltextEngine',
'PhabricatorCalendarEventHeraldAdapter' => 'HeraldAdapter',
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,6 +59,8 @@
=> 'PhabricatorCalendarEventCancelController',
'(?P<action>join|decline|accept)/(?P<id>[1-9]\d*)/'
=> 'PhabricatorCalendarEventJoinController',
+ 'export/(?P<id>[1-9]\d*)/'
+ => 'PhabricatorCalendarEventExportController',
),
),
);
diff --git a/src/applications/calendar/controller/PhabricatorCalendarEventExportController.php b/src/applications/calendar/controller/PhabricatorCalendarEventExportController.php
new file mode 100644
--- /dev/null
+++ b/src/applications/calendar/controller/PhabricatorCalendarEventExportController.php
@@ -0,0 +1,54 @@
+<?php
+
+final class PhabricatorCalendarEventExportController
+ extends PhabricatorCalendarController {
+
+ public function shouldAllowPublic() {
+ return true;
+ }
+
+ public function handleRequest(AphrontRequest $request) {
+ $viewer = $this->getViewer();
+ $id = $request->getURIData('id');
+
+ $event = id(new PhabricatorCalendarEventQuery())
+ ->setViewer($viewer)
+ ->withIDs(array($id))
+ ->executeOne();
+ if (!$event) {
+ return new Aphront404Response();
+ }
+
+ if ($request->isFormPost()) {
+ $file_name = $event->getMonogram().'.ics';
+
+ $event_node = $event->newIntermediateEventNode();
+
+ $document_node = id(new PhutilCalendarDocumentNode())
+ ->appendChild($event_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'));
+
+ }
+
+}
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,6 +193,15 @@
->setWorkflow(true));
}
+ $export_uri = $this->getApplicationURI("event/export/{$id}/");
+
+ $curtain->addAction(
+ id(new PhabricatorActionView())
+ ->setName(pht('Export as .ics'))
+ ->setIcon('fa-download')
+ ->setHref($export_uri)
+ ->setWorkflow(true));
+
return $curtain;
}
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
@@ -626,6 +626,43 @@
}
+ public function newIntermediateEventNode() {
+ $base_uri = new PhutilURI(PhabricatorEnv::getProductionURI('/'));
+ $domain = $base_uri->getDomain();
+
+ $uid = $this->getPHID().'@'.$domain;
+
+ $created = $this->getDateCreated();
+ $created = PhutilCalendarAbsoluteDateTime::newFromEpoch($created);
+
+ $modified = $this->getDateModified();
+ $modified = PhutilCalendarAbsoluteDateTime::newFromEpoch($modified);
+
+ $date_start = $this->getDateFrom();
+ $date_start = PhutilCalendarAbsoluteDateTime::newFromEpoch($date_start);
+
+ $date_end = $this->getDateTo();
+ $date_end = PhutilCalendarAbsoluteDateTime::newFromEpoch($date_end);
+
+ if ($this->getIsAllDay()) {
+ $date_start->setIsAllDay(true);
+ $date_end->setIsAllDay(true);
+ }
+
+ $node = id(new PhutilCalendarEventNode())
+ ->setUID($uid)
+ ->setName($this->getName())
+ ->setDescription($this->getDescription())
+ ->setCreatedDateTime($created)
+ ->setModifiedDateTime($modified)
+ ->setStartDateTime($date_start)
+ ->setEndDateTime($date_end);
+
+ return $node;
+ }
+
+
+
/* -( Markup Interface )--------------------------------------------------- */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Mar 16, 6:04 AM (2 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7706242
Default Alt Text
D16553.diff (6 KB)
Attached To
Mode
D16553: Add an "Export as .ics" action to Calendar events
Attached
Detach File
Event Timeline
Log In to Comment