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

Add an "Export as .ics" action to Calendar events

Summary: Ref T10747. Allows you to grab an event as a (basic) ICS file.

Test Plan:
- Exported a normal event.
- Exported an all-day event.

{F1830577}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10747

Differential Revision: https://secure.phabricator.com/D16553

+104
+2
src/__phutil_library_map__.php
··· 2044 2044 'PhabricatorCalendarEventEditor' => 'applications/calendar/editor/PhabricatorCalendarEventEditor.php', 2045 2045 'PhabricatorCalendarEventEmailCommand' => 'applications/calendar/command/PhabricatorCalendarEventEmailCommand.php', 2046 2046 'PhabricatorCalendarEventEndDateTransaction' => 'applications/calendar/xaction/PhabricatorCalendarEventEndDateTransaction.php', 2047 + 'PhabricatorCalendarEventExportController' => 'applications/calendar/controller/PhabricatorCalendarEventExportController.php', 2047 2048 'PhabricatorCalendarEventFrequencyTransaction' => 'applications/calendar/xaction/PhabricatorCalendarEventFrequencyTransaction.php', 2048 2049 'PhabricatorCalendarEventFulltextEngine' => 'applications/calendar/search/PhabricatorCalendarEventFulltextEngine.php', 2049 2050 'PhabricatorCalendarEventHeraldAdapter' => 'applications/calendar/herald/PhabricatorCalendarEventHeraldAdapter.php', ··· 6781 6782 'PhabricatorCalendarEventEditor' => 'PhabricatorApplicationTransactionEditor', 6782 6783 'PhabricatorCalendarEventEmailCommand' => 'MetaMTAEmailTransactionCommand', 6783 6784 'PhabricatorCalendarEventEndDateTransaction' => 'PhabricatorCalendarEventDateTransaction', 6785 + 'PhabricatorCalendarEventExportController' => 'PhabricatorCalendarController', 6784 6786 'PhabricatorCalendarEventFrequencyTransaction' => 'PhabricatorCalendarEventTransactionType', 6785 6787 'PhabricatorCalendarEventFulltextEngine' => 'PhabricatorFulltextEngine', 6786 6788 'PhabricatorCalendarEventHeraldAdapter' => 'HeraldAdapter',
+2
src/applications/calendar/application/PhabricatorCalendarApplication.php
··· 59 59 => 'PhabricatorCalendarEventCancelController', 60 60 '(?P<action>join|decline|accept)/(?P<id>[1-9]\d*)/' 61 61 => 'PhabricatorCalendarEventJoinController', 62 + 'export/(?P<id>[1-9]\d*)/' 63 + => 'PhabricatorCalendarEventExportController', 62 64 ), 63 65 ), 64 66 );
+54
src/applications/calendar/controller/PhabricatorCalendarEventExportController.php
··· 1 + <?php 2 + 3 + final class PhabricatorCalendarEventExportController 4 + extends PhabricatorCalendarController { 5 + 6 + public function shouldAllowPublic() { 7 + return true; 8 + } 9 + 10 + public function handleRequest(AphrontRequest $request) { 11 + $viewer = $this->getViewer(); 12 + $id = $request->getURIData('id'); 13 + 14 + $event = id(new PhabricatorCalendarEventQuery()) 15 + ->setViewer($viewer) 16 + ->withIDs(array($id)) 17 + ->executeOne(); 18 + if (!$event) { 19 + return new Aphront404Response(); 20 + } 21 + 22 + if ($request->isFormPost()) { 23 + $file_name = $event->getMonogram().'.ics'; 24 + 25 + $event_node = $event->newIntermediateEventNode(); 26 + 27 + $document_node = id(new PhutilCalendarDocumentNode()) 28 + ->appendChild($event_node); 29 + 30 + $root_node = id(new PhutilCalendarRootNode()) 31 + ->appendChild($document_node); 32 + 33 + $ics_data = id(new PhutilICSWriter()) 34 + ->writeICSDocument($root_node); 35 + 36 + return id(new AphrontFileResponse()) 37 + ->setDownload($file_name) 38 + ->setMimeType('text/calendar') 39 + ->setContent($ics_data); 40 + } 41 + 42 + return $this->newDialog() 43 + ->setDisableWorkflowOnSubmit(true) 44 + ->setTitle(pht('Export as .ics')) 45 + ->appendParagraph( 46 + pht( 47 + 'WARNING: This feature is a prototype and only supports a limited '. 48 + 'set of features. Keep your expectations low!')) 49 + ->addSubmitButton(pht('Download .ics')) 50 + ->addCancelButton($event->getURI(), pht('Close')); 51 + 52 + } 53 + 54 + }
+9
src/applications/calendar/controller/PhabricatorCalendarEventViewController.php
··· 193 193 ->setWorkflow(true)); 194 194 } 195 195 196 + $export_uri = $this->getApplicationURI("event/export/{$id}/"); 197 + 198 + $curtain->addAction( 199 + id(new PhabricatorActionView()) 200 + ->setName(pht('Export as .ics')) 201 + ->setIcon('fa-download') 202 + ->setHref($export_uri) 203 + ->setWorkflow(true)); 204 + 196 205 return $curtain; 197 206 } 198 207
+37
src/applications/calendar/storage/PhabricatorCalendarEvent.php
··· 626 626 } 627 627 628 628 629 + public function newIntermediateEventNode() { 630 + $base_uri = new PhutilURI(PhabricatorEnv::getProductionURI('/')); 631 + $domain = $base_uri->getDomain(); 632 + 633 + $uid = $this->getPHID().'@'.$domain; 634 + 635 + $created = $this->getDateCreated(); 636 + $created = PhutilCalendarAbsoluteDateTime::newFromEpoch($created); 637 + 638 + $modified = $this->getDateModified(); 639 + $modified = PhutilCalendarAbsoluteDateTime::newFromEpoch($modified); 640 + 641 + $date_start = $this->getDateFrom(); 642 + $date_start = PhutilCalendarAbsoluteDateTime::newFromEpoch($date_start); 643 + 644 + $date_end = $this->getDateTo(); 645 + $date_end = PhutilCalendarAbsoluteDateTime::newFromEpoch($date_end); 646 + 647 + if ($this->getIsAllDay()) { 648 + $date_start->setIsAllDay(true); 649 + $date_end->setIsAllDay(true); 650 + } 651 + 652 + $node = id(new PhutilCalendarEventNode()) 653 + ->setUID($uid) 654 + ->setName($this->getName()) 655 + ->setDescription($this->getDescription()) 656 + ->setCreatedDateTime($created) 657 + ->setModifiedDateTime($modified) 658 + ->setStartDateTime($date_start) 659 + ->setEndDateTime($date_end); 660 + 661 + return $node; 662 + } 663 + 664 + 665 + 629 666 /* -( Markup Interface )--------------------------------------------------- */ 630 667 631 668