add owner-displayname property to calendars and addressbooks
Signed-off-by: Georg Ehrke <developer@georgehrke.com>
This commit is contained in:
parent
11c7953888
commit
c89e057d27
|
@ -248,6 +248,8 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
|||
$calendar[$xmlName] = $row[$dbName];
|
||||
}
|
||||
|
||||
$this->addOwnerPrincipal($calendar);
|
||||
|
||||
if (!isset($calendars[$calendar['id']])) {
|
||||
$calendars[$calendar['id']] = $calendar;
|
||||
}
|
||||
|
@ -319,6 +321,8 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
|||
$calendar[$xmlName] = $row[$dbName];
|
||||
}
|
||||
|
||||
$this->addOwnerPrincipal($calendar);
|
||||
|
||||
$calendars[$calendar['id']] = $calendar;
|
||||
}
|
||||
$result->closeCursor();
|
||||
|
@ -359,6 +363,9 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
|||
foreach($this->propertyMap as $xmlName=>$dbName) {
|
||||
$calendar[$xmlName] = $row[$dbName];
|
||||
}
|
||||
|
||||
$this->addOwnerPrincipal($calendar);
|
||||
|
||||
if (!isset($calendars[$calendar['id']])) {
|
||||
$calendars[$calendar['id']] = $calendar;
|
||||
}
|
||||
|
@ -428,6 +435,8 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
|||
$calendar[$xmlName] = $row[$dbName];
|
||||
}
|
||||
|
||||
$this->addOwnerPrincipal($calendar);
|
||||
|
||||
if (!isset($calendars[$calendar['id']])) {
|
||||
$calendars[$calendar['id']] = $calendar;
|
||||
}
|
||||
|
@ -492,6 +501,8 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
|||
$calendar[$xmlName] = $row[$dbName];
|
||||
}
|
||||
|
||||
$this->addOwnerPrincipal($calendar);
|
||||
|
||||
return $calendar;
|
||||
|
||||
}
|
||||
|
@ -543,6 +554,8 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
|||
$calendar[$xmlName] = $row[$dbName];
|
||||
}
|
||||
|
||||
$this->addOwnerPrincipal($calendar);
|
||||
|
||||
return $calendar;
|
||||
}
|
||||
|
||||
|
@ -587,6 +600,8 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
|||
$calendar[$xmlName] = $row[$dbName];
|
||||
}
|
||||
|
||||
$this->addOwnerPrincipal($calendar);
|
||||
|
||||
return $calendar;
|
||||
}
|
||||
|
||||
|
@ -1815,4 +1830,19 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
|||
}
|
||||
return $principalUri;
|
||||
}
|
||||
|
||||
private function addOwnerPrincipal(&$calendarInfo) {
|
||||
$ownerPrincipalKey = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal';
|
||||
$displaynameKey = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_NEXTCLOUD . '}owner-displayname';
|
||||
if (isset($calendarInfo[$ownerPrincipalKey])) {
|
||||
$uri = $calendarInfo[$ownerPrincipalKey];
|
||||
} else {
|
||||
$uri = $calendarInfo['principaluri'];
|
||||
}
|
||||
|
||||
$principalInformation = $this->principalBackend->getPrincipalByPath($uri);
|
||||
if (isset($principalInformation['{DAV:}displayname'])) {
|
||||
$calendarInfo[$displaynameKey] = $principalInformation['{DAV:}displayname'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -155,6 +155,8 @@ class CardDavBackend implements BackendInterface, SyncSupport {
|
|||
'{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
|
||||
'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
|
||||
];
|
||||
|
||||
$this->addOwnerPrincipal($addressBooks[$row['id']]);
|
||||
}
|
||||
$result->closeCursor();
|
||||
|
||||
|
@ -206,6 +208,8 @@ class CardDavBackend implements BackendInterface, SyncSupport {
|
|||
'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $row['principaluri'],
|
||||
$readOnlyPropertyName => $readOnly,
|
||||
];
|
||||
|
||||
$this->addOwnerPrincipal($addressBooks[$row['id']]);
|
||||
}
|
||||
$result->closeCursor();
|
||||
|
||||
|
@ -233,6 +237,8 @@ class CardDavBackend implements BackendInterface, SyncSupport {
|
|||
'{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
|
||||
'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
|
||||
];
|
||||
|
||||
$this->addOwnerPrincipal($addressBooks[$row['id']]);
|
||||
}
|
||||
$result->closeCursor();
|
||||
|
||||
|
@ -269,7 +275,7 @@ class CardDavBackend implements BackendInterface, SyncSupport {
|
|||
return null;
|
||||
}
|
||||
|
||||
return [
|
||||
$addressBook = [
|
||||
'id' => $row['id'],
|
||||
'uri' => $row['uri'],
|
||||
'principaluri' => $row['principaluri'],
|
||||
|
@ -278,6 +284,10 @@ class CardDavBackend implements BackendInterface, SyncSupport {
|
|||
'{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
|
||||
'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
|
||||
];
|
||||
|
||||
$this->addOwnerPrincipal($addressBook);
|
||||
|
||||
return $addressBook;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -299,15 +309,19 @@ class CardDavBackend implements BackendInterface, SyncSupport {
|
|||
return null;
|
||||
}
|
||||
|
||||
return [
|
||||
'id' => $row['id'],
|
||||
'uri' => $row['uri'],
|
||||
'principaluri' => $row['principaluri'],
|
||||
'{DAV:}displayname' => $row['displayname'],
|
||||
'{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'],
|
||||
'{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
|
||||
'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
|
||||
];
|
||||
$addressBook = [
|
||||
'id' => $row['id'],
|
||||
'uri' => $row['uri'],
|
||||
'principaluri' => $row['principaluri'],
|
||||
'{DAV:}displayname' => $row['displayname'],
|
||||
'{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'],
|
||||
'{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
|
||||
'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
|
||||
];
|
||||
|
||||
$this->addOwnerPrincipal($addressBook);
|
||||
|
||||
return $addressBook;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1087,4 +1101,19 @@ class CardDavBackend implements BackendInterface, SyncSupport {
|
|||
}
|
||||
return $principalUri;
|
||||
}
|
||||
|
||||
private function addOwnerPrincipal(&$addressbookInfo) {
|
||||
$ownerPrincipalKey = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal';
|
||||
$displaynameKey = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_NEXTCLOUD . '}owner-displayname';
|
||||
if (isset($addressbookInfo[$ownerPrincipalKey])) {
|
||||
$uri = $addressbookInfo[$ownerPrincipalKey];
|
||||
} else {
|
||||
$uri = $addressbookInfo['principaluri'];
|
||||
}
|
||||
|
||||
$principalInformation = $this->principalBackend->getPrincipalByPath($uri);
|
||||
if (isset($principalInformation['{DAV:}displayname'])) {
|
||||
$addressbookInfo[$displaynameKey] = $principalInformation['{DAV:}displayname'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ use Sabre\HTTP\ResponseInterface;
|
|||
class Plugin extends ServerPlugin {
|
||||
|
||||
const NS_OWNCLOUD = 'http://owncloud.org/ns';
|
||||
const NS_NEXTCLOUD = 'http://nextcloud.com/ns';
|
||||
|
||||
/** @var Auth */
|
||||
private $auth;
|
||||
|
|
|
@ -68,7 +68,8 @@ abstract class AbstractCalDavBackendTest extends TestCase {
|
|||
->getMock();
|
||||
$this->principal->expects($this->any())->method('getPrincipalByPath')
|
||||
->willReturn([
|
||||
'uri' => 'principals/best-friend'
|
||||
'uri' => 'principals/best-friend',
|
||||
'{DAV:}displayname' => 'User\'s displayname',
|
||||
]);
|
||||
$this->principal->expects($this->any())->method('getGroupMembership')
|
||||
->withAnyParameters()
|
||||
|
|
|
@ -61,6 +61,7 @@ class CalDavBackendTest extends AbstractCalDavBackendTest {
|
|||
$this->assertCount(1, $calendars);
|
||||
$this->assertEquals('Unit test', $calendars[0]['{DAV:}displayname']);
|
||||
$this->assertEquals('Calendar used for unit testing', $calendars[0]['{urn:ietf:params:xml:ns:caldav}calendar-description']);
|
||||
$this->assertEquals('User\'s displayname', $calendars[0]['{http://nextcloud.com/ns}owner-displayname']);
|
||||
|
||||
// delete the address book
|
||||
$this->dispatcher->expects($this->at(0))
|
||||
|
@ -410,6 +411,7 @@ EOD;
|
|||
$publicCalendars = $this->backend->getPublicCalendars();
|
||||
$this->assertCount(1, $publicCalendars);
|
||||
$this->assertEquals(true, $publicCalendars[0]['{http://owncloud.org/ns}public']);
|
||||
$this->assertEquals('User\'s displayname', $publicCalendars[0]['{http://nextcloud.com/ns}owner-displayname']);
|
||||
|
||||
$publicCalendarURI = $publicCalendars[0]['uri'];
|
||||
$publicCalendar = $this->backend->getPublicCalendar($publicCalendarURI);
|
||||
|
|
|
@ -82,7 +82,8 @@ class CardDavBackendTest extends TestCase {
|
|||
->getMock();
|
||||
$this->principal->method('getPrincipalByPath')
|
||||
->willReturn([
|
||||
'uri' => 'principals/best-friend'
|
||||
'uri' => 'principals/best-friend',
|
||||
'{DAV:}displayname' => 'User\'s displayname',
|
||||
]);
|
||||
$this->principal->method('getGroupMembership')
|
||||
->withAnyParameters()
|
||||
|
@ -123,6 +124,7 @@ class CardDavBackendTest extends TestCase {
|
|||
$books = $this->backend->getAddressBooksForUser(self::UNIT_TEST_USER);
|
||||
$this->assertEquals(1, count($books));
|
||||
$this->assertEquals('Example', $books[0]['{DAV:}displayname']);
|
||||
$this->assertEquals('User\'s displayname', $books[0]['{http://nextcloud.com/ns}owner-displayname']);
|
||||
|
||||
// update it's display name
|
||||
$patch = new PropPatch([
|
||||
|
|
Loading…
Reference in New Issue