/** * Retrieves the user addressbooks IDs */ private function getAddressBooksIDsForUser() { $activeAddressbooksArray = $this->backend->getAddressBooksForUser('principals/users/' . $this->userUID); foreach ($activeAddressbooksArray as $activeAddressbook) { $activeAddressbooks[] = $activeAddressbook['id']; } return $activeAddressbooks; }
public function testSyncSupport() { // create a new address book $this->backend->createAddressBook(self::UNIT_TEST_USER, 'Example', []); $books = $this->backend->getAddressBooksForUser(self::UNIT_TEST_USER); $this->assertEquals(1, count($books)); $bookId = $books[0]['id']; // fist call without synctoken $changes = $this->backend->getChangesForAddressBook($bookId, '', 1); $syncToken = $changes['syncToken']; // add a change $uri0 = $this->getUniqueID('card'); $this->backend->createCard($bookId, $uri0, ''); // look for changes $changes = $this->backend->getChangesForAddressBook($bookId, $syncToken, 1); $this->assertEquals($uri0, $changes['added'][0]); }
public function testSharing() { $this->backend->createAddressBook(self::UNIT_TEST_USER, 'Example', []); $books = $this->backend->getAddressBooksForUser(self::UNIT_TEST_USER); $this->assertEquals(1, count($books)); $this->backend->updateShares('Example', [['href' => 'principal:principals/best-friend']], []); $shares = $this->backend->getShares('Example'); $this->assertEquals(1, count($shares)); // adding the same sharee again has no effect $this->backend->updateShares('Example', [['href' => 'principal:principals/best-friend']], []); $shares = $this->backend->getShares('Example'); $this->assertEquals(1, count($shares)); $books = $this->backend->getAddressBooksForUser('principals/best-friend'); $this->assertEquals(1, count($books)); $this->backend->updateShares('Example', [], [['href' => 'principal:principals/best-friend']]); $shares = $this->backend->getShares('Example'); $this->assertEquals(0, count($shares)); $books = $this->backend->getAddressBooksForUser('principals/best-friend'); $this->assertEquals(0, count($books)); }
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); } } }
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); } } } }