mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-18 12:52:42 +01:00
Export ORGANIZER and ATTENDEE sections in ".ics" files from Calendar
Summary: Ref T10747. This exports these sections when generating an ".ics" file. Test Plan: {F1832214} Reviewers: chad Reviewed By: chad Maniphest Tasks: T10747 Differential Revision: https://secure.phabricator.com/D16558
This commit is contained in:
parent
2e1c7da1bf
commit
96f800249b
2 changed files with 58 additions and 3 deletions
|
@ -22,7 +22,7 @@ final class PhabricatorCalendarEventExportController
|
|||
if ($request->isFormPost()) {
|
||||
$file_name = $event->getMonogram().'.ics';
|
||||
|
||||
$event_node = $event->newIntermediateEventNode();
|
||||
$event_node = $event->newIntermediateEventNode($viewer);
|
||||
|
||||
$document_node = id(new PhutilCalendarDocumentNode())
|
||||
->appendChild($event_node);
|
||||
|
|
|
@ -626,7 +626,7 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO
|
|||
}
|
||||
|
||||
|
||||
public function newIntermediateEventNode() {
|
||||
public function newIntermediateEventNode(PhabricatorUser $viewer) {
|
||||
$base_uri = new PhutilURI(PhabricatorEnv::getProductionURI('/'));
|
||||
$domain = $base_uri->getDomain();
|
||||
|
||||
|
@ -649,6 +649,59 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO
|
|||
$date_end->setIsAllDay(true);
|
||||
}
|
||||
|
||||
$host_phid = $this->getHostPHID();
|
||||
|
||||
$invitees = $this->getInvitees();
|
||||
foreach ($invitees as $key => $invitee) {
|
||||
if ($invitee->isUninvited()) {
|
||||
unset($invitees[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
$phids = array();
|
||||
$phids[] = $host_phid;
|
||||
foreach ($invitees as $invitee) {
|
||||
$phids[] = $invitee->getInviteePHID();
|
||||
}
|
||||
|
||||
$handles = $viewer->loadHandles($phids);
|
||||
|
||||
$host_handle = $handles[$host_phid];
|
||||
$host_name = $host_handle->getFullName();
|
||||
$host_uri = $host_handle->getURI();
|
||||
$host_uri = PhabricatorEnv::getURI($host_uri);
|
||||
|
||||
$organizer = id(new PhutilCalendarUserNode())
|
||||
->setName($host_name)
|
||||
->setURI($host_uri);
|
||||
|
||||
$attendees = array();
|
||||
foreach ($invitees as $invitee) {
|
||||
$invitee_phid = $invitee->getInviteePHID();
|
||||
$invitee_handle = $handles[$invitee_phid];
|
||||
$invitee_name = $invitee_handle->getFullName();
|
||||
$invitee_uri = $invitee_handle->getURI();
|
||||
$invitee_uri = PhabricatorEnv::getURI($invitee_uri);
|
||||
|
||||
switch ($invitee->getStatus()) {
|
||||
case PhabricatorCalendarEventInvitee::STATUS_ATTENDING:
|
||||
$status = PhutilCalendarUserNode::STATUS_ACCEPTED;
|
||||
break;
|
||||
case PhabricatorCalendarEventInvitee::STATUS_DECLINED:
|
||||
$status = PhutilCalendarUserNode::STATUS_DECLINED;
|
||||
break;
|
||||
case PhabricatorCalendarEventInvitee::STATUS_INVITED:
|
||||
default:
|
||||
$status = PhutilCalendarUserNode::STATUS_INVITED;
|
||||
break;
|
||||
}
|
||||
|
||||
$attendees[] = id(new PhutilCalendarUserNode())
|
||||
->setName($invitee_name)
|
||||
->setURI($invitee_uri)
|
||||
->setStatus($status);
|
||||
}
|
||||
|
||||
$node = id(new PhutilCalendarEventNode())
|
||||
->setUID($uid)
|
||||
->setName($this->getName())
|
||||
|
@ -656,7 +709,9 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO
|
|||
->setCreatedDateTime($created)
|
||||
->setModifiedDateTime($modified)
|
||||
->setStartDateTime($date_start)
|
||||
->setEndDateTime($date_end);
|
||||
->setEndDateTime($date_end)
|
||||
->setOrganizer($organizer)
|
||||
->setAttendees($attendees);
|
||||
|
||||
return $node;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue