2019-08-06 07:10:04 -04:00
|
|
|
<?php
|
2019-12-03 13:57:53 -05:00
|
|
|
|
2019-08-06 07:10:04 -04:00
|
|
|
declare(strict_types=1);
|
2019-12-03 13:57:53 -05:00
|
|
|
|
2019-08-06 07:10:04 -04:00
|
|
|
/**
|
2024-05-27 11:39:07 -04:00
|
|
|
* SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
2019-08-06 07:10:04 -04:00
|
|
|
*/
|
2019-08-06 07:40:52 -04:00
|
|
|
namespace OCA\DAV\CalDAV\Proxy;
|
2019-08-06 07:10:04 -04:00
|
|
|
|
|
|
|
|
use OCP\AppFramework\Db\QBMapper;
|
|
|
|
|
use OCP\IDBConnection;
|
|
|
|
|
|
2019-08-14 07:38:11 -04:00
|
|
|
/**
|
|
|
|
|
* Class ProxyMapper
|
|
|
|
|
*
|
|
|
|
|
* @package OCA\DAV\CalDAV\Proxy
|
2023-03-31 03:28:22 -04:00
|
|
|
*
|
|
|
|
|
* @template-extends QBMapper<Proxy>
|
2019-08-14 07:38:11 -04:00
|
|
|
*/
|
2019-08-06 07:10:04 -04:00
|
|
|
class ProxyMapper extends QBMapper {
|
2020-10-05 09:12:57 -04:00
|
|
|
public const PERMISSION_READ = 1;
|
2020-04-10 10:54:27 -04:00
|
|
|
public const PERMISSION_WRITE = 2;
|
2019-08-06 07:10:04 -04:00
|
|
|
|
2019-08-14 07:38:11 -04:00
|
|
|
/**
|
|
|
|
|
* ProxyMapper constructor.
|
|
|
|
|
*
|
|
|
|
|
* @param IDBConnection $db
|
|
|
|
|
*/
|
2019-08-06 07:10:04 -04:00
|
|
|
public function __construct(IDBConnection $db) {
|
|
|
|
|
parent::__construct($db, 'dav_cal_proxy', Proxy::class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2019-08-14 07:38:11 -04:00
|
|
|
* @param string $proxyId The principal uri that can act as a proxy for the resulting calendars
|
2019-08-06 07:40:52 -04:00
|
|
|
*
|
|
|
|
|
* @return Proxy[]
|
2019-08-06 07:10:04 -04:00
|
|
|
*/
|
|
|
|
|
public function getProxiesFor(string $proxyId): array {
|
|
|
|
|
$qb = $this->db->getQueryBuilder();
|
|
|
|
|
|
|
|
|
|
$qb->select('*')
|
|
|
|
|
->from($this->getTableName())
|
|
|
|
|
->where($qb->expr()->eq('proxy_id', $qb->createNamedParameter($proxyId)));
|
|
|
|
|
|
|
|
|
|
return $this->findEntities($qb);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2019-08-14 07:38:11 -04:00
|
|
|
* @param string $ownerId The principal uri that has the resulting proxies for their calendars
|
2019-08-06 07:40:52 -04:00
|
|
|
*
|
|
|
|
|
* @return Proxy[]
|
2019-08-06 07:10:04 -04:00
|
|
|
*/
|
|
|
|
|
public function getProxiesOf(string $ownerId): array {
|
|
|
|
|
$qb = $this->db->getQueryBuilder();
|
|
|
|
|
|
|
|
|
|
$qb->select('*')
|
|
|
|
|
->from($this->getTableName())
|
|
|
|
|
->where($qb->expr()->eq('owner_id', $qb->createNamedParameter($ownerId)));
|
|
|
|
|
|
|
|
|
|
return $this->findEntities($qb);
|
|
|
|
|
}
|
|
|
|
|
}
|