add correct calendar-user-type to resource and room backend

Signed-off-by: Georg Ehrke <developer@georgehrke.com>
This commit is contained in:
Georg Ehrke 2018-10-16 14:39:04 +02:00
parent f737ae719d
commit 325e366b58
No known key found for this signature in database
GPG Key ID: 9D98FD9380A1CB43
6 changed files with 21 additions and 4 deletions

View File

@ -50,6 +50,9 @@ abstract class AbstractPrincipalBackend implements BackendInterface {
/** @var string */
private $dbTableName;
/** @var string */
private $cuType;
/**
* @param IDBConnection $dbConnection
* @param IUserSession $userSession
@ -57,18 +60,22 @@ abstract class AbstractPrincipalBackend implements BackendInterface {
* @param ILogger $logger
* @param string $principalPrefix
* @param string $dbPrefix
* @param string $cuType
*/
public function __construct(IDBConnection $dbConnection,
IUserSession $userSession,
IGroupManager $groupManager,
ILogger $logger,
$principalPrefix, $dbPrefix) {
string $principalPrefix,
string $dbPrefix,
string $cuType) {
$this->db = $dbConnection;
$this->userSession = $userSession;
$this->groupManager = $groupManager;
$this->logger = $logger;
$this->principalPrefix = $principalPrefix;
$this->dbTableName = 'calendar_' . $dbPrefix;
$this->cuType = $cuType;
}
/**
@ -328,7 +335,8 @@ abstract class AbstractPrincipalBackend implements BackendInterface {
return [
'uri' => $this->principalPrefix . '/' . $row['backend_id'] . '-' . $row['resource_id'],
'{DAV:}displayname' => $row['displayname'],
'{http://sabredav.org/ns}email-address' => $row['email']
'{http://sabredav.org/ns}email-address' => $row['email'],
'{urn:ietf:params:xml:ns:caldav}calendar-user-type' => $this->cuType,
];
}

View File

@ -40,6 +40,6 @@ class ResourcePrincipalBackend extends AbstractPrincipalBackend {
IGroupManager $groupManager,
ILogger $logger) {
parent::__construct($dbConnection, $userSession, $groupManager, $logger,
'principals/calendar-resources', 'resources');
'principals/calendar-resources', 'resources', 'RESOURCE');
}
}

View File

@ -40,6 +40,6 @@ class RoomPrincipalBackend extends AbstractPrincipalBackend {
IGroupManager $groupManager,
ILogger $logger) {
parent::__construct($dbConnection, $userSession, $groupManager, $logger,
'principals/calendar-rooms', 'rooms');
'principals/calendar-rooms', 'rooms', 'ROOM');
}
}

View File

@ -53,6 +53,9 @@ abstract class AbstractPrincipalBackendTest extends TestCase {
/** @var string */
protected $principalPrefix;
/** @var string */
protected $expectedCUType;
public function setUp() {
parent::setUp();
@ -127,16 +130,19 @@ abstract class AbstractPrincipalBackendTest extends TestCase {
'uri' => $this->principalPrefix . '/db-123',
'{DAV:}displayname' => 'Resource 123',
'{http://sabredav.org/ns}email-address' => 'foo@bar.com',
'{urn:ietf:params:xml:ns:caldav}calendar-user-type' => $this->expectedCUType,
],
[
'uri' => $this->principalPrefix . '/ldap-123',
'{DAV:}displayname' => 'Resource 123 ldap',
'{http://sabredav.org/ns}email-address' => 'ldap@bar.com',
'{urn:ietf:params:xml:ns:caldav}calendar-user-type' => $this->expectedCUType,
],
[
'uri' => $this->principalPrefix . '/db-456',
'{DAV:}displayname' => 'Resource 456',
'{http://sabredav.org/ns}email-address' => 'bli@bar.com',
'{urn:ietf:params:xml:ns:caldav}calendar-user-type' => $this->expectedCUType,
],
], $actual);
@ -209,6 +215,7 @@ abstract class AbstractPrincipalBackendTest extends TestCase {
'uri' => $this->principalPrefix . '/db-123',
'{DAV:}displayname' => 'Resource 123',
'{http://sabredav.org/ns}email-address' => 'foo@bar.com',
'{urn:ietf:params:xml:ns:caldav}calendar-user-type' => $this->expectedCUType,
], $actual);
}

View File

@ -31,5 +31,6 @@ Class ResourcePrincipalBackendTest extends AbstractPrincipalBackendTest {
$this->userSession, $this->groupManager, $this->logger);
$this->expectedDbTable = 'calendar_resources';
$this->principalPrefix = 'principals/calendar-resources';
$this->expectedCUType = 'RESOURCE';
}
}

View File

@ -31,5 +31,6 @@ Class RoomPrincipalBackendTest extends AbstractPrincipalBackendTest {
$this->userSession, $this->groupManager, $this->logger);
$this->expectedDbTable = 'calendar_rooms';
$this->principalPrefix = 'principals/calendar-rooms';
$this->expectedCUType = 'ROOM';
}
}