mirror of
https://github.com/nextcloud/server.git
synced 2026-04-22 23:03:00 -04:00
Merge pull request #47494 from nextcloud/bugfix/eun-100/allow-apps-to-get-unshared-users
fix(dav): Allow apps to get unshares for DAV resources
This commit is contained in:
commit
0fdcaa584e
2 changed files with 22 additions and 5 deletions
|
|
@ -14,21 +14,34 @@ class SharingMapper {
|
|||
public function __construct(private IDBConnection $db) {
|
||||
}
|
||||
|
||||
public function getSharesForId(int $resourceId, string $resourceType): array {
|
||||
protected function getSharesForIdByAccess(int $resourceId, string $resourceType, bool $sharesWithAccess): array {
|
||||
$query = $this->db->getQueryBuilder();
|
||||
$result = $query->select(['principaluri', 'access'])
|
||||
$query->select(['principaluri', 'access'])
|
||||
->from('dav_shares')
|
||||
->where($query->expr()->eq('resourceid', $query->createNamedParameter($resourceId, IQueryBuilder::PARAM_INT)))
|
||||
->andWhere($query->expr()->eq('type', $query->createNamedParameter($resourceType, IQueryBuilder::PARAM_STR)))
|
||||
->andWhere($query->expr()->neq('access', $query->createNamedParameter(Backend::ACCESS_UNSHARED, IQueryBuilder::PARAM_INT)))
|
||||
->groupBy(['principaluri', 'access'])
|
||||
->executeQuery();
|
||||
->groupBy(['principaluri', 'access']);
|
||||
|
||||
if ($sharesWithAccess) {
|
||||
$query->andWhere($query->expr()->neq('access', $query->createNamedParameter(Backend::ACCESS_UNSHARED, IQueryBuilder::PARAM_INT)));
|
||||
} else {
|
||||
$query->andWhere($query->expr()->eq('access', $query->createNamedParameter(Backend::ACCESS_UNSHARED, IQueryBuilder::PARAM_INT)));
|
||||
}
|
||||
|
||||
$result = $query->executeQuery();
|
||||
$rows = $result->fetchAll();
|
||||
$result->closeCursor();
|
||||
return $rows;
|
||||
}
|
||||
|
||||
public function getSharesForId(int $resourceId, string $resourceType): array {
|
||||
return $this->getSharesForIdByAccess($resourceId, $resourceType, true);
|
||||
}
|
||||
|
||||
public function getUnsharesForId(int $resourceId, string $resourceType): array {
|
||||
return $this->getSharesForIdByAccess($resourceId, $resourceType, false);
|
||||
}
|
||||
|
||||
public function getSharesForIds(array $resourceIds, string $resourceType): array {
|
||||
$query = $this->db->getQueryBuilder();
|
||||
$result = $query->select(['resourceid', 'principaluri', 'access'])
|
||||
|
|
|
|||
|
|
@ -41,6 +41,10 @@ abstract class SharingService {
|
|||
return $this->mapper->getSharesForId($resourceId, $this->getResourceType());
|
||||
}
|
||||
|
||||
public function getUnshares(int $resourceId): array {
|
||||
return $this->mapper->getUnsharesForId($resourceId, $this->getResourceType());
|
||||
}
|
||||
|
||||
public function getSharesForIds(array $resourceIds): array {
|
||||
return $this->mapper->getSharesForIds($resourceIds, $this->getResourceType());
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue