Merge pull request #16498 from nextcloud/feature/noid/room_metadata
Allow calendar resources/rooms to provide metadata
This commit is contained in:
commit
1d72073e34
|
@ -5,7 +5,7 @@
|
|||
<name>WebDAV</name>
|
||||
<summary>WebDAV endpoint</summary>
|
||||
<description>WebDAV endpoint</description>
|
||||
<version>1.10.0</version>
|
||||
<version>1.11.0</version>
|
||||
<licence>agpl</licence>
|
||||
<author>owncloud.org</author>
|
||||
<namespace>DAV</namespace>
|
||||
|
|
|
@ -179,6 +179,7 @@ return array(
|
|||
'OCA\\DAV\\Migration\\Version1008Date20181105110300' => $baseDir . '/../lib/Migration/Version1008Date20181105110300.php',
|
||||
'OCA\\DAV\\Migration\\Version1008Date20181105112049' => $baseDir . '/../lib/Migration/Version1008Date20181105112049.php',
|
||||
'OCA\\DAV\\Migration\\Version1008Date20181114084440' => $baseDir . '/../lib/Migration/Version1008Date20181114084440.php',
|
||||
'OCA\\DAV\\Migration\\Version1011Date20190725113607' => $baseDir . '/../lib/Migration/Version1011Date20190725113607.php',
|
||||
'OCA\\DAV\\Provisioning\\Apple\\AppleProvisioningNode' => $baseDir . '/../lib/Provisioning/Apple/AppleProvisioningNode.php',
|
||||
'OCA\\DAV\\Provisioning\\Apple\\AppleProvisioningPlugin' => $baseDir . '/../lib/Provisioning/Apple/AppleProvisioningPlugin.php',
|
||||
'OCA\\DAV\\RootCollection' => $baseDir . '/../lib/RootCollection.php',
|
||||
|
|
|
@ -194,6 +194,7 @@ class ComposerStaticInitDAV
|
|||
'OCA\\DAV\\Migration\\Version1008Date20181105110300' => __DIR__ . '/..' . '/../lib/Migration/Version1008Date20181105110300.php',
|
||||
'OCA\\DAV\\Migration\\Version1008Date20181105112049' => __DIR__ . '/..' . '/../lib/Migration/Version1008Date20181105112049.php',
|
||||
'OCA\\DAV\\Migration\\Version1008Date20181114084440' => __DIR__ . '/..' . '/../lib/Migration/Version1008Date20181114084440.php',
|
||||
'OCA\\DAV\\Migration\\Version1011Date20190725113607' => __DIR__ . '/..' . '/../lib/Migration/Version1011Date20190725113607.php',
|
||||
'OCA\\DAV\\Provisioning\\Apple\\AppleProvisioningNode' => __DIR__ . '/..' . '/../lib/Provisioning/Apple/AppleProvisioningNode.php',
|
||||
'OCA\\DAV\\Provisioning\\Apple\\AppleProvisioningPlugin' => __DIR__ . '/..' . '/../lib/Provisioning/Apple/AppleProvisioningPlugin.php',
|
||||
'OCA\\DAV\\RootCollection' => __DIR__ . '/..' . '/../lib/RootCollection.php',
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright 2018, Georg Ehrke <oc.list@georgehrke.com>
|
||||
* @copyright 2019, Georg Ehrke <oc.list@georgehrke.com>
|
||||
*
|
||||
* @author Georg Ehrke <oc.list@georgehrke.com>
|
||||
*
|
||||
|
@ -26,6 +26,8 @@ namespace OCA\DAV\BackgroundJob;
|
|||
use OC\BackgroundJob\TimedJob;
|
||||
use OCA\DAV\CalDAV\CalDavBackend;
|
||||
use OCP\Calendar\BackendTemporarilyUnavailableException;
|
||||
use OCP\Calendar\IMetadataProvider;
|
||||
use OCP\Calendar\Resource\IBackend as IResourceBackend;
|
||||
use OCP\Calendar\Resource\IManager as IResourceManager;
|
||||
use OCP\Calendar\Resource\IResource;
|
||||
use OCP\Calendar\Room\IManager as IRoomManager;
|
||||
|
@ -41,23 +43,11 @@ class UpdateCalendarResourcesRoomsBackgroundJob extends TimedJob {
|
|||
private $roomManager;
|
||||
|
||||
/** @var IDBConnection */
|
||||
private $db;
|
||||
private $dbConnection;
|
||||
|
||||
/** @var CalDavBackend */
|
||||
private $calDavBackend;
|
||||
|
||||
/** @var string */
|
||||
private $resourceDbTable;
|
||||
|
||||
/** @var string */
|
||||
private $resourcePrincipalUri;
|
||||
|
||||
/** @var string */
|
||||
private $roomDbTable;
|
||||
|
||||
/** @var string */
|
||||
private $roomPrincipalUri;
|
||||
|
||||
/**
|
||||
* UpdateCalendarResourcesRoomsBackgroundJob constructor.
|
||||
*
|
||||
|
@ -66,16 +56,14 @@ class UpdateCalendarResourcesRoomsBackgroundJob extends TimedJob {
|
|||
* @param IDBConnection $dbConnection
|
||||
* @param CalDavBackend $calDavBackend
|
||||
*/
|
||||
public function __construct(IResourceManager $resourceManager, IRoomManager $roomManager,
|
||||
IDBConnection $dbConnection, CalDavBackend $calDavBackend) {
|
||||
public function __construct(IResourceManager $resourceManager,
|
||||
IRoomManager $roomManager,
|
||||
IDBConnection $dbConnection,
|
||||
CalDavBackend $calDavBackend) {
|
||||
$this->resourceManager = $resourceManager;
|
||||
$this->roomManager = $roomManager;
|
||||
$this->db = $dbConnection;
|
||||
$this->dbConnection = $dbConnection;
|
||||
$this->calDavBackend = $calDavBackend;
|
||||
$this->resourceDbTable = 'calendar_resources';
|
||||
$this->resourcePrincipalUri = 'principals/calendar-resources';
|
||||
$this->roomDbTable = 'calendar_rooms';
|
||||
$this->roomPrincipalUri = 'principals/calendar-rooms';
|
||||
|
||||
// run once an hour
|
||||
$this->setInterval(60 * 60);
|
||||
|
@ -84,211 +72,132 @@ class UpdateCalendarResourcesRoomsBackgroundJob extends TimedJob {
|
|||
/**
|
||||
* @param $argument
|
||||
*/
|
||||
public function run($argument) {
|
||||
$this->runResources();
|
||||
$this->runRooms();
|
||||
public function run($argument):void {
|
||||
$this->runForBackend(
|
||||
$this->resourceManager,
|
||||
'calendar_resources',
|
||||
'calendar_resources_md',
|
||||
'resource_id',
|
||||
'principals/calendar-resources'
|
||||
);
|
||||
$this->runForBackend(
|
||||
$this->roomManager,
|
||||
'calendar_rooms',
|
||||
'calendar_rooms_md',
|
||||
'room_id',
|
||||
'principals/calendar-rooms'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* run timed job for resources
|
||||
*/
|
||||
private function runResources() {
|
||||
$resourceBackends = $this->resourceManager->getBackends();
|
||||
$cachedResources = $this->getCached($this->resourceDbTable);
|
||||
$cachedResourceIds = $this->getCachedResourceIds($cachedResources);
|
||||
|
||||
$remoteResourceIds = [];
|
||||
foreach($resourceBackends as $resourceBackend) {
|
||||
try {
|
||||
$remoteResourceIds[$resourceBackend->getBackendIdentifier()] =
|
||||
$resourceBackend->listAllResources();
|
||||
} catch(BackendTemporarilyUnavailableException $ex) {
|
||||
// If the backend is temporarily unavailable
|
||||
// ignore this backend in this execution
|
||||
unset($cachedResourceIds[$resourceBackend->getBackendIdentifier()]);
|
||||
}
|
||||
}
|
||||
|
||||
$sortedResources = $this->sortByNewDeletedExisting($cachedResourceIds, $remoteResourceIds);
|
||||
|
||||
foreach($sortedResources['new'] as $backendId => $newResources) {
|
||||
foreach ($newResources as $newResource) {
|
||||
$backend = $this->resourceManager->getBackend($backendId);
|
||||
if ($backend === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$resource = $backend->getResource($newResource);
|
||||
$this->addToCache($this->resourceDbTable, $resource);
|
||||
}
|
||||
}
|
||||
foreach($sortedResources['deleted'] as $backendId => $deletedResources) {
|
||||
foreach ($deletedResources as $deletedResource) {
|
||||
$this->deleteFromCache($this->resourceDbTable,
|
||||
$this->resourcePrincipalUri, $backendId, $deletedResource);
|
||||
}
|
||||
}
|
||||
foreach($sortedResources['edited'] as $backendId => $editedResources) {
|
||||
foreach ($editedResources as $editedResource) {
|
||||
$backend = $this->resourceManager->getBackend($backendId);
|
||||
if ($backend === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$resource = $backend->getResource($editedResource);
|
||||
$this->updateCache($this->resourceDbTable, $resource);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* run timed job for rooms
|
||||
*/
|
||||
private function runRooms() {
|
||||
$roomBackends = $this->roomManager->getBackends();
|
||||
$cachedRooms = $this->getCached($this->roomDbTable);
|
||||
$cachedRoomIds = $this->getCachedRoomIds($cachedRooms);
|
||||
|
||||
$remoteRoomIds = [];
|
||||
foreach($roomBackends as $roomBackend) {
|
||||
try {
|
||||
$remoteRoomIds[$roomBackend->getBackendIdentifier()] =
|
||||
$roomBackend->listAllRooms();
|
||||
} catch(BackendTemporarilyUnavailableException $ex) {
|
||||
// If the backend is temporarily unavailable
|
||||
// ignore this backend in this execution
|
||||
unset($cachedRoomIds[$roomBackend->getBackendIdentifier()]);
|
||||
}
|
||||
}
|
||||
|
||||
$sortedRooms = $this->sortByNewDeletedExisting($cachedRoomIds, $remoteRoomIds);
|
||||
|
||||
foreach($sortedRooms['new'] as $backendId => $newRooms) {
|
||||
foreach ($newRooms as $newRoom) {
|
||||
$backend = $this->roomManager->getBackend($backendId);
|
||||
if ($backend === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$resource = $backend->getRoom($newRoom);
|
||||
$this->addToCache($this->roomDbTable, $resource);
|
||||
}
|
||||
}
|
||||
foreach($sortedRooms['deleted'] as $backendId => $deletedRooms) {
|
||||
foreach ($deletedRooms as $deletedRoom) {
|
||||
$this->deleteFromCache($this->roomDbTable,
|
||||
$this->roomPrincipalUri, $backendId, $deletedRoom);
|
||||
}
|
||||
}
|
||||
foreach($sortedRooms['edited'] as $backendId => $editedRooms) {
|
||||
foreach ($editedRooms as $editedRoom) {
|
||||
$backend = $this->roomManager->getBackend($backendId);
|
||||
if ($backend === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$resource = $backend->getRoom($editedRoom);
|
||||
$this->updateCache($this->roomDbTable, $resource);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get cached db rows for resources / rooms
|
||||
* @param string $tableName
|
||||
* @return array
|
||||
*/
|
||||
private function getCached($tableName):array {
|
||||
$query = $this->db->getQueryBuilder();
|
||||
$query->select('*')->from($tableName);
|
||||
|
||||
$rows = [];
|
||||
$stmt = $query->execute();
|
||||
while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
|
||||
$rows[] = $row;
|
||||
}
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $cachedResources
|
||||
* @return array
|
||||
*/
|
||||
private function getCachedResourceIds(array $cachedResources):array {
|
||||
$cachedResourceIds = [];
|
||||
foreach ($cachedResources as $cachedResource) {
|
||||
if (!isset($cachedResourceIds[$cachedResource['backend_id']])) {
|
||||
$cachedResourceIds[$cachedResource['backend_id']] = [];
|
||||
}
|
||||
|
||||
$cachedResourceIds[$cachedResource['backend_id']][] =
|
||||
$cachedResource['resource_id'];
|
||||
}
|
||||
|
||||
return $cachedResourceIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $cachedRooms
|
||||
* @return array
|
||||
*/
|
||||
private function getCachedRoomIds(array $cachedRooms):array {
|
||||
$cachedRoomIds = [];
|
||||
foreach ($cachedRooms as $cachedRoom) {
|
||||
if (!isset($cachedRoomIds[$cachedRoom['backend_id']])) {
|
||||
$cachedRoomIds[$cachedRoom['backend_id']] = [];
|
||||
}
|
||||
|
||||
$cachedRoomIds[$cachedRoom['backend_id']][] =
|
||||
$cachedRoom['resource_id'];
|
||||
}
|
||||
|
||||
return $cachedRoomIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* sort list of ids by whether they appear only in the backend /
|
||||
* only in the cache / in both
|
||||
* Run background-job for one specific backendManager
|
||||
* either ResourceManager or RoomManager
|
||||
*
|
||||
* @param array $cached
|
||||
* @param array $remote
|
||||
* @return array
|
||||
* @param IResourceManager|IRoomManager $backendManager
|
||||
* @param string $dbTable
|
||||
* @param string $dbTableMetadata
|
||||
* @param string $foreignKey
|
||||
* @param string $principalPrefix
|
||||
*/
|
||||
private function sortByNewDeletedExisting(array $cached, array $remote):array {
|
||||
$sorted = [
|
||||
'new' => [],
|
||||
'deleted' => [],
|
||||
'edited' => [],
|
||||
];
|
||||
private function runForBackend($backendManager,
|
||||
string $dbTable,
|
||||
string $dbTableMetadata,
|
||||
string $foreignKey,
|
||||
string $principalPrefix):void {
|
||||
$backends = $backendManager->getBackends();
|
||||
|
||||
$backendIds = array_merge(array_keys($cached), array_keys($remote));
|
||||
foreach($backendIds as $backendId) {
|
||||
if (!isset($cached[$backendId])) {
|
||||
$sorted['new'][$backendId] = $remote[$backendId];
|
||||
} elseif (!isset($remote[$backendId])) {
|
||||
$sorted['deleted'][$backendId] = $cached[$backendId];
|
||||
} else {
|
||||
$sorted['new'][$backendId] = array_diff($remote[$backendId], $cached[$backendId]);
|
||||
$sorted['deleted'][$backendId] = array_diff($cached[$backendId], $remote[$backendId]);
|
||||
$sorted['edited'][$backendId] = array_intersect($remote[$backendId], $cached[$backendId]);
|
||||
foreach($backends as $backend) {
|
||||
$backendId = $backend->getBackendIdentifier();
|
||||
|
||||
try {
|
||||
if ($backend instanceof IResourceBackend) {
|
||||
$list = $backend->listAllResources();
|
||||
} else {
|
||||
$list = $backend->listAllRooms();
|
||||
}
|
||||
} catch(BackendTemporarilyUnavailableException $ex) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$cachedList = $this->getAllCachedByBackend($dbTable, $backendId);
|
||||
$newIds = array_diff($list, $cachedList);
|
||||
$deletedIds = array_diff($cachedList, $list);
|
||||
$editedIds = array_intersect($list, $cachedList);
|
||||
|
||||
foreach($newIds as $newId) {
|
||||
try {
|
||||
if ($backend instanceof IResourceBackend) {
|
||||
$resource = $backend->getResource($newId);
|
||||
} else {
|
||||
$resource = $backend->getRoom($newId);
|
||||
}
|
||||
|
||||
$metadata = [];
|
||||
if ($resource instanceof IMetadataProvider) {
|
||||
$metadata = $this->getAllMetadataOfBackend($resource);
|
||||
}
|
||||
} catch(BackendTemporarilyUnavailableException $ex) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$id = $this->addToCache($dbTable, $backendId, $resource);
|
||||
$this->addMetadataToCache($dbTableMetadata, $foreignKey, $id, $metadata);
|
||||
// we don't create the calendar here, it is created lazily
|
||||
// when an event is actually scheduled with this resource / room
|
||||
}
|
||||
|
||||
foreach($deletedIds as $deletedId) {
|
||||
$id = $this->getIdForBackendAndResource($dbTable, $backendId, $deletedId);
|
||||
$this->deleteFromCache($dbTable, $id);
|
||||
$this->deleteMetadataFromCache($dbTableMetadata, $foreignKey, $id);
|
||||
|
||||
$principalName = implode('-', [$backendId, $deletedId]);
|
||||
$this->deleteCalendarDataForResource($principalPrefix, $principalName);
|
||||
}
|
||||
|
||||
foreach($editedIds as $editedId) {
|
||||
$id = $this->getIdForBackendAndResource($dbTable, $backendId, $editedId);
|
||||
|
||||
try {
|
||||
if ($backend instanceof IResourceBackend) {
|
||||
$resource = $backend->getResource($editedId);
|
||||
} else {
|
||||
$resource = $backend->getRoom($editedId);
|
||||
}
|
||||
|
||||
$metadata = [];
|
||||
if ($resource instanceof IMetadataProvider) {
|
||||
$metadata = $this->getAllMetadataOfBackend($resource);
|
||||
}
|
||||
} catch(BackendTemporarilyUnavailableException $ex) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->updateCache($dbTable, $id, $resource);
|
||||
|
||||
if ($resource instanceof IMetadataProvider) {
|
||||
$cachedMetadata = $this->getAllMetadataOfCache($dbTableMetadata, $foreignKey, $id);
|
||||
$this->updateMetadataCache($dbTableMetadata, $foreignKey, $id, $metadata, $cachedMetadata);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $sorted;
|
||||
}
|
||||
|
||||
/**
|
||||
* add entry to cache that exists remotely but not yet in cache
|
||||
*
|
||||
* @param string $table
|
||||
* @param string $backendId
|
||||
* @param IResource|IRoom $remote
|
||||
* @return int Insert id
|
||||
*/
|
||||
private function addToCache($table, $remote) {
|
||||
$query = $this->db->getQueryBuilder();
|
||||
private function addToCache(string $table,
|
||||
string $backendId,
|
||||
$remote):int {
|
||||
$query = $this->dbConnection->getQueryBuilder();
|
||||
$query->insert($table)
|
||||
->values([
|
||||
'backend_id' => $query->createNamedParameter($remote->getBackend()->getBackendIdentifier()),
|
||||
'backend_id' => $query->createNamedParameter($backendId),
|
||||
'resource_id' => $query->createNamedParameter($remote->getId()),
|
||||
'email' => $query->createNamedParameter($remote->getEMail()),
|
||||
'displayname' => $query->createNamedParameter($remote->getDisplayName()),
|
||||
|
@ -298,37 +207,70 @@ class UpdateCalendarResourcesRoomsBackgroundJob extends TimedJob {
|
|||
))
|
||||
])
|
||||
->execute();
|
||||
return $query->getLastInsertId();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $table
|
||||
* @param string $foreignKey
|
||||
* @param int $foreignId
|
||||
* @param array $metadata
|
||||
*/
|
||||
private function addMetadataToCache(string $table,
|
||||
string $foreignKey,
|
||||
int $foreignId,
|
||||
array $metadata):void {
|
||||
foreach($metadata as $key => $value) {
|
||||
$query = $this->dbConnection->getQueryBuilder();
|
||||
$query->insert($table)
|
||||
->values([
|
||||
$foreignKey => $query->createNamedParameter($foreignId),
|
||||
'key' => $query->createNamedParameter($key),
|
||||
'value' => $query->createNamedParameter($value),
|
||||
])
|
||||
->execute();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* delete entry from cache that does not exist anymore remotely
|
||||
*
|
||||
* @param string $table
|
||||
* @param string $principalUri
|
||||
* @param string $backendId
|
||||
* @param string $resourceId
|
||||
* @param int $id
|
||||
*/
|
||||
private function deleteFromCache($table, $principalUri, $backendId, $resourceId) {
|
||||
$query = $this->db->getQueryBuilder();
|
||||
private function deleteFromCache(string $table,
|
||||
int $id):void {
|
||||
$query = $this->dbConnection->getQueryBuilder();
|
||||
$query->delete($table)
|
||||
->where($query->expr()->eq('backend_id', $query->createNamedParameter($backendId)))
|
||||
->andWhere($query->expr()->eq('resource_id', $query->createNamedParameter($resourceId)))
|
||||
->where($query->expr()->eq('id', $query->createNamedParameter($id)))
|
||||
->execute();
|
||||
}
|
||||
|
||||
$calendar = $this->calDavBackend->getCalendarByUri($principalUri, implode('-', [$backendId, $resourceId]));
|
||||
if ($calendar !== null) {
|
||||
$this->calDavBackend->deleteCalendar($calendar['id']);
|
||||
}
|
||||
/**
|
||||
* @param string $table
|
||||
* @param string $foreignKey
|
||||
* @param int $id
|
||||
*/
|
||||
private function deleteMetadataFromCache(string $table,
|
||||
string $foreignKey,
|
||||
int $id):void {
|
||||
$query = $this->dbConnection->getQueryBuilder();
|
||||
$query->delete($table)
|
||||
->where($query->expr()->eq($foreignKey, $query->createNamedParameter($id)))
|
||||
->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* update an existing entry in cache
|
||||
*
|
||||
* @param string $table
|
||||
* @param int $id
|
||||
* @param IResource|IRoom $remote
|
||||
*/
|
||||
private function updateCache($table, $remote) {
|
||||
$query = $this->db->getQueryBuilder();
|
||||
private function updateCache(string $table,
|
||||
int $id,
|
||||
$remote):void {
|
||||
$query = $this->dbConnection->getQueryBuilder();
|
||||
$query->update($table)
|
||||
->set('email', $query->createNamedParameter($remote->getEMail()))
|
||||
->set('displayname', $query->createNamedParameter($remote->getDisplayName()))
|
||||
|
@ -336,11 +278,57 @@ class UpdateCalendarResourcesRoomsBackgroundJob extends TimedJob {
|
|||
$this->serializeGroupRestrictions(
|
||||
$remote->getGroupRestrictions()
|
||||
)))
|
||||
->where($query->expr()->eq('backend_id', $query->createNamedParameter($remote->getBackend()->getBackendIdentifier())))
|
||||
->andWhere($query->expr()->eq('resource_id', $query->createNamedParameter($remote->getId())))
|
||||
->where($query->expr()->eq('id', $query->createNamedParameter($id)))
|
||||
->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $dbTable
|
||||
* @param string $foreignKey
|
||||
* @param int $id
|
||||
* @param array $metadata
|
||||
* @param array $cachedMetadata
|
||||
*/
|
||||
private function updateMetadataCache(string $dbTable,
|
||||
string $foreignKey,
|
||||
int $id,
|
||||
array $metadata,
|
||||
array $cachedMetadata):void {
|
||||
$newMetadata = array_diff_key($metadata, $cachedMetadata);
|
||||
$deletedMetadata = array_diff_key($cachedMetadata, $metadata);
|
||||
|
||||
foreach ($newMetadata as $key => $value) {
|
||||
$query = $this->dbConnection->getQueryBuilder();
|
||||
$query->insert($dbTable)
|
||||
->values([
|
||||
$foreignKey => $query->createNamedParameter($id),
|
||||
'key' => $query->createNamedParameter($key),
|
||||
'value' => $query->createNamedParameter($value),
|
||||
])
|
||||
->execute();
|
||||
}
|
||||
|
||||
foreach($deletedMetadata as $key => $value) {
|
||||
$query = $this->dbConnection->getQueryBuilder();
|
||||
$query->delete($dbTable)
|
||||
->where($query->expr()->eq($foreignKey, $query->createNamedParameter($id)))
|
||||
->andWhere($query->expr()->eq('key', $query->createNamedParameter($key)))
|
||||
->execute();
|
||||
}
|
||||
|
||||
$existingKeys = array_keys(array_intersect_key($metadata, $cachedMetadata));
|
||||
foreach($existingKeys as $existingKey) {
|
||||
if ($metadata[$existingKey] !== $cachedMetadata[$existingKey]) {
|
||||
$query = $this->dbConnection->getQueryBuilder();
|
||||
$query->update($dbTable)
|
||||
->set('value', $query->createNamedParameter($metadata[$existingKey]))
|
||||
->where($query->expr()->eq($foreignKey, $query->createNamedParameter($id)))
|
||||
->andWhere($query->expr()->eq('key', $query->createNamedParameter($existingKey)))
|
||||
->execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* serialize array of group restrictions to store them in database
|
||||
*
|
||||
|
@ -350,4 +338,102 @@ class UpdateCalendarResourcesRoomsBackgroundJob extends TimedJob {
|
|||
private function serializeGroupRestrictions(array $groups):string {
|
||||
return \json_encode($groups);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all metadata of a backend
|
||||
*
|
||||
* @param IResource|IRoom $resource
|
||||
* @return array
|
||||
*/
|
||||
private function getAllMetadataOfBackend($resource):array {
|
||||
if (!($resource instanceof IMetadataProvider)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$keys = $resource->getAllAvailableMetadataKeys();
|
||||
$metadata = [];
|
||||
foreach($keys as $key) {
|
||||
$metadata[$key] = $resource->getMetadataForKey($key);
|
||||
}
|
||||
|
||||
return $metadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $table
|
||||
* @param string $foreignKey
|
||||
* @param int $id
|
||||
* @return array
|
||||
*/
|
||||
private function getAllMetadataOfCache(string $table,
|
||||
string $foreignKey,
|
||||
int $id):array {
|
||||
$query = $this->dbConnection->getQueryBuilder();
|
||||
$query->select(['key', 'value'])
|
||||
->from($table)
|
||||
->where($query->expr()->eq($foreignKey, $query->createNamedParameter($id)));
|
||||
$stmt = $query->execute();
|
||||
$rows = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
|
||||
$metadata = [];
|
||||
foreach($rows as $row) {
|
||||
$metadata[$row['key']] = $row['value'];
|
||||
}
|
||||
|
||||
return $metadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all cached rooms / resources by backend
|
||||
*
|
||||
* @param $tableName
|
||||
* @param $backendId
|
||||
* @return array
|
||||
*/
|
||||
private function getAllCachedByBackend(string $tableName,
|
||||
string $backendId):array {
|
||||
$query = $this->dbConnection->getQueryBuilder();
|
||||
$query->select('resource_id')
|
||||
->from($tableName)
|
||||
->where($query->expr()->eq('backend_id', $query->createNamedParameter($backendId)));
|
||||
$stmt = $query->execute();
|
||||
|
||||
return array_map(function($row) {
|
||||
return $row['resource_id'];
|
||||
}, $stmt->fetchAll(\PDO::FETCH_NAMED));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $principalPrefix
|
||||
* @param $principalUri
|
||||
*/
|
||||
private function deleteCalendarDataForResource(string $principalPrefix,
|
||||
string $principalUri):void {
|
||||
$calendar = $this->calDavBackend->getCalendarByUri(
|
||||
implode('/', [$principalPrefix, $principalUri]),
|
||||
CalDavBackend::RESOURCE_BOOKING_CALENDAR_URI);
|
||||
|
||||
if ($calendar !== null) {
|
||||
$this->calDavBackend->deleteCalendar($calendar['id']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $table
|
||||
* @param $backendId
|
||||
* @param $resourceId
|
||||
* @return int
|
||||
*/
|
||||
private function getIdForBackendAndResource(string $table,
|
||||
string $backendId,
|
||||
string $resourceId):int {
|
||||
$query = $this->dbConnection->getQueryBuilder();
|
||||
$query->select('id')
|
||||
->from($table)
|
||||
->where($query->expr()->eq('backend_id', $query->createNamedParameter($backendId)))
|
||||
->andWhere($query->expr()->eq('resource_id', $query->createNamedParameter($resourceId)));
|
||||
$stmt = $query->execute();
|
||||
|
||||
return $stmt->fetch(\PDO::FETCH_NAMED)['id'];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright 2018, Georg Ehrke <oc.list@georgehrke.com>
|
||||
* @copyright 2019, Georg Ehrke <oc.list@georgehrke.com>
|
||||
*
|
||||
* @author Georg Ehrke <oc.list@georgehrke.com>
|
||||
*
|
||||
|
@ -50,6 +50,12 @@ abstract class AbstractPrincipalBackend implements BackendInterface {
|
|||
/** @var string */
|
||||
private $dbTableName;
|
||||
|
||||
/** @var string */
|
||||
private $dbMetaDataTableName;
|
||||
|
||||
/** @var string */
|
||||
private $dbForeignKeyName;
|
||||
|
||||
/** @var string */
|
||||
private $cuType;
|
||||
|
||||
|
@ -74,7 +80,9 @@ abstract class AbstractPrincipalBackend implements BackendInterface {
|
|||
$this->groupManager = $groupManager;
|
||||
$this->logger = $logger;
|
||||
$this->principalPrefix = $principalPrefix;
|
||||
$this->dbTableName = 'calendar_' . $dbPrefix;
|
||||
$this->dbTableName = 'calendar_' . $dbPrefix . 's';
|
||||
$this->dbMetaDataTableName = $this->dbTableName . '_md';
|
||||
$this->dbForeignKeyName = $dbPrefix . '_id';
|
||||
$this->cuType = $cuType;
|
||||
}
|
||||
|
||||
|
@ -100,8 +108,31 @@ abstract class AbstractPrincipalBackend implements BackendInterface {
|
|||
->from($this->dbTableName);
|
||||
$stmt = $query->execute();
|
||||
|
||||
$metaDataQuery = $this->db->getQueryBuilder();
|
||||
$metaDataQuery->select([$this->dbForeignKeyName, 'key', 'value'])
|
||||
->from($this->dbMetaDataTableName);
|
||||
$metaDataStmt = $metaDataQuery->execute();
|
||||
$metaDataRows = $metaDataStmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
|
||||
$metaDataById = [];
|
||||
foreach($metaDataRows as $metaDataRow) {
|
||||
if (!isset($metaDataById[$metaDataRow[$this->dbForeignKeyName]])) {
|
||||
$metaDataById[$metaDataRow[$this->dbForeignKeyName]] = [];
|
||||
}
|
||||
|
||||
$metaDataById[$metaDataRow[$this->dbForeignKeyName]][$metaDataRow['key']] =
|
||||
$metaDataRow['value'];
|
||||
}
|
||||
|
||||
while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
|
||||
$principals[] = $this->rowToPrincipal($row);
|
||||
$id = $row['id'];
|
||||
|
||||
if (isset($metaDataById[$id])) {
|
||||
$principals[] = $this->rowToPrincipal($row, $metaDataById[$id]);
|
||||
} else {
|
||||
$principals[] = $this->rowToPrincipal($row);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$stmt->closeCursor();
|
||||
|
@ -138,7 +169,50 @@ abstract class AbstractPrincipalBackend implements BackendInterface {
|
|||
return null;
|
||||
}
|
||||
|
||||
return $this->rowToPrincipal($row);
|
||||
$metaDataQuery = $this->db->getQueryBuilder();
|
||||
$metaDataQuery->select(['key', 'value'])
|
||||
->from($this->dbMetaDataTableName)
|
||||
->where($metaDataQuery->expr()->eq($this->dbForeignKeyName, $metaDataQuery->createNamedParameter($row['id'])));
|
||||
$metaDataStmt = $metaDataQuery->execute();
|
||||
$metaDataRows = $metaDataStmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
$metadata = [];
|
||||
|
||||
foreach($metaDataRows as $metaDataRow) {
|
||||
$metadata[$metaDataRow['key']] = $metaDataRow['value'];
|
||||
}
|
||||
|
||||
return $this->rowToPrincipal($row, $metadata);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @return array|null
|
||||
*/
|
||||
public function getPrincipalById($id):?array {
|
||||
$query = $this->db->getQueryBuilder();
|
||||
$query->select(['id', 'backend_id', 'resource_id', 'email', 'displayname'])
|
||||
->from($this->dbTableName)
|
||||
->where($query->expr()->eq('id', $query->createNamedParameter($id)));
|
||||
$stmt = $query->execute();
|
||||
$row = $stmt->fetch(\PDO::FETCH_ASSOC);
|
||||
|
||||
if(!$row) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$metaDataQuery = $this->db->getQueryBuilder();
|
||||
$metaDataQuery->select(['key', 'value'])
|
||||
->from($this->dbMetaDataTableName)
|
||||
->where($metaDataQuery->expr()->eq($this->dbForeignKeyName, $metaDataQuery->createNamedParameter($row['id'])));
|
||||
$metaDataStmt = $metaDataQuery->execute();
|
||||
$metaDataRows = $metaDataStmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
$metadata = [];
|
||||
|
||||
foreach($metaDataRows as $metaDataRow) {
|
||||
$metadata[$metaDataRow['key']] = $metaDataRow['value'];
|
||||
}
|
||||
|
||||
return $this->rowToPrincipal($row, $metadata);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -253,7 +327,15 @@ abstract class AbstractPrincipalBackend implements BackendInterface {
|
|||
break;
|
||||
|
||||
default:
|
||||
$results[] = [];
|
||||
$rowsByMetadata = $this->searchPrincipalsByMetadataKey($prop, $value);
|
||||
$filteredRows = array_filter($rowsByMetadata, function($row) use ($usersGroups) {
|
||||
return $this->isAllowedToAccessResource($row, $usersGroups);
|
||||
});
|
||||
|
||||
$results[] = array_map(function($row) {
|
||||
return $row['uri'];
|
||||
}, $filteredRows);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -274,6 +356,39 @@ abstract class AbstractPrincipalBackend implements BackendInterface {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches principals based on their metadata keys.
|
||||
* This allows to search for all principals with a specific key.
|
||||
* e.g.:
|
||||
* '{http://nextcloud.com/ns}room-building-address' => 'ABC Street 123, ...'
|
||||
*
|
||||
* @param $key
|
||||
* @param $value
|
||||
* @return array
|
||||
*/
|
||||
private function searchPrincipalsByMetadataKey($key, $value):array {
|
||||
$query = $this->db->getQueryBuilder();
|
||||
$query->select([$this->dbForeignKeyName])
|
||||
->from($this->dbMetaDataTableName)
|
||||
->where($query->expr()->eq('key', $query->createNamedParameter($key)))
|
||||
->andWhere($query->expr()->iLike('value', $query->createNamedParameter('%' . $this->db->escapeLikeParameter($value) . '%')));
|
||||
$stmt = $query->execute();
|
||||
|
||||
$rows = [];
|
||||
while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
|
||||
$id = $row[$this->dbForeignKeyName];
|
||||
|
||||
$principalRow = $this->getPrincipalById($id);
|
||||
if (!$principalRow) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$rows[] = $principalRow;
|
||||
}
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $uri
|
||||
* @param string $principalPrefix
|
||||
|
@ -338,14 +453,18 @@ abstract class AbstractPrincipalBackend implements BackendInterface {
|
|||
|
||||
/**
|
||||
* convert database row to principal
|
||||
*
|
||||
* @param String[] $row
|
||||
* @param String[] $metadata
|
||||
* @return Array
|
||||
*/
|
||||
private function rowToPrincipal($row) {
|
||||
return [
|
||||
private function rowToPrincipal(array $row, array $metadata=[]):array {
|
||||
return array_merge([
|
||||
'uri' => $this->principalPrefix . '/' . $row['backend_id'] . '-' . $row['resource_id'],
|
||||
'{DAV:}displayname' => $row['displayname'],
|
||||
'{http://sabredav.org/ns}email-address' => $row['email'],
|
||||
'{urn:ietf:params:xml:ns:caldav}calendar-user-type' => $this->cuType,
|
||||
];
|
||||
], $metadata);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -353,7 +472,7 @@ abstract class AbstractPrincipalBackend implements BackendInterface {
|
|||
* @param $userGroups
|
||||
* @return bool
|
||||
*/
|
||||
private function isAllowedToAccessResource($row, $userGroups) {
|
||||
private function isAllowedToAccessResource(array $row, array $userGroups):bool {
|
||||
if (!isset($row['group_restrictions']) ||
|
||||
$row['group_restrictions'] === null ||
|
||||
$row['group_restrictions'] === '') {
|
||||
|
|
|
@ -40,6 +40,6 @@ class ResourcePrincipalBackend extends AbstractPrincipalBackend {
|
|||
IGroupManager $groupManager,
|
||||
ILogger $logger) {
|
||||
parent::__construct($dbConnection, $userSession, $groupManager, $logger,
|
||||
'principals/calendar-resources', 'resources', 'RESOURCE');
|
||||
'principals/calendar-resources', 'resource', 'RESOURCE');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,6 +40,6 @@ class RoomPrincipalBackend extends AbstractPrincipalBackend {
|
|||
IGroupManager $groupManager,
|
||||
ILogger $logger) {
|
||||
parent::__construct($dbConnection, $userSession, $groupManager, $logger,
|
||||
'principals/calendar-rooms', 'rooms', 'ROOM');
|
||||
'principals/calendar-rooms', 'room', 'ROOM');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OCA\DAV\Migration;
|
||||
|
||||
use Closure;
|
||||
use Doctrine\DBAL\Types\Type;
|
||||
use OCP\DB\ISchemaWrapper;
|
||||
use OCP\Migration\SimpleMigrationStep;
|
||||
use OCP\Migration\IOutput;
|
||||
|
||||
/**
|
||||
* Auto-generated migration step: Please modify to your needs!
|
||||
*/
|
||||
class Version1011Date20190725113607 extends SimpleMigrationStep {
|
||||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param array $options
|
||||
* @return null|ISchemaWrapper
|
||||
* @since 13.0.0
|
||||
*/
|
||||
public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) {
|
||||
/** @var ISchemaWrapper $schema */
|
||||
$schema = $schemaClosure();
|
||||
|
||||
$types = ['resource', 'room'];
|
||||
foreach($types as $type) {
|
||||
if (!$schema->hasTable($this->getMetadataTableName($type))) {
|
||||
$table = $schema->createTable($this->getMetadataTableName($type));
|
||||
|
||||
$table->addColumn('id', Type::BIGINT, [
|
||||
'autoincrement' => true,
|
||||
'notnull' => true,
|
||||
'length' => 11,
|
||||
'unsigned' => true,
|
||||
]);
|
||||
$table->addColumn($type . '_id', Type::BIGINT, [
|
||||
'notnull' => true,
|
||||
'length' => 11,
|
||||
'unsigned' => true,
|
||||
]);
|
||||
$table->addColumn('key', Type::STRING, [
|
||||
'notnull' => true,
|
||||
'length' => 255,
|
||||
]);
|
||||
$table->addColumn('value', Type::STRING, [
|
||||
'notnull' => false,
|
||||
'length' => 4000,
|
||||
]);
|
||||
|
||||
$table->setPrimaryKey(['id']);
|
||||
$table->addIndex([$type . '_id', 'key'], $this->getMetadataTableName($type) . '_idk');
|
||||
}
|
||||
}
|
||||
|
||||
return $schema;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
* @return string
|
||||
*/
|
||||
private function getMetadataTableName(string $type):string {
|
||||
return 'calendar_' . $type . 's_md';
|
||||
}
|
||||
}
|
|
@ -26,6 +26,7 @@ use OCA\DAV\BackgroundJob\UpdateCalendarResourcesRoomsBackgroundJob;
|
|||
|
||||
use OCA\DAV\CalDAV\CalDavBackend;
|
||||
use OCP\Calendar\BackendTemporarilyUnavailableException;
|
||||
use OCP\Calendar\IMetadataProvider;
|
||||
use OCP\Calendar\Resource\IBackend;
|
||||
use OCP\Calendar\Resource\IManager as IResourceManager;
|
||||
use OCP\Calendar\Resource\IResource;
|
||||
|
@ -61,34 +62,38 @@ class UpdateCalendarResourcesRoomsBackgroundJobTest extends TestCase {
|
|||
protected function tearDown() {
|
||||
$query = self::$realDatabase->getQueryBuilder();
|
||||
$query->delete('calendar_resources')->execute();
|
||||
$query->delete('calendar_resources_md')->execute();
|
||||
$query->delete('calendar_rooms')->execute();
|
||||
$query->delete('calendar_rooms_md')->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Data in Cache:
|
||||
* resources:
|
||||
* [backend1, res1, Beamer1, {}]
|
||||
* [backend1, res2, TV1, {}]
|
||||
* [backend2, res3, Beamer2, {}]
|
||||
* [backend2, res4, TV2, {}]
|
||||
* [backend3, res5, Beamer3, {}]
|
||||
* [backend3, res6, Pointer, {foo, bar}]
|
||||
* [backend1, res1, Beamer1, {}] - []
|
||||
* [backend1, res2, TV1, {}] - []
|
||||
* [backend2, res3, Beamer2, {}] - ['meta1' => 'value1', 'meta2' => 'value2']
|
||||
* [backend2, res4, TV2, {}] - ['meta1' => 'value1', 'meta3' => 'value3-old']
|
||||
* [backend3, res5, Beamer3, {}] - []
|
||||
* [backend3, res6, Pointer, {foo, bar}] - ['meta99' => 'value99']
|
||||
*
|
||||
* Data in Backend:
|
||||
* backend1 gone
|
||||
* backend2 throws BackendTemporarilyUnavailableException
|
||||
* [backend3, res6, Pointer123, {foo, biz}]
|
||||
* [backend3, res7, Resource4, {biz}]
|
||||
* [backend4, res8, Beamer, {}]
|
||||
* [backend4, res9, Beamer2, {}]
|
||||
* [backend3, res6, Pointer123, {foo, biz}] - ['meta99' => 'value99-new', 'meta123' => 'meta456']
|
||||
* [backend3, res7, Resource4, {biz}] - ['meta1' => 'value1']
|
||||
* [backend4, res8, Beamer, {}] - ['meta2' => 'value2']
|
||||
* [backend4, res9, Beamer2, {}] - []
|
||||
*
|
||||
* Expected after run:
|
||||
* [backend2, res3, Beamer2, {}]
|
||||
* [backend2, res4, TV2, {}]
|
||||
* [backend3, res6, Pointer123, {foo, biz}]
|
||||
* [backend3, res7, Resource4, {biz}]
|
||||
* [backend4, res8, Beamer, {}]
|
||||
* [backend4, res9, Beamer2, {}]
|
||||
* [backend1, res1, Beamer1, {}] - []
|
||||
* [backend1, res2, TV1, {}] - []
|
||||
* [backend2, res3, Beamer2, {}] - ['meta1' => 'value1', 'meta2' => 'value2']
|
||||
* [backend2, res4, TV2, {}] - ['meta1' => 'value1', 'meta3' => 'value3-old']
|
||||
* [backend3, res6, Pointer123, {foo, biz}] - ['meta99' => 'value99-new', 'meta123' => 'meta456']
|
||||
* [backend3, res7, Resource4, {biz}] - ['meta1' => 'value1']
|
||||
* [backend4, res8, Beamer, {}] - ['meta2' => 'value2']
|
||||
* [backend4, res9, Beamer2, {}] - []
|
||||
*/
|
||||
|
||||
public function testRun() {
|
||||
|
@ -98,9 +103,9 @@ class UpdateCalendarResourcesRoomsBackgroundJobTest extends TestCase {
|
|||
$backend3 = $this->createMock(IBackend::class);
|
||||
$backend4 = $this->createMock(IBackend::class);
|
||||
|
||||
$res6 = $this->createMock(IResource::class);
|
||||
$res7 = $this->createMock(IResource::class);
|
||||
$res8 = $this->createMock(IResource::class);
|
||||
$res6 = $this->createMock([IResource::class, IMetadataProvider::class]);
|
||||
$res7 = $this->createMock([IResource::class, IMetadataProvider::class]);
|
||||
$res8 = $this->createMock([IResource::class, IMetadataProvider::class]);
|
||||
$res9 = $this->createMock(IResource::class);
|
||||
|
||||
$backend2->method('getBackendIdentifier')
|
||||
|
@ -136,17 +141,51 @@ class UpdateCalendarResourcesRoomsBackgroundJobTest extends TestCase {
|
|||
$res6->method('getEMail')->will($this->returnValue('res6@foo.bar'));
|
||||
$res6->method('getBackend')->will($this->returnValue($backend3));
|
||||
|
||||
$res6->method('getAllAvailableMetadataKeys')->will($this->returnValue(['meta99', 'meta123']));
|
||||
$res6->method('getMetadataForKey')->will($this->returnCallback(function($key) {
|
||||
switch($key) {
|
||||
case 'meta99':
|
||||
return 'value99-new';
|
||||
|
||||
case 'meta123':
|
||||
return 'meta456';
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}));
|
||||
|
||||
$res7->method('getId')->will($this->returnValue('res7'));
|
||||
$res7->method('getDisplayName')->will($this->returnValue('Resource4'));
|
||||
$res7->method('getGroupRestrictions')->will($this->returnValue(['biz']));
|
||||
$res7->method('getEMail')->will($this->returnValue('res7@foo.bar'));
|
||||
$res7->method('getBackend')->will($this->returnValue($backend3));
|
||||
$res7->method('getAllAvailableMetadataKeys')->will($this->returnValue(['meta1']));
|
||||
$res7->method('getMetadataForKey')->will($this->returnCallback(function($key) {
|
||||
switch($key) {
|
||||
case 'meta1':
|
||||
return 'value1';
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}));
|
||||
|
||||
$res8->method('getId')->will($this->returnValue('res8'));
|
||||
$res8->method('getDisplayName')->will($this->returnValue('Beamer'));
|
||||
$res8->method('getGroupRestrictions')->will($this->returnValue([]));
|
||||
$res8->method('getEMail')->will($this->returnValue('res8@foo.bar'));
|
||||
$res8->method('getBackend')->will($this->returnValue($backend4));
|
||||
$res8->method('getAllAvailableMetadataKeys')->will($this->returnValue(['meta2']));
|
||||
$res8->method('getMetadataForKey')->will($this->returnCallback(function($key) {
|
||||
switch($key) {
|
||||
case 'meta2':
|
||||
return 'value2';
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}));
|
||||
|
||||
$res9->method('getId')->will($this->returnValue('res9'));
|
||||
$res9->method('getDisplayName')->will($this->returnValue('Beamer2'));
|
||||
|
@ -173,13 +212,29 @@ class UpdateCalendarResourcesRoomsBackgroundJobTest extends TestCase {
|
|||
$query->select('*')->from('calendar_resources');
|
||||
|
||||
$rows = [];
|
||||
$ids = [];
|
||||
$stmt = $query->execute();
|
||||
while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
|
||||
$ids[$row['backend_id'] . '::' . $row['resource_id']] = $row['id'];
|
||||
unset($row['id']);
|
||||
$rows[] = $row;
|
||||
}
|
||||
|
||||
$this->assertEquals([
|
||||
[
|
||||
'backend_id' => 'backend1',
|
||||
'resource_id' => 'res1',
|
||||
'displayname' => 'Beamer1',
|
||||
'email' => 'res1@foo.bar',
|
||||
'group_restrictions' => '[]',
|
||||
],
|
||||
[
|
||||
'backend_id' => 'backend1',
|
||||
'resource_id' => 'res2',
|
||||
'displayname' => 'TV1',
|
||||
'email' => 'res2@foo.bar',
|
||||
'group_restrictions' => '[]',
|
||||
],
|
||||
[
|
||||
'backend_id' => 'backend2',
|
||||
'resource_id' => 'res3',
|
||||
|
@ -223,6 +278,59 @@ class UpdateCalendarResourcesRoomsBackgroundJobTest extends TestCase {
|
|||
'group_restrictions' => '[]',
|
||||
],
|
||||
], $rows);
|
||||
|
||||
$query2 = self::$realDatabase->getQueryBuilder();
|
||||
$query2->select('*')->from('calendar_resources_md');
|
||||
|
||||
$rows2 = [];
|
||||
$stmt = $query2->execute();
|
||||
while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
|
||||
unset($row['id']);
|
||||
$rows2[] = $row;
|
||||
}
|
||||
|
||||
$this->assertEquals([
|
||||
[
|
||||
'resource_id' => $ids['backend2::res3'],
|
||||
'key' => 'meta1',
|
||||
'value' => 'value1',
|
||||
],
|
||||
[
|
||||
'resource_id' => $ids['backend2::res3'],
|
||||
'key' => 'meta2',
|
||||
'value' => 'value2',
|
||||
],
|
||||
[
|
||||
'resource_id' => $ids['backend2::res4'],
|
||||
'key' => 'meta1',
|
||||
'value' => 'value1',
|
||||
],
|
||||
[
|
||||
'resource_id' => $ids['backend2::res4'],
|
||||
'key' => 'meta3',
|
||||
'value' => 'value3-old',
|
||||
],
|
||||
[
|
||||
'resource_id' => $ids['backend3::res6'],
|
||||
'key' => 'meta99',
|
||||
'value' => 'value99-new',
|
||||
],
|
||||
[
|
||||
'resource_id' => $ids['backend3::res7'],
|
||||
'key' => 'meta1',
|
||||
'value' => 'value1',
|
||||
],
|
||||
[
|
||||
'resource_id' => $ids['backend3::res6'],
|
||||
'key' => 'meta123',
|
||||
'value' => 'meta456',
|
||||
],
|
||||
[
|
||||
'resource_id' => $ids['backend4::res8'],
|
||||
'key' => 'meta2',
|
||||
'value' => 'value2',
|
||||
]
|
||||
], $rows2);
|
||||
}
|
||||
|
||||
protected function createTestResourcesInCache() {
|
||||
|
@ -236,6 +344,7 @@ class UpdateCalendarResourcesRoomsBackgroundJobTest extends TestCase {
|
|||
'group_restrictions' => $query->createNamedParameter('[]'),
|
||||
])
|
||||
->execute();
|
||||
|
||||
$query->insert('calendar_resources')
|
||||
->values([
|
||||
'backend_id' => $query->createNamedParameter('backend1'),
|
||||
|
@ -245,6 +354,7 @@ class UpdateCalendarResourcesRoomsBackgroundJobTest extends TestCase {
|
|||
'group_restrictions' => $query->createNamedParameter('[]'),
|
||||
])
|
||||
->execute();
|
||||
|
||||
$query->insert('calendar_resources')
|
||||
->values([
|
||||
'backend_id' => $query->createNamedParameter('backend2'),
|
||||
|
@ -254,6 +364,8 @@ class UpdateCalendarResourcesRoomsBackgroundJobTest extends TestCase {
|
|||
'group_restrictions' => $query->createNamedParameter('[]'),
|
||||
])
|
||||
->execute();
|
||||
$id3 = $query->getLastInsertId();
|
||||
|
||||
$query->insert('calendar_resources')
|
||||
->values([
|
||||
'backend_id' => $query->createNamedParameter('backend2'),
|
||||
|
@ -263,6 +375,8 @@ class UpdateCalendarResourcesRoomsBackgroundJobTest extends TestCase {
|
|||
'group_restrictions' => $query->createNamedParameter('[]'),
|
||||
])
|
||||
->execute();
|
||||
$id4 = $query->getLastInsertId();
|
||||
|
||||
$query->insert('calendar_resources')
|
||||
->values([
|
||||
'backend_id' => $query->createNamedParameter('backend3'),
|
||||
|
@ -272,6 +386,7 @@ class UpdateCalendarResourcesRoomsBackgroundJobTest extends TestCase {
|
|||
'group_restrictions' => $query->createNamedParameter('[]'),
|
||||
])
|
||||
->execute();
|
||||
|
||||
$query->insert('calendar_resources')
|
||||
->values([
|
||||
'backend_id' => $query->createNamedParameter('backend3'),
|
||||
|
@ -281,5 +396,42 @@ class UpdateCalendarResourcesRoomsBackgroundJobTest extends TestCase {
|
|||
'group_restrictions' => $query->createNamedParameter('["foo", "bar"]'),
|
||||
])
|
||||
->execute();
|
||||
$id6 = $query->getLastInsertId();
|
||||
|
||||
$query->insert('calendar_resources_md')
|
||||
->values([
|
||||
'resource_id' => $query->createNamedParameter($id3),
|
||||
'key' => $query->createNamedParameter('meta1'),
|
||||
'value' => $query->createNamedParameter('value1')
|
||||
])
|
||||
->execute();
|
||||
$query->insert('calendar_resources_md')
|
||||
->values([
|
||||
'resource_id' => $query->createNamedParameter($id3),
|
||||
'key' => $query->createNamedParameter('meta2'),
|
||||
'value' => $query->createNamedParameter('value2')
|
||||
])
|
||||
->execute();
|
||||
$query->insert('calendar_resources_md')
|
||||
->values([
|
||||
'resource_id' => $query->createNamedParameter($id4),
|
||||
'key' => $query->createNamedParameter('meta1'),
|
||||
'value' => $query->createNamedParameter('value1')
|
||||
])
|
||||
->execute();
|
||||
$query->insert('calendar_resources_md')
|
||||
->values([
|
||||
'resource_id' => $query->createNamedParameter($id4),
|
||||
'key' => $query->createNamedParameter('meta3'),
|
||||
'value' => $query->createNamedParameter('value3-old')
|
||||
])
|
||||
->execute();
|
||||
$query->insert('calendar_resources_md')
|
||||
->values([
|
||||
'resource_id' => $query->createNamedParameter($id6),
|
||||
'key' => $query->createNamedParameter('meta99'),
|
||||
'value' => $query->createNamedParameter('value99')
|
||||
])
|
||||
->execute();
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -27,10 +27,16 @@ Class ResourcePrincipalBackendTest extends AbstractPrincipalBackendTest {
|
|||
public function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->principalBackend = new ResourcePrincipalBackend($this->dbConnection,
|
||||
$this->principalBackend = new ResourcePrincipalBackend(self::$realDatabase,
|
||||
$this->userSession, $this->groupManager, $this->logger);
|
||||
$this->expectedDbTable = 'calendar_resources';
|
||||
|
||||
$this->mainDbTable = 'calendar_resources';
|
||||
$this->metadataDbTable = 'calendar_resources_md';
|
||||
$this->foreignKey = 'resource_id';
|
||||
|
||||
$this->principalPrefix = 'principals/calendar-resources';
|
||||
$this->expectedCUType = 'RESOURCE';
|
||||
|
||||
$this->createTestDatasetInDb();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,10 +27,16 @@ Class RoomPrincipalBackendTest extends AbstractPrincipalBackendTest {
|
|||
public function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->principalBackend = new RoomPrincipalBackend($this->dbConnection,
|
||||
$this->principalBackend = new RoomPrincipalBackend(self::$realDatabase,
|
||||
$this->userSession, $this->groupManager, $this->logger);
|
||||
$this->expectedDbTable = 'calendar_rooms';
|
||||
|
||||
$this->mainDbTable = 'calendar_rooms';
|
||||
$this->metadataDbTable = 'calendar_rooms_md';
|
||||
$this->foreignKey = 'room_id';
|
||||
|
||||
$this->principalPrefix = 'principals/calendar-rooms';
|
||||
$this->expectedCUType = 'ROOM';
|
||||
|
||||
$this->createTestDatasetInDb();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -100,12 +100,15 @@ return array(
|
|||
'OCP\\Calendar\\BackendTemporarilyUnavailableException' => $baseDir . '/lib/public/Calendar/BackendTemporarilyUnavailableException.php',
|
||||
'OCP\\Calendar\\ICalendar' => $baseDir . '/lib/public/Calendar/ICalendar.php',
|
||||
'OCP\\Calendar\\IManager' => $baseDir . '/lib/public/Calendar/IManager.php',
|
||||
'OCP\\Calendar\\IMetadataProvider' => $baseDir . '/lib/public/Calendar/IMetadataProvider.php',
|
||||
'OCP\\Calendar\\Resource\\IBackend' => $baseDir . '/lib/public/Calendar/Resource/IBackend.php',
|
||||
'OCP\\Calendar\\Resource\\IManager' => $baseDir . '/lib/public/Calendar/Resource/IManager.php',
|
||||
'OCP\\Calendar\\Resource\\IResource' => $baseDir . '/lib/public/Calendar/Resource/IResource.php',
|
||||
'OCP\\Calendar\\Resource\\IResourceMetadata' => $baseDir . '/lib/public/Calendar/Resource/IResourceMetadata.php',
|
||||
'OCP\\Calendar\\Room\\IBackend' => $baseDir . '/lib/public/Calendar/Room/IBackend.php',
|
||||
'OCP\\Calendar\\Room\\IManager' => $baseDir . '/lib/public/Calendar/Room/IManager.php',
|
||||
'OCP\\Calendar\\Room\\IRoom' => $baseDir . '/lib/public/Calendar/Room/IRoom.php',
|
||||
'OCP\\Calendar\\Room\\IRoomMetadata' => $baseDir . '/lib/public/Calendar/Room/IRoomMetadata.php',
|
||||
'OCP\\Capabilities\\ICapability' => $baseDir . '/lib/public/Capabilities/ICapability.php',
|
||||
'OCP\\Capabilities\\IPublicCapability' => $baseDir . '/lib/public/Capabilities/IPublicCapability.php',
|
||||
'OCP\\Collaboration\\AutoComplete\\AutoCompleteEvent' => $baseDir . '/lib/public/Collaboration/AutoComplete/AutoCompleteEvent.php',
|
||||
|
|
|
@ -134,12 +134,15 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
|
|||
'OCP\\Calendar\\BackendTemporarilyUnavailableException' => __DIR__ . '/../../..' . '/lib/public/Calendar/BackendTemporarilyUnavailableException.php',
|
||||
'OCP\\Calendar\\ICalendar' => __DIR__ . '/../../..' . '/lib/public/Calendar/ICalendar.php',
|
||||
'OCP\\Calendar\\IManager' => __DIR__ . '/../../..' . '/lib/public/Calendar/IManager.php',
|
||||
'OCP\\Calendar\\IMetadataProvider' => __DIR__ . '/../../..' . '/lib/public/Calendar/IMetadataProvider.php',
|
||||
'OCP\\Calendar\\Resource\\IBackend' => __DIR__ . '/../../..' . '/lib/public/Calendar/Resource/IBackend.php',
|
||||
'OCP\\Calendar\\Resource\\IManager' => __DIR__ . '/../../..' . '/lib/public/Calendar/Resource/IManager.php',
|
||||
'OCP\\Calendar\\Resource\\IResource' => __DIR__ . '/../../..' . '/lib/public/Calendar/Resource/IResource.php',
|
||||
'OCP\\Calendar\\Resource\\IResourceMetadata' => __DIR__ . '/../../..' . '/lib/public/Calendar/Resource/IResourceMetadata.php',
|
||||
'OCP\\Calendar\\Room\\IBackend' => __DIR__ . '/../../..' . '/lib/public/Calendar/Room/IBackend.php',
|
||||
'OCP\\Calendar\\Room\\IManager' => __DIR__ . '/../../..' . '/lib/public/Calendar/Room/IManager.php',
|
||||
'OCP\\Calendar\\Room\\IRoom' => __DIR__ . '/../../..' . '/lib/public/Calendar/Room/IRoom.php',
|
||||
'OCP\\Calendar\\Room\\IRoomMetadata' => __DIR__ . '/../../..' . '/lib/public/Calendar/Room/IRoomMetadata.php',
|
||||
'OCP\\Capabilities\\ICapability' => __DIR__ . '/../../..' . '/lib/public/Capabilities/ICapability.php',
|
||||
'OCP\\Capabilities\\IPublicCapability' => __DIR__ . '/../../..' . '/lib/public/Capabilities/IPublicCapability.php',
|
||||
'OCP\\Collaboration\\AutoComplete\\AutoCompleteEvent' => __DIR__ . '/../../..' . '/lib/public/Collaboration/AutoComplete/AutoCompleteEvent.php',
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright 2019, Georg Ehrke <oc.list@georgehrke.com>
|
||||
*
|
||||
* @author Georg Ehrke <oc.list@georgehrke.com>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCP\Calendar;
|
||||
|
||||
/**
|
||||
* Interface IMetadataProvider
|
||||
*
|
||||
* Provider for metadata of a resource or a room
|
||||
*
|
||||
* @package OCP\Calendar
|
||||
* @since 17.0.0
|
||||
*/
|
||||
interface IMetadataProvider {
|
||||
|
||||
/**
|
||||
* Get a list of all metadata keys available for this room
|
||||
*
|
||||
* Room backends are allowed to return custom keys, beyond the ones
|
||||
* defined in this class. If they do, they should make sure to use their
|
||||
* own namespace.
|
||||
*
|
||||
* @return String[] - A list of available keys
|
||||
* @since 17.0.0
|
||||
*/
|
||||
public function getAllAvailableMetadataKeys():array;
|
||||
|
||||
/**
|
||||
* Get whether or not a metadata key is set for this room
|
||||
*
|
||||
* @param string $key - The key to check for
|
||||
* @return bool - Whether or not key is available
|
||||
* @since 17.0.0
|
||||
*/
|
||||
public function hasMetadataForKey(string $key):bool;
|
||||
|
||||
/**
|
||||
* Get the value for a metadata key
|
||||
*
|
||||
* @param string $key - The key to check for
|
||||
* @return string|null - The value stored for the key, null if no value stored
|
||||
* @since 17.0.0
|
||||
*/
|
||||
public function getMetadataForKey(string $key):?string;
|
||||
}
|
|
@ -0,0 +1,118 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright 2019, Georg Ehrke <oc.list@georgehrke.com>
|
||||
*
|
||||
* @author Georg Ehrke <oc.list@georgehrke.com>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCP\Calendar\Resource;
|
||||
|
||||
/**
|
||||
* Interface IResourceMetadata
|
||||
*
|
||||
* This interface provides keys for common metadata.
|
||||
* Resource Backends are not limited to this list and can provide
|
||||
* any metadata they want.
|
||||
*
|
||||
* @package OCP\Calendar\Resource
|
||||
* @since 17.0.0
|
||||
*/
|
||||
interface IResourceMetadata {
|
||||
|
||||
/**
|
||||
* Type of resource
|
||||
*
|
||||
* Allowed values for this key include:
|
||||
* - projector
|
||||
* - tv
|
||||
* - vehicle
|
||||
* - other
|
||||
*
|
||||
* @since 17.0.0
|
||||
*/
|
||||
public const RESOURCE_TYPE = '{http://nextcloud.com/ns}resource-type';
|
||||
|
||||
/**
|
||||
* If resource is of type vehicle, this describes the type of vehicle
|
||||
*
|
||||
* Allowed values:
|
||||
* - bicycle
|
||||
* - scooter
|
||||
* - motorbike
|
||||
* - car
|
||||
* - plane
|
||||
* - helicopter
|
||||
* - other
|
||||
*
|
||||
* @since 17.0.0
|
||||
*/
|
||||
public const VEHICLE_TYPE = '{http://nextcloud.com/ns}resource-vehicle-type';
|
||||
|
||||
/**
|
||||
* Make of the vehicle
|
||||
*
|
||||
* @since 17.0.0
|
||||
*/
|
||||
public const VEHICLE_MAKE = '{http://nextcloud.com/ns}resource-vehicle-make';
|
||||
|
||||
/**
|
||||
* Model of the vehicle
|
||||
*
|
||||
* @since 17.0.0
|
||||
*/
|
||||
public const VEHICLE_MODEL = '{http://nextcloud.com/ns}resource-vehicle-model';
|
||||
|
||||
/**
|
||||
* Whether or not the car is electric
|
||||
*
|
||||
* use '1' for electric, '0' for non-electric
|
||||
*
|
||||
* @since 17.0.0
|
||||
*/
|
||||
public const VEHICLE_IS_ELECTRIC = '{http://nextcloud.com/ns}resource-vehicle-is-electric';
|
||||
|
||||
/**
|
||||
* Range of vehicle with a full tank
|
||||
*
|
||||
* @since 17.0.0
|
||||
*/
|
||||
public const VEHICLE_RANGE = '{http://nextcloud.com/ns}resource-vehicle-range';
|
||||
|
||||
/**
|
||||
* Seating capacity of the vehicle
|
||||
*
|
||||
* @since 17.0.0
|
||||
*/
|
||||
public const VEHICLE_SEATING_CAPACITY = '{http://nextcloud.com/ns}resource-vehicle-seating-capacity';
|
||||
|
||||
/**
|
||||
* Contact information about the person who is responsible to administer / maintain this resource
|
||||
* This key stores a textual description of name and possible ways to contact the person
|
||||
*
|
||||
* @since 17.0.0
|
||||
*/
|
||||
public const CONTACT_PERSON = '{http://nextcloud.com/ns}resource-contact-person';
|
||||
|
||||
/**
|
||||
* Link to the vcard of the contact person
|
||||
*
|
||||
* @since 17.0.0
|
||||
*/
|
||||
public const CONTACT_PERSON_VCARD = '{http://nextcloud.com/ns}resource-contact-person-vcard';
|
||||
}
|
|
@ -32,7 +32,7 @@ namespace OCP\Calendar\Room;
|
|||
interface IRoom {
|
||||
|
||||
/**
|
||||
* get the room id
|
||||
* Get a unique ID for the room
|
||||
*
|
||||
* This id has to be unique within the backend
|
||||
*
|
||||
|
@ -42,7 +42,7 @@ interface IRoom {
|
|||
public function getId():string;
|
||||
|
||||
/**
|
||||
* get the display name for a room
|
||||
* Get the display name for the room
|
||||
*
|
||||
* @return string
|
||||
* @since 14.0.0
|
||||
|
@ -61,9 +61,9 @@ interface IRoom {
|
|||
public function getGroupRestrictions():array;
|
||||
|
||||
/**
|
||||
* get email-address for room
|
||||
* Get the email-address for the room
|
||||
*
|
||||
* The email address has to be globally unique
|
||||
* The email-address has to be globally unique
|
||||
*
|
||||
* @return string
|
||||
* @since 14.0.0
|
||||
|
|
|
@ -0,0 +1,95 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright 2019, Georg Ehrke <oc.list@georgehrke.com>
|
||||
*
|
||||
* @author Georg Ehrke <oc.list@georgehrke.com>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCP\Calendar\Room;
|
||||
|
||||
/**
|
||||
* Interface IRoomMetadata
|
||||
*
|
||||
* This interface provides keys for common metadata.
|
||||
* Room Backends are not limited to this list and can provide
|
||||
* any metadata they want.
|
||||
*
|
||||
* @package OCP\Calendar\Room
|
||||
* @since 17.0.0
|
||||
*/
|
||||
interface IRoomMetadata {
|
||||
|
||||
/**
|
||||
* Type of room
|
||||
*
|
||||
* Allowed values for this key include:
|
||||
* - meeting-room
|
||||
* - lecture-hall
|
||||
* - seminar-room
|
||||
* - other
|
||||
*
|
||||
* @since 17.0.0
|
||||
*/
|
||||
public const ROOM_TYPE = '{http://nextcloud.com/ns}room-type';
|
||||
|
||||
/**
|
||||
* Seating capacity of the room
|
||||
*
|
||||
* @since 17.0.0
|
||||
*/
|
||||
public const CAPACITY = '{http://nextcloud.com/ns}room-seating-capacity';
|
||||
|
||||
/**
|
||||
* The physical address of the building this room is located in
|
||||
*
|
||||
* @since 17.0.0
|
||||
*/
|
||||
public const BUILDING_ADDRESS = '{http://nextcloud.com/ns}room-building-address';
|
||||
|
||||
/**
|
||||
* The story of the building this rooms is located in
|
||||
*
|
||||
* @since 17.0.0
|
||||
*/
|
||||
public const BUILDING_STORY = '{http://nextcloud.com/ns}room-building-story';
|
||||
|
||||
/**
|
||||
* The room-number
|
||||
*
|
||||
* @since 17.0.0
|
||||
*/
|
||||
public const BUILDING_ROOM_NUMBER = '{http://nextcloud.com/ns}room-building-room-number';
|
||||
|
||||
/**
|
||||
* Features provided by the room.
|
||||
* This is a stringified list of features.
|
||||
* Example: "PHONE,VIDEO-CONFERENCING"
|
||||
*
|
||||
* Standard features include:
|
||||
* - PHONE: This room is fitted with a phone
|
||||
* - VIDEO-CONFERENCING: This room is fitted with a video-conferencing system
|
||||
* - TV: This room is fitted with a TV
|
||||
* - PROJECTOR: This room is fitted with a projector
|
||||
* - WHITEBOARD: This room is fitted with a whiteboard
|
||||
* - WHEELCHAIR-ACCESSIBLE: This room is wheelchair-accessible
|
||||
*
|
||||
* @since 17.0.0
|
||||
*/
|
||||
public const FEATURES = '{http://nextcloud.com/ns}room-features';
|
||||
}
|
Loading…
Reference in New Issue