예제 #1
0
 public function render(Diary $diary)
 {
     $vcalendar = new VCalendar();
     $vcalendar->remove('PRODID');
     $vcalendar->add('PRODID', '-//Camdram//NONSGML Show Diary//EN');
     foreach ($diary->getEvents() as $event) {
         $start_time = null;
         $rrule = array();
         if ($event instanceof MultiDayEventInterface) {
             $start_time = new \DateTime($event->getStartDate()->format('Y-m-d') . ' ' . $event->getStartTime()->format('H:i:s'));
             $last_start_time = new \DateTime($event->getEndDate()->format('Y-m-d') . ' ' . $event->getStartTime()->format('H:i:s'));
             $rrule = 'FREQ=DAILY;UNTIL=' . $last_start_time->format('Ymd\\THis\\Z');
         } elseif ($event instanceof SingleDayEventInterface) {
             $start_time = new \DateTime($event->getDate() . ' ' . $event->getStartTime()->format('H:i:s'));
         }
         if ($start_time) {
             $utc = new \DateTimeZone('UTC');
             $start_time->setTimezone($utc);
             $end_time = clone $start_time;
             $end_time->modify('+2 hours');
             $dtstamp = clone $event->getUpdatedAt();
             $dtstamp->setTimezone($utc);
             $params = array('SUMMARY' => $event->getName(), 'LOCATION' => $event->getVenue(), 'UID' => $event->getUid(), 'DTSTAMP' => $dtstamp, 'DTSTART' => $start_time, 'DURATION' => 'PT2H00M00S', 'DESCRIPTION' => $event->getDescription());
             if ($rrule) {
                 $params['RRULE'] = $rrule;
             }
             $vcalendar->add('VEVENT', $params);
         }
     }
     return $vcalendar->serialize();
 }
예제 #2
0
 /**
  * Processes incoming REQUEST messages.
  *
  * This is message from an organizer, and is either a new event
  * invite, or an update to an existing one.
  *
  *
  * @param Message $itipMessage
  * @param VCalendar $existingObject
  * @return VCalendar|null
  */
 protected function processMessageRequest(Message $itipMessage, VCalendar $existingObject = null)
 {
     if (!$existingObject) {
         // This is a new invite, and we're just going to copy over
         // all the components from the invite.
         $existingObject = new VCalendar();
         foreach ($itipMessage->message->getComponents() as $component) {
             $existingObject->add(clone $component);
         }
     } else {
         // We need to update an existing object with all the new
         // information. We can just remove all existing components
         // and create new ones.
         foreach ($existingObject->getComponents() as $component) {
             $existingObject->remove($component);
         }
         foreach ($itipMessage->message->getComponents() as $component) {
             $existingObject->add(clone $component);
         }
     }
     return $existingObject;
 }
예제 #3
0
 /**
  * @expectedException InvalidArgumentException
  */
 function testRemoveNotFound()
 {
     $comp = new VCalendar(array(), false);
     $prop = $comp->createProperty('A', 'B');
     $comp->remove($prop);
 }