diff --git a/.gitignore b/.gitignore
index 964701eea63ae..fa49588fad4b2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -22,6 +22,7 @@
!/apps/files_sharing
!/apps/files_trashbin
!/apps/files_versions
+!/apps/lookup_server_connector
!/apps/user_ldap
!/apps/provisioning_api
!/apps/systemtags
diff --git a/apps/dav/lib/AppInfo/Application.php b/apps/dav/lib/AppInfo/Application.php
index 844e0780ffb92..7c32fda8f5a7e 100644
--- a/apps/dav/lib/AppInfo/Application.php
+++ b/apps/dav/lib/AppInfo/Application.php
@@ -101,6 +101,12 @@ public function registerHooks() {
}
});
+ $dispatcher->addListener('OC\AccountManager::userUpdated', function(GenericEvent $event) {
+ $user = $event->getSubject();
+ $syncService = $this->getContainer()->query(SyncService::class);
+ $syncService->updateUser($user);
+ });
+
$dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::createCalendar', function(GenericEvent $event) {
/** @var Backend $backend */
$backend = $this->getContainer()->query(Backend::class);
diff --git a/apps/dav/lib/CardDAV/Converter.php b/apps/dav/lib/CardDAV/Converter.php
index d1fb754017e17..065c5494ec38f 100644
--- a/apps/dav/lib/CardDAV/Converter.php
+++ b/apps/dav/lib/CardDAV/Converter.php
@@ -22,6 +22,7 @@
namespace OCA\DAV\CardDAV;
+use OC\Accounts\AccountManager;
use OCP\IImage;
use OCP\IUser;
use Sabre\VObject\Component\VCard;
@@ -29,109 +30,76 @@
class Converter {
+ /** @var AccountManager */
+ private $accountManager;
+
/**
- * @param IUser $user
- * @return VCard
+ * Converter constructor.
+ *
+ * @param AccountManager $accountManager
*/
- public function createCardFromUser(IUser $user) {
-
- $uid = $user->getUID();
- $displayName = $user->getDisplayName();
- $displayName = empty($displayName ) ? $uid : $displayName;
- $emailAddress = $user->getEMailAddress();
- $cloudId = $user->getCloudId();
- $image = $this->getAvatarImage($user);
-
- $vCard = new VCard();
- $vCard->VERSION = '3.0';
- $vCard->UID = $uid;
- if (!empty($displayName)) {
- $vCard->FN = $displayName;
- $vCard->N = $this->splitFullName($displayName);
- }
- if (!empty($emailAddress)) {
- $vCard->add(new Text($vCard, 'EMAIL', $emailAddress, ['TYPE' => 'OTHER']));
- }
- if (!empty($cloudId)) {
- $vCard->CLOUD = $cloudId;
- }
- if ($image) {
- $vCard->add('PHOTO', $image->data(), ['ENCODING' => 'b', 'TYPE' => $image->mimeType()]);
- }
- $vCard->validate();
-
- return $vCard;
+ public function __construct(AccountManager $accountManager) {
+ $this->accountManager = $accountManager;
}
/**
- * @param VCard $vCard
* @param IUser $user
- * @return bool
+ * @return VCard|null
*/
- public function updateCard(VCard $vCard, IUser $user) {
+ public function createCardFromUser(IUser $user) {
+
+ $userData = $this->accountManager->getUser($user);
+
$uid = $user->getUID();
- $displayName = $user->getDisplayName();
- $displayName = empty($displayName ) ? $uid : $displayName;
- $emailAddress = $user->getEMailAddress();
$cloudId = $user->getCloudId();
$image = $this->getAvatarImage($user);
- $updated = false;
- if($this->propertyNeedsUpdate($vCard, 'FN', $displayName)) {
- $vCard->FN = new Text($vCard, 'FN', $displayName);
- unset($vCard->N);
- $vCard->add(new Text($vCard, 'N', $this->splitFullName($displayName)));
- $updated = true;
- }
- if($this->propertyNeedsUpdate($vCard, 'EMAIL', $emailAddress)) {
- $vCard->EMAIL = new Text($vCard, 'EMAIL', $emailAddress);
- $updated = true;
- }
- if($this->propertyNeedsUpdate($vCard, 'CLOUD', $cloudId)) {
- $vCard->CLOUD = new Text($vCard, 'CLOUD', $cloudId);
- $updated = true;
- }
-
- if($this->propertyNeedsUpdate($vCard, 'PHOTO', $image)) {
- unset($vCard->PHOTO);
- $vCard->add('PHOTO', $image->data(), ['ENCODING' => 'b', 'TYPE' => $image->mimeType()]);
- $updated = true;
- }
-
- if (empty($emailAddress) && !is_null($vCard->EMAIL)) {
- unset($vCard->EMAIL);
- $updated = true;
- }
- if (empty($cloudId) && !is_null($vCard->CLOUD)) {
- unset($vCard->CLOUD);
- $updated = true;
- }
- if (empty($image) && !is_null($vCard->PHOTO)) {
- unset($vCard->PHOTO);
- $updated = true;
+ $vCard = new VCard();
+ $vCard->add(new Text($vCard, 'UID', $uid));
+
+ $publish = false;
+
+ foreach ($userData as $property => $value) {
+ if ($value['scope'] === AccountManager::VISIBILITY_CONTACTS_ONLY ||
+ $value['scope'] === AccountManager::VISIBILITY_PUBLIC
+ ) {
+ $publish = true;
+ switch ($property) {
+ case AccountManager::PROPERTY_DISPLAYNAME:
+ $vCard->add(new Text($vCard, 'FN', $value['value']));
+ $vCard->add(new Text($vCard, 'N', $this->splitFullName($value['value'])));
+ break;
+ case AccountManager::PROPERTY_AVATAR:
+ if ($image !== null) {
+ $vCard->add('PHOTO', $image->data(), ['ENCODING' => 'b', 'TYPE' => $image->mimeType()]);
+ }
+ break;
+ case AccountManager::PROPERTY_EMAIL:
+ $vCard->add(new Text($vCard, 'EMAIL', $value['value'], ['TYPE' => 'OTHER']));
+ break;
+ case AccountManager::PROPERTY_WEBSITE:
+ $vCard->add(new Text($vCard, 'URL', $value['value']));
+ break;
+ case AccountManager::PROPERTY_PHONE:
+ $vCard->add(new Text($vCard, 'TEL', $value['value'], ['TYPE' => 'OTHER']));
+ break;
+ case AccountManager::PROPERTY_ADDRESS:
+ $vCard->add(new Text($vCard, 'ADR', $value['value'], ['TYPE' => 'OTHER']));
+ break;
+ case AccountManager::PROPERTY_TWITTER:
+ $vCard->add(new Text($vCard, 'X-SOCIALPROFILE', $value['value'], ['TYPE' => 'TWITTER']));
+ break;
+ }
+ }
}
- return $updated;
- }
-
- /**
- * @param VCard $vCard
- * @param string $name
- * @param string|IImage $newValue
- * @return bool
- */
- private function propertyNeedsUpdate(VCard $vCard, $name, $newValue) {
- if (is_null($newValue)) {
- return false;
+ if ($publish && !empty($cloudId)) {
+ $vCard->add(new Text($vCard, 'CLOUD', $cloudId));
+ $vCard->validate();
+ return $vCard;
}
- $value = $vCard->__get($name);
- if (!is_null($value)) {
- $value = $value->getValue();
- $newValue = $newValue instanceof IImage ? $newValue->data() : $newValue;
- return $value !== $newValue;
- }
- return true;
+ return null;
}
/**
diff --git a/apps/dav/lib/CardDAV/SyncService.php b/apps/dav/lib/CardDAV/SyncService.php
index 1ad37da6bfe4b..1293d8ae8a005 100644
--- a/apps/dav/lib/CardDAV/SyncService.php
+++ b/apps/dav/lib/CardDAV/SyncService.php
@@ -24,6 +24,7 @@
namespace OCA\DAV\CardDAV;
+use OC\Accounts\AccountManager;
use OCP\AppFramework\Http;
use OCP\ILogger;
use OCP\IUser;
@@ -48,10 +49,22 @@ class SyncService {
/** @var array */
private $localSystemAddressBook;
- public function __construct(CardDavBackend $backend, IUserManager $userManager, ILogger $logger) {
+ /** @var AccountManager */
+ private $accountManager;
+
+ /**
+ * SyncService constructor.
+ *
+ * @param CardDavBackend $backend
+ * @param IUserManager $userManager
+ * @param ILogger $logger
+ * @param AccountManager $accountManager
+ */
+ public function __construct(CardDavBackend $backend, IUserManager $userManager, ILogger $logger, AccountManager $accountManager) {
$this->backend = $backend;
$this->userManager = $userManager;
$this->logger = $logger;
+ $this->accountManager = $accountManager;
}
/**
@@ -215,7 +228,7 @@ private function parseMultiStatus($body) {
public function updateUser($user) {
$systemAddressBook = $this->getLocalSystemAddressBook();
$addressBookId = $systemAddressBook['id'];
- $converter = new Converter();
+ $converter = new Converter($this->accountManager);
$name = $user->getBackendClassName();
$userId = $user->getUID();
@@ -223,10 +236,14 @@ public function updateUser($user) {
$card = $this->backend->getCard($addressBookId, $cardId);
if ($card === false) {
$vCard = $converter->createCardFromUser($user);
- $this->backend->createCard($addressBookId, $cardId, $vCard->serialize());
+ if ($vCard !== null) {
+ $this->backend->createCard($addressBookId, $cardId, $vCard->serialize());
+ }
} else {
- $vCard = Reader::read($card['carddata']);
- if ($converter->updateCard($vCard, $user)) {
+ $vCard = $converter->createCardFromUser($user);
+ if (is_null($vCard)) {
+ $this->backend->deleteCard($addressBookId, $cardId);
+ } else {
$this->backend->updateCard($addressBookId, $cardId, $vCard->serialize());
}
}
diff --git a/apps/dav/lib/HookManager.php b/apps/dav/lib/HookManager.php
index 247d4b291af15..26f3895a45986 100644
--- a/apps/dav/lib/HookManager.php
+++ b/apps/dav/lib/HookManager.php
@@ -27,6 +27,8 @@
use OCP\IUser;
use OCP\IUserManager;
use OCP\Util;
+use Symfony\Component\EventDispatcher\EventDispatcher;
+use Symfony\Component\EventDispatcher\GenericEvent;
class HookManager {
@@ -51,14 +53,19 @@ class HookManager {
/** @var array */
private $addressBooksToDelete;
+ /** @var EventDispatcher */
+ private $eventDispatcher;
+
public function __construct(IUserManager $userManager,
SyncService $syncService,
CalDavBackend $calDav,
- CardDavBackend $cardDav) {
+ CardDavBackend $cardDav,
+ EventDispatcher $eventDispatcher) {
$this->userManager = $userManager;
$this->syncService = $syncService;
$this->calDav = $calDav;
$this->cardDav = $cardDav;
+ $this->eventDispatcher = $eventDispatcher;
}
public function setup() {
diff --git a/apps/dav/tests/unit/CardDAV/ConverterTest.php b/apps/dav/tests/unit/CardDAV/ConverterTest.php
index 7737b999507e4..737bbd96aaafb 100644
--- a/apps/dav/tests/unit/CardDAV/ConverterTest.php
+++ b/apps/dav/tests/unit/CardDAV/ConverterTest.php
@@ -24,79 +24,121 @@
namespace OCA\DAV\Tests\unit\CardDAV;
+use OC\Accounts\AccountManager;
use OCA\DAV\CardDAV\Converter;
+use OCP\IDBConnection;
use OCP\IImage;
use OCP\IUser;
+use OpenCloud\ObjectStore\Resource\Account;
use PHPUnit_Framework_MockObject_MockObject;
+use Symfony\Component\EventDispatcher\EventDispatcher;
use Test\TestCase;
class ConverterTest extends TestCase {
- /**
- * @dataProvider providesNewUsers
- */
- public function testCreation($expectedVCard, $displayName = null, $eMailAddress = null, $cloudId = null) {
- $user = $this->getUserMock($displayName, $eMailAddress, $cloudId);
+ /** @var AccountManager | PHPUnit_Framework_MockObject_MockObject */
+ private $accountManager;
- $converter = new Converter();
- $vCard = $converter->createCardFromUser($user);
- $cardData = $vCard->serialize();
+ /** @var EventDispatcher | PHPUnit_Framework_MockObject_MockObject */
+ private $eventDispatcher;
- $this->assertEquals($expectedVCard, $cardData);
- }
+ /** @var IDBConnection | PHPUnit_Framework_MockObject_MockObject */
+ private $databaseConnection;
- public function providesNewUsers() {
- return [
- ["BEGIN:VCARD\r\nVERSION:3.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.1//EN\r\nUID:12345\r\nFN:12345\r\nN:12345;;;;\r\nPHOTO;ENCODING=b;TYPE=JPEG:MTIzNDU2Nzg5\r\nEND:VCARD\r\n"],
- ["BEGIN:VCARD\r\nVERSION:3.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.1//EN\r\nUID:12345\r\nFN:Dr. Foo Bar\r\nN:Bar;Dr.;Foo;;\r\nPHOTO;ENCODING=b;TYPE=JPEG:MTIzNDU2Nzg5\r\nEND:VCARD\r\n", "Dr. Foo Bar"],
- ["BEGIN:VCARD\r\nVERSION:3.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.1//EN\r\nUID:12345\r\nFN:Dr. Foo Bar\r\nN:Bar;Dr.;Foo;;\r\nEMAIL;TYPE=OTHER:foo@bar.net\r\nPHOTO;ENCODING=b;TYPE=JPEG:MTIzNDU2Nzg5\r\nEND:VCARD\r\n", "Dr. Foo Bar", "foo@bar.net"],
- ["BEGIN:VCARD\r\nVERSION:3.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.1//EN\r\nUID:12345\r\nFN:Dr. Foo Bar\r\nN:Bar;Dr.;Foo;;\r\nCLOUD:foo@bar.net\r\nPHOTO;ENCODING=b;TYPE=JPEG:MTIzNDU2Nzg5\r\nEND:VCARD\r\n", "Dr. Foo Bar", null, "foo@bar.net"],
- ];
+ public function setUp() {
+ parent::setUp();
+ $this->databaseConnection = $this->getMockBuilder('OCP\IDBConnection')->getMock();
+ $this->eventDispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
+ ->disableOriginalConstructor()->getMock();
+ $this->accountManager = $this->getMockBuilder('OC\Accounts\AccountManager')
+ ->disableOriginalConstructor()->getMock();
}
- /**
- * @dataProvider providesNewUsers
- */
- public function testUpdateOfUnchangedUser($expectedVCard, $displayName = null, $eMailAddress = null, $cloudId = null) {
- $user = $this->getUserMock($displayName, $eMailAddress, $cloudId);
-
- $converter = new Converter();
- $vCard = $converter->createCardFromUser($user);
- $updated = $converter->updateCard($vCard, $user);
- $this->assertFalse($updated);
- $cardData = $vCard->serialize();
-
- $this->assertEquals($expectedVCard, $cardData);
+ public function getAccountManager(IUser $user) {
+ $accountManager = $this->getMockBuilder('OC\Accounts\AccountManager')
+ ->disableOriginalConstructor()->getMock();
+ $accountManager->expects($this->any())->method('getUser')->willReturn(
+ [
+ AccountManager::PROPERTY_DISPLAYNAME =>
+ [
+ 'value' => $user->getDisplayName(),
+ 'scope' => AccountManager::VISIBILITY_CONTACTS_ONLY,
+ ],
+ AccountManager::PROPERTY_ADDRESS =>
+ [
+ 'value' => '',
+ 'scope' => AccountManager::VISIBILITY_PRIVATE,
+ ],
+ AccountManager::PROPERTY_WEBSITE =>
+ [
+ 'value' => '',
+ 'scope' => AccountManager::VISIBILITY_PRIVATE,
+ ],
+ AccountManager::PROPERTY_EMAIL =>
+ [
+ 'value' => $user->getEMailAddress(),
+ 'scope' => AccountManager::VISIBILITY_CONTACTS_ONLY,
+ ],
+ AccountManager::PROPERTY_AVATAR =>
+ [
+ 'scope' => AccountManager::VISIBILITY_CONTACTS_ONLY
+ ],
+ AccountManager::PROPERTY_PHONE =>
+ [
+ 'value' => '',
+ 'scope' => AccountManager::VISIBILITY_PRIVATE,
+ ],
+ AccountManager::PROPERTY_TWITTER =>
+ [
+ 'value' => '',
+ 'scope' => AccountManager::VISIBILITY_PRIVATE,
+ ],
+ ]
+ );
+
+ return $accountManager;
}
/**
- * @dataProvider providesUsersForUpdateOfRemovedElement
+ * @dataProvider providesNewUsers
*/
- public function testUpdateOfRemovedElement($expectedVCard, $displayName = null, $eMailAddress = null, $cloudId = null) {
+ public function testCreation($expectedVCard, $displayName = null, $eMailAddress = null, $cloudId = null) {
$user = $this->getUserMock($displayName, $eMailAddress, $cloudId);
+ $accountManager = $this->getAccountManager($user);
- $converter = new Converter();
+ $converter = new Converter($accountManager);
$vCard = $converter->createCardFromUser($user);
+ if ($expectedVCard !== null) {
+ $this->assertInstanceOf('Sabre\VObject\Component\VCard', $vCard);
+ $cardData = $vCard->jsonSerialize();
+ $this->compareData($expectedVCard, $cardData);
- $user1 = $this->getMockBuilder('OCP\IUser')->disableOriginalConstructor()->getMock();
- $user1->method('getUID')->willReturn('12345');
- $user1->method('getDisplayName')->willReturn(null);
- $user1->method('getEMailAddress')->willReturn(null);
- $user1->method('getCloudId')->willReturn(null);
- $user1->method('getAvatarImage')->willReturn(null);
+ } else {
+ $this->assertSame($expectedVCard, $vCard);
+ }
- $updated = $converter->updateCard($vCard, $user1);
- $this->assertTrue($updated);
- $cardData = $vCard->serialize();
+ }
- $this->assertEquals($expectedVCard, $cardData);
+ protected function compareData($expected, $data) {
+ foreach ($expected as $key => $value) {
+ $found = false;
+ foreach ($data[1] as $d) {
+ if($d[0] === $key && $d[3] === $value) {
+ $found = true;
+ break;
+ }
+ }
+ if (!$found) $this->assertTrue(false, 'Expected data: ' . $key . ' not found.');
+ }
}
- public function providesUsersForUpdateOfRemovedElement() {
+ public function providesNewUsers() {
return [
- ["BEGIN:VCARD\r\nVERSION:3.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.1//EN\r\nUID:12345\r\nFN:12345\r\nN:12345;;;;\r\nEND:VCARD\r\n", "Dr. Foo Bar"],
- ["BEGIN:VCARD\r\nVERSION:3.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.1//EN\r\nUID:12345\r\nFN:12345\r\nN:12345;;;;\r\nEND:VCARD\r\n", "Dr. Foo Bar", "foo@bar.net"],
- ["BEGIN:VCARD\r\nVERSION:3.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.1//EN\r\nUID:12345\r\nFN:12345\r\nN:12345;;;;\r\nEND:VCARD\r\n", "Dr. Foo Bar", null, "foo@bar.net"],
+ [null],
+ [null, null, 'foo@bar.net'],
+ [['cloud' => 'foo@cloud.net', 'email' => 'foo@bar.net'], null, 'foo@bar.net', 'foo@cloud.net'],
+ [['cloud' => 'foo@cloud.net', 'email' => 'foo@bar.net', 'fn' => 'Dr. Foo Bar'], "Dr. Foo Bar", "foo@bar.net", 'foo@cloud.net'],
+ [['cloud' => 'foo@cloud.net', 'fn' => 'Dr. Foo Bar'], "Dr. Foo Bar", null, "foo@cloud.net"],
];
}
@@ -107,7 +149,7 @@ public function providesUsersForUpdateOfRemovedElement() {
*/
public function testNameSplitter($expected, $fullName) {
- $converter = new Converter();
+ $converter = new Converter($this->accountManager);
$r = $converter->splitFullName($fullName);
$r = implode(';', $r);
$this->assertEquals($expected, $r);
diff --git a/apps/dav/tests/unit/CardDAV/SyncServiceTest.php b/apps/dav/tests/unit/CardDAV/SyncServiceTest.php
index e6a5ac1f16ab9..68345def66b85 100644
--- a/apps/dav/tests/unit/CardDAV/SyncServiceTest.php
+++ b/apps/dav/tests/unit/CardDAV/SyncServiceTest.php
@@ -25,6 +25,7 @@
namespace OCA\DAV\Tests\unit\CardDAV;
+use OC\Accounts\AccountManager;
use OCA\DAV\CardDAV\CardDavBackend;
use OCA\DAV\CardDAV\SyncService;
use OCP\IUser;
@@ -76,7 +77,8 @@ public function testEnsureSystemAddressBookExists() {
/** @var IUserManager $userManager */
$userManager = $this->getMockBuilder('OCP\IUserManager')->disableOriginalConstructor()->getMock();
$logger = $this->getMockBuilder('OCP\ILogger')->disableOriginalConstructor()->getMock();
- $ss = new SyncService($backend, $userManager, $logger);
+ $accountManager = $this->getMockBuilder('OC\Accounts\AccountManager')->disableOriginalConstructor()->getMock();
+ $ss = new SyncService($backend, $userManager, $logger, $accountManager);
$book = $ss->ensureSystemAddressBookExists('principals/users/adam', 'contacts', []);
}
@@ -100,8 +102,47 @@ public function testUpdateAndDeleteUser() {
$user = $this->getMockBuilder('OCP\IUser')->disableOriginalConstructor()->getMock();
$user->method('getBackendClassName')->willReturn('unittest');
$user->method('getUID')->willReturn('test-user');
-
- $ss = new SyncService($backend, $userManager, $logger);
+ $user->method('getCloudId')->willReturn('cloudId');
+ $accountManager = $this->getMockBuilder('OC\Accounts\AccountManager')->disableOriginalConstructor()->getMock();
+ $accountManager->expects($this->any())->method('getUser')
+ ->willReturn([
+ AccountManager::PROPERTY_DISPLAYNAME =>
+ [
+ 'value' => $user->getDisplayName(),
+ 'scope' => AccountManager::VISIBILITY_CONTACTS_ONLY,
+ ],
+ AccountManager::PROPERTY_ADDRESS =>
+ [
+ 'value' => '',
+ 'scope' => AccountManager::VISIBILITY_PRIVATE,
+ ],
+ AccountManager::PROPERTY_WEBSITE =>
+ [
+ 'value' => '',
+ 'scope' => AccountManager::VISIBILITY_PRIVATE,
+ ],
+ AccountManager::PROPERTY_EMAIL =>
+ [
+ 'value' => $user->getEMailAddress(),
+ 'scope' => AccountManager::VISIBILITY_CONTACTS_ONLY,
+ ],
+ AccountManager::PROPERTY_AVATAR =>
+ [
+ 'scope' => AccountManager::VISIBILITY_CONTACTS_ONLY
+ ],
+ AccountManager::PROPERTY_PHONE =>
+ [
+ 'value' => '',
+ 'scope' => AccountManager::VISIBILITY_PRIVATE,
+ ],
+ AccountManager::PROPERTY_TWITTER =>
+ [
+ 'value' => '',
+ 'scope' => AccountManager::VISIBILITY_PRIVATE,
+ ],
+ ]);
+
+ $ss = new SyncService($backend, $userManager, $logger, $accountManager);
$ss->updateUser($user);
$user->method('getDisplayName')->willReturn('A test user for unit testing');
@@ -135,10 +176,11 @@ private function getBackendMock($createCount, $updateCount, $deleteCount) {
private function getSyncServiceMock($backend, $response) {
$userManager = $this->getMockBuilder('OCP\IUserManager')->disableOriginalConstructor()->getMock();
$logger = $this->getMockBuilder('OCP\ILogger')->disableOriginalConstructor()->getMock();
+ $accountManager = $this->getMockBuilder('OC\Accounts\AccountManager')->disableOriginalConstructor()->getMock();
/** @var SyncService | \PHPUnit_Framework_MockObject_MockObject $ss */
$ss = $this->getMockBuilder(SyncService::class)
->setMethods(['ensureSystemAddressBookExists', 'requestSyncReport', 'download'])
- ->setConstructorArgs([$backend, $userManager, $logger])
+ ->setConstructorArgs([$backend, $userManager, $logger, $accountManager])
->getMock();
$ss->method('requestSyncReport')->withAnyParameters()->willReturn(['response' => $response, 'token' => 'sync-token-1']);
$ss->method('ensureSystemAddressBookExists')->willReturn(['id' => 1]);
diff --git a/apps/dav/tests/unit/DAV/HookManagerTest.php b/apps/dav/tests/unit/DAV/HookManagerTest.php
index f980e595bf917..9579ce1c6d3f0 100644
--- a/apps/dav/tests/unit/DAV/HookManagerTest.php
+++ b/apps/dav/tests/unit/DAV/HookManagerTest.php
@@ -31,14 +31,19 @@
use OCP\IL10N;
use OCP\IUser;
use OCP\IUserManager;
+use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Test\TestCase;
class HookManagerTest extends TestCase {
/** @var IL10N */
private $l10n;
+ /** @var EventDispatcher | \PHPUnit_Framework_MockObject_MockObject */
+ private $eventDispatcher;
+
public function setUp() {
parent::setUp();
+ $this->eventDispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')->disableOriginalConstructor()->getMock();
$this->l10n = $this->createMock(IL10N::class);
$this->l10n
->expects($this->any())
@@ -82,7 +87,7 @@ public function test() {
'principals/users/newUser',
'contacts', ['{DAV:}displayname' => 'Contacts']);
- $hm = new HookManager($userManager, $syncService, $cal, $card);
+ $hm = new HookManager($userManager, $syncService, $cal, $card, $this->eventDispatcher);
$hm->firstLogin($user);
}
@@ -116,7 +121,7 @@ public function testWithExisting() {
$card->expects($this->once())->method('getAddressBooksForUserCount')->willReturn(1);
$card->expects($this->never())->method('createAddressBook');
- $hm = new HookManager($userManager, $syncService, $cal, $card);
+ $hm = new HookManager($userManager, $syncService, $cal, $card, $this->eventDispatcher);
$hm->firstLogin($user);
}
@@ -154,7 +159,7 @@ public function testWithBirthdayCalendar() {
'principals/users/newUser',
'contacts', ['{DAV:}displayname' => 'Contacts']);
- $hm = new HookManager($userManager, $syncService, $cal, $card);
+ $hm = new HookManager($userManager, $syncService, $cal, $card, $this->eventDispatcher);
$hm->firstLogin($user);
}
@@ -195,7 +200,7 @@ public function testDeleteCalendar() {
]);
$card->expects($this->once())->method('deleteAddressBook');
- $hm = new HookManager($userManager, $syncService, $cal, $card, $this->l10n);
+ $hm = new HookManager($userManager, $syncService, $cal, $card, $this->eventDispatcher);
$hm->preDeleteUser(['uid' => 'newUser']);
$hm->postDeleteUser(['uid' => 'newUser']);
}
diff --git a/apps/federatedfilesharing/lib/FederatedShareProvider.php b/apps/federatedfilesharing/lib/FederatedShareProvider.php
index 6481abe32e2c6..61f1b1c8f186e 100644
--- a/apps/federatedfilesharing/lib/FederatedShareProvider.php
+++ b/apps/federatedfilesharing/lib/FederatedShareProvider.php
@@ -943,4 +943,14 @@ public function isIncomingServer2serverShareEnabled() {
$result = $this->config->getAppValue('files_sharing', 'incoming_server2server_share_enabled', 'yes');
return ($result === 'yes') ? true : false;
}
+
+ /**
+ * Check if querying sharees on the lookup server is enabled
+ *
+ * @return bool
+ */
+ public function isLookupServerQueriesEnabled() {
+ $result = $this->config->getAppValue('files_sharing', 'lookupServerEnabled', 'no');
+ return ($result === 'yes') ? true : false;
+ }
}
diff --git a/apps/federatedfilesharing/lib/Settings/Admin.php b/apps/federatedfilesharing/lib/Settings/Admin.php
index 64619e329f371..20ff6ae6f4a62 100644
--- a/apps/federatedfilesharing/lib/Settings/Admin.php
+++ b/apps/federatedfilesharing/lib/Settings/Admin.php
@@ -43,6 +43,7 @@ public function getForm() {
$parameters = [
'outgoingServer2serverShareEnabled' => $this->fedShareProvider->isOutgoingServer2serverShareEnabled(),
'incomingServer2serverShareEnabled' => $this->fedShareProvider->isIncomingServer2serverShareEnabled(),
+ 'lookupServerEnabled' => $this->fedShareProvider->isLookupServerQueriesEnabled(),
];
return new TemplateResponse('federatedfilesharing', 'settings-admin', $parameters, '');
diff --git a/apps/federatedfilesharing/templates/settings-admin.php b/apps/federatedfilesharing/templates/settings-admin.php
index 3ffd4bd5b2750..0670553e06112 100644
--- a/apps/federatedfilesharing/templates/settings-admin.php
+++ b/apps/federatedfilesharing/templates/settings-admin.php
@@ -25,4 +25,11 @@
t('Allow users on this server to receive shares from other servers'));?>
+ />
+
+
{{displayName}}
' +
+ '