/** * @param IUser $user */ public function runForUser($user) { $principal = 'principals/users/' . $user->getUID(); $calendars = $this->calDavBackend->getCalendarsForUser($principal); foreach ($calendars as $calendar) { $objects = $this->calDavBackend->getCalendarObjects($calendar['id']); foreach ($objects as $object) { $calObject = $this->calDavBackend->getCalendarObject($calendar['id'], $object['uri']); $classification = $this->extractClassification($calObject['calendardata']); $this->calDavBackend->setClassification($object['id'], $classification); } } }
public function testCalendarObjectsOperations() { $calendarId = $this->createTestCalendar(); // create a card $uri = $this->getUniqueID('calobj'); $calData = <<<'EOD' BEGIN:VCALENDAR VERSION:2.0 PRODID:ownCloud Calendar BEGIN:VEVENT CREATED;VALUE=DATE-TIME:20130910T125139Z UID:47d15e3ec8 LAST-MODIFIED;VALUE=DATE-TIME:20130910T125139Z DTSTAMP;VALUE=DATE-TIME:20130910T125139Z SUMMARY:Test Event DTSTART;VALUE=DATE-TIME:20130912T130000Z DTEND;VALUE=DATE-TIME:20130912T140000Z CLASS:PUBLIC END:VEVENT END:VCALENDAR EOD; $this->backend->createCalendarObject($calendarId, $uri, $calData); // get all the cards $calendarObjects = $this->backend->getCalendarObjects($calendarId); $this->assertEquals(1, count($calendarObjects)); $this->assertEquals($calendarId, $calendarObjects[0]['calendarid']); // get the cards $calendarObject = $this->backend->getCalendarObject($calendarId, $uri); $this->assertNotNull($calendarObject); $this->assertArrayHasKey('id', $calendarObject); $this->assertArrayHasKey('uri', $calendarObject); $this->assertArrayHasKey('lastmodified', $calendarObject); $this->assertArrayHasKey('etag', $calendarObject); $this->assertArrayHasKey('size', $calendarObject); $this->assertEquals($calData, $calendarObject['calendardata']); // update the card $calData = <<<'EOD' BEGIN:VCALENDAR VERSION:2.0 PRODID:ownCloud Calendar BEGIN:VEVENT CREATED;VALUE=DATE-TIME:20130910T125139Z UID:47d15e3ec8 LAST-MODIFIED;VALUE=DATE-TIME:20130910T125139Z DTSTAMP;VALUE=DATE-TIME:20130910T125139Z SUMMARY:Test Event DTSTART;VALUE=DATE-TIME:20130912T130000Z DTEND;VALUE=DATE-TIME:20130912T140000Z END:VEVENT END:VCALENDAR EOD; $this->backend->updateCalendarObject($calendarId, $uri, $calData); $calendarObject = $this->backend->getCalendarObject($calendarId, $uri); $this->assertEquals($calData, $calendarObject['calendardata']); // delete the card $this->backend->deleteCalendarObject($calendarId, $uri); $calendarObjects = $this->backend->getCalendarObjects($calendarId); $this->assertEquals(0, count($calendarObjects)); }