Signed-off-by: Georg Ehrke <developer@georgehrke.com>tags/v15.0.0beta1
@@ -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, | |||
]; | |||
} | |||
@@ -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'); | |||
} | |||
} |
@@ -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'); | |||
} | |||
} |
@@ -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); | |||
} | |||
@@ -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'; | |||
} | |||
} |
@@ -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'; | |||
} | |||
} |