private function newUpdateTransactions(PhabricatorCalendarEvent $event, PhutilCalendarEventNode $node)
 {
     $xactions = array();
     $uid = $node->getUID();
     if (!$event->getID()) {
         $xactions[] = id(new PhabricatorCalendarEventTransaction())->setTransactionType(PhabricatorTransactions::TYPE_CREATE)->setNewValue(true);
     }
     $name = $node->getName();
     if (!strlen($name)) {
         if (strlen($uid)) {
             $name = pht('Unnamed Event "%s"', $uid);
         } else {
             $name = pht('Unnamed Imported Event');
         }
     }
     $xactions[] = id(new PhabricatorCalendarEventTransaction())->setTransactionType(PhabricatorCalendarEventNameTransaction::TRANSACTIONTYPE)->setNewValue($name);
     $description = $node->getDescription();
     $xactions[] = id(new PhabricatorCalendarEventTransaction())->setTransactionType(PhabricatorCalendarEventDescriptionTransaction::TRANSACTIONTYPE)->setNewValue((string) $description);
     $is_recurring = (bool) $node->getRecurrenceRule();
     $xactions[] = id(new PhabricatorCalendarEventTransaction())->setTransactionType(PhabricatorCalendarEventRecurringTransaction::TRANSACTIONTYPE)->setNewValue($is_recurring);
     return $xactions;
 }
Esempio n. 2
0
 private function getEventNodeProperties(PhutilCalendarEventNode $event)
 {
     $properties = array();
     $uid = $event->getUID();
     if (!strlen($uid)) {
         throw new Exception(pht('Unable to write ICS document: event has no UID, but each event ' . 'MUST have a UID.'));
     }
     $properties[] = $this->newTextProperty('UID', $uid);
     $created = $event->getCreatedDateTime();
     if ($created) {
         $properties[] = $this->newDateTimeProperty('CREATED', $event->getCreatedDateTime());
     }
     $dtstamp = $event->getModifiedDateTime();
     if (!$dtstamp) {
         throw new Exception(pht('Unable to write ICS document: event has no modified time, but ' . 'each event MUST have a modified time.'));
     }
     $properties[] = $this->newDateTimeProperty('DTSTAMP', $dtstamp);
     $dtstart = $event->getStartDateTime();
     if ($dtstart) {
         $properties[] = $this->newDateTimeProperty('DTSTART', $dtstart);
     }
     $dtend = $event->getEndDateTime();
     if ($dtend) {
         $properties[] = $this->newDateTimeProperty('DTEND', $event->getEndDateTime());
     }
     $name = $event->getName();
     if (strlen($name)) {
         $properties[] = $this->newTextProperty('SUMMARY', $name);
     }
     $description = $event->getDescription();
     if (strlen($description)) {
         $properties[] = $this->newTextProperty('DESCRIPTION', $description);
     }
     $organizer = $event->getOrganizer();
     if ($organizer) {
         $properties[] = $this->newUserProperty('ORGANIZER', $organizer);
     }
     $attendees = $event->getAttendees();
     if ($attendees) {
         foreach ($attendees as $attendee) {
             $properties[] = $this->newUserProperty('ATTENDEE', $attendee);
         }
     }
     return $properties;
 }