Пример #1
0
 /**
  * @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);
         }
     }
 }
 protected function createTestCalendar()
 {
     $this->backend->createCalendar(self::UNIT_TEST_USER, 'Example', ['{http://apple.com/ns/ical/}calendar-color' => '#1C4587FF']);
     $calendars = $this->backend->getCalendarsForUser(self::UNIT_TEST_USER);
     $this->assertEquals(1, count($calendars));
     $this->assertEquals(self::UNIT_TEST_USER, $calendars[0]['principaluri']);
     /** @var SupportedCalendarComponentSet $components */
     $components = $calendars[0]['{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set'];
     $this->assertEquals(['VEVENT', 'VTODO'], $components->getValue());
     $color = $calendars[0]['{http://apple.com/ns/ical/}calendar-color'];
     $this->assertEquals('#1C4587FF', $color);
     $this->assertEquals('Example', $calendars[0]['uri']);
     $this->assertEquals('Example', $calendars[0]['{DAV:}displayname']);
     $calendarId = $calendars[0]['id'];
     return $calendarId;
 }
Пример #3
0
 public function postLogin($params)
 {
     $user = $this->userManager->get($params['uid']);
     $principal = 'principals/users/' . $user->getUID();
     $calendars = $this->calDav->getCalendarsForUser($principal);
     if (empty($calendars)) {
         try {
             $this->calDav->createCalendar($principal, 'default', []);
         } catch (\Exception $ex) {
             \OC::$server->getLogger()->logException($ex);
         }
     }
     $books = $this->cardDav->getAddressBooksForUser($principal);
     if (empty($books)) {
         try {
             $this->cardDav->createAddressBook($principal, 'default', []);
         } catch (\Exception $ex) {
             \OC::$server->getLogger()->logException($ex);
         }
     }
 }
Пример #4
0
 public function postLogin($params)
 {
     $user = $this->userManager->get($params['uid']);
     if (!is_null($user)) {
         $principal = 'principals/users/' . $user->getUID();
         $calendars = $this->calDav->getCalendarsForUser($principal);
         if (empty($calendars) || count($calendars) === 1 && $calendars[0]['uri'] === BirthdayService::BIRTHDAY_CALENDAR_URI) {
             try {
                 $this->calDav->createCalendar($principal, 'personal', ['{DAV:}displayname' => 'Personal']);
             } catch (\Exception $ex) {
                 \OC::$server->getLogger()->logException($ex);
             }
         }
         $books = $this->cardDav->getAddressBooksForUser($principal);
         if (empty($books)) {
             try {
                 $this->cardDav->createAddressBook($principal, 'contacts', ['{DAV:}displayname' => 'Contacts']);
             } catch (\Exception $ex) {
                 \OC::$server->getLogger()->logException($ex);
             }
         }
     }
 }