diff --git a/.gitignore b/.gitignore
index 964701eea6..fa49588fad 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 844e0780ff..7c32fda8f5 100644
--- a/apps/dav/lib/AppInfo/Application.php
+++ b/apps/dav/lib/AppInfo/Application.php
@@ -101,6 +101,12 @@ class Application extends App {
}
});
+ $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 d1fb754017..065c5494ec 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 @@ use Sabre\VObject\Property\Text;
class Converter {
+ /** @var AccountManager */
+ private $accountManager;
+
+ /**
+ * Converter constructor.
+ *
+ * @param AccountManager $accountManager
+ */
+ public function __construct(AccountManager $accountManager) {
+ $this->accountManager = $accountManager;
+ }
+
/**
* @param IUser $user
- * @return VCard
+ * @return VCard|null
*/
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);
$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();
+ $vCard->add(new Text($vCard, 'UID', $uid));
- return $vCard;
- }
+ $publish = false;
- /**
- * @param VCard $vCard
- * @param IUser $user
- * @return bool
- */
- public function updateCard(VCard $vCard, IUser $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;
+ 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;
+ }
+ }
}
- if($this->propertyNeedsUpdate($vCard, 'PHOTO', $image)) {
- unset($vCard->PHOTO);
- $vCard->add('PHOTO', $image->data(), ['ENCODING' => 'b', 'TYPE' => $image->mimeType()]);
- $updated = true;
+ if ($publish && !empty($cloudId)) {
+ $vCard->add(new Text($vCard, 'CLOUD', $cloudId));
+ $vCard->validate();
+ return $vCard;
}
- 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;
- }
-
- 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;
- }
- $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 1ad37da6bf..1293d8ae8a 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 @@ class SyncService {
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 @@ class SyncService {
$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 247d4b291a..26f3895a45 100644
--- a/apps/dav/lib/HookManager.php
+++ b/apps/dav/lib/HookManager.php
@@ -27,6 +27,8 @@ use OCA\DAV\CardDAV\SyncService;
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 7737b99950..737bbd96aa 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 {
+ /** @var AccountManager | PHPUnit_Framework_MockObject_MockObject */
+ private $accountManager;
+
+ /** @var EventDispatcher | PHPUnit_Framework_MockObject_MockObject */
+ private $eventDispatcher;
+
+ /** @var IDBConnection | PHPUnit_Framework_MockObject_MockObject */
+ private $databaseConnection;
+
+ 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();
+ }
+
+ 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 providesNewUsers
*/
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);
- $cardData = $vCard->serialize();
+ if ($expectedVCard !== null) {
+ $this->assertInstanceOf('Sabre\VObject\Component\VCard', $vCard);
+ $cardData = $vCard->jsonSerialize();
+ $this->compareData($expectedVCard, $cardData);
- $this->assertEquals($expectedVCard, $cardData);
+ } else {
+ $this->assertSame($expectedVCard, $vCard);
+ }
+
+ }
+
+ 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 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"],
- ];
- }
-
- /**
- * @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);
- }
-
- /**
- * @dataProvider providesUsersForUpdateOfRemovedElement
- */
- public function testUpdateOfRemovedElement($expectedVCard, $displayName = null, $eMailAddress = null, $cloudId = null) {
- $user = $this->getUserMock($displayName, $eMailAddress, $cloudId);
-
- $converter = new Converter();
- $vCard = $converter->createCardFromUser($user);
-
- $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);
-
- $updated = $converter->updateCard($vCard, $user1);
- $this->assertTrue($updated);
- $cardData = $vCard->serialize();
-
- $this->assertEquals($expectedVCard, $cardData);
- }
-
- public function providesUsersForUpdateOfRemovedElement() {
- 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 @@ class ConverterTest extends TestCase {
*/
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 e6a5ac1f16..68345def66 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 @@ class SyncServiceTest extends TestCase {
/** @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 @@ class SyncServiceTest extends TestCase {
$user = $this->getMockBuilder('OCP\IUser')->disableOriginalConstructor()->getMock();
$user->method('getBackendClassName')->willReturn('unittest');
$user->method('getUID')->willReturn('test-user');
+ $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);
+ $ss = new SyncService($backend, $userManager, $logger, $accountManager);
$ss->updateUser($user);
$user->method('getDisplayName')->willReturn('A test user for unit testing');
@@ -135,10 +176,11 @@ class SyncServiceTest extends TestCase {
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 f980e595bf..9579ce1c6d 100644
--- a/apps/dav/tests/unit/DAV/HookManagerTest.php
+++ b/apps/dav/tests/unit/DAV/HookManagerTest.php
@@ -31,14 +31,19 @@ use OCA\DAV\HookManager;
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 @@ class HookManagerTest extends TestCase {
'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 @@ class HookManagerTest extends TestCase {
$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 @@ class HookManagerTest extends TestCase {
'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 @@ class HookManagerTest extends TestCase {
]);
$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 6481abe32e..61f1b1c8f1 100644
--- a/apps/federatedfilesharing/lib/FederatedShareProvider.php
+++ b/apps/federatedfilesharing/lib/FederatedShareProvider.php
@@ -943,4 +943,14 @@ class FederatedShareProvider implements IShareProvider {
$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 64619e329f..20ff6ae6f4 100644
--- a/apps/federatedfilesharing/lib/Settings/Admin.php
+++ b/apps/federatedfilesharing/lib/Settings/Admin.php
@@ -43,6 +43,7 @@ class Admin implements ISettings {
$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 3ffd4bd5b2..0670553e06 100644
--- a/apps/federatedfilesharing/templates/settings-admin.php
+++ b/apps/federatedfilesharing/templates/settings-admin.php
@@ -25,4 +25,11 @@ script('federatedfilesharing', 'settings-admin');
t('Allow users on this server to receive shares from other servers'));?>
+ />
+
+
{{displayName}}
' +
+ '