/** * As defined in Sabre_CalDAV_Backend_Abstract * * Creates a new calendar object from the given data. * * @param string $calendarId The id of the calendar. Equals to the id of the user it belongs to. * @param string $objectUri The uri that the new object should have. * @param string $calendarData The vobject data for the new calendar object. * * @return void */ public function createCalendarObject($calendarId, $objectUri, $calendarData) { $vcalendar = Sabre_VObject_Reader::read($calendarData); $event = new Calendar2_Models_Calendar2(); $event->fromVObject($vcalendar->vevent); $event->uri = $objectUri; $event->save(); }
/** * Test fromVObject with duration. */ public function testFromVObjectWithDuration() { $calendarData = <<<HERE BEGIN:VCALENDAR VERSION:2.0 CALSCALE:GREGORIAN PRODID:-//Pentabarf//Schedule//EN BEGIN:VEVENT DURATION:PT1H00M LOCATION:Saal 1 SEQUENCE:0 URL:http://events.ccc.de/congress/2011/Fahrplan/events/4816.en.html DTSTART;TZID=Europe/Berlin:20111229T160000 UID:4816@28C3@pentabarf.org DTSTAMP:20111206T185008 CATEGORIES:Lecture DESCRIPTION:Some Description SUMMARY:the summary is here STATUS:CONFIRMED END:VEVENT END:VCALENDAR HERE; $vcalendar = Sabre_VObject_Reader::read($calendarData); $model = new Calendar2_Models_Calendar2(); $model->fromVObject($vcalendar->vevent); $this->assertEquals('Saal 1', $model->location); $this->assertEquals('Some Description', $model->description); $this->assertEquals('the summary is here', $model->summary); $reflection = new ReflectionClass($model); $data = $reflection->getProperty('_data'); $data->setAccessible(true); $data = $data->getValue($model); // User timezone is utc in tests, so 1500 is correct $this->assertEquals('2011-12-29 15:00:00', $data['start']); $this->assertEquals('2011-12-29 16:00:00', $data['end']); }