Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 35 additions & 7 deletions lib/private/Share20/DefaultShareProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -951,14 +951,34 @@ private function _getSharedWith(
}

if ($path !== null) {
$qb->leftJoin('s', 'share', 'sc', $qb->expr()->eq('sc.parent', 's.id'))
->andWhere($qb->expr()->eq('sc.share_type', $qb->createNamedParameter(IShare::TYPE_USERGROUP)))
->where($qb->expr()->eq('sc.share_with', $qb->createNamedParameter($userId)));
$onClause = $qb->expr()->andX(
$qb->expr()->eq('sc.parent', 's.id'),
$qb->expr()->eq('sc.share_type', $qb->createNamedParameter(IShare::TYPE_USERGROUP)),
$qb->expr()->eq('sc.share_with', $qb->createNamedParameter($userId)),
);
$qb->leftJoin('s', 'share', 'sc', $onClause);

if ($forChildren) {
$qb->andWhere($qb->expr()->like('sc.file_target', $qb->createNamedParameter($this->dbConn->escapeLikeParameter($path) . '_%')));
$qb->andWhere(
$qb->expr()->orX(
$qb->expr()->like('sc.file_target', $qb->createNamedParameter($this->dbConn->escapeLikeParameter($path) . '_%')),
$qb->expr()->andX(
$qb->expr()->isNull('sc.file_target'),
$qb->expr()->like('s.file_target', $qb->createNamedParameter($this->dbConn->escapeLikeParameter($path) . '_%'),
),
),
)
);
} else {
$qb->andWhere($qb->expr()->eq('sc.file_target', $qb->createNamedParameter($path)));
$qb->andWhere(
$qb->expr()->orX(
$qb->expr()->eq('sc.file_target', $qb->createNamedParameter($path)),
$qb->expr()->andX(
$qb->expr()->isNull('sc.file_target'),
$qb->expr()->eq('s.file_target', $qb->createNamedParameter($path)),
),
)
);
}
}

Expand Down Expand Up @@ -989,7 +1009,7 @@ private function _getSharedWith(
/*
* Resolve all group shares to user specific shares
*/
$shares = $this->resolveGroupShares($shares2, $userId);
$shares = $this->resolveGroupShares($shares2, $userId, $path, $forChildren);
} else {
throw new BackendError('Invalid backend');
}
Expand Down Expand Up @@ -1105,7 +1125,7 @@ private function createShare($data) {
* @param $userId
* @return Share[] The updates shares if no update is found for a share return the original
*/
private function resolveGroupShares($shareMap, $userId) {
private function resolveGroupShares($shareMap, $userId, ?string $path = null, ?bool $forChildren = false) {
$qb = $this->dbConn->getQueryBuilder();
$query = $qb->select('*')
->from('share')
Expand All @@ -1119,6 +1139,14 @@ private function resolveGroupShares($shareMap, $userId) {
if (count($shareMap) === 1) {
$share = reset($shareMap);
$query->andWhere($qb->expr()->eq('parent', $qb->createNamedParameter($share->getId())));
} elseif ($path !== null) {
if ($forChildren) {
$query->andWhere($qb->expr()->like('file_target',
$qb->createNamedParameter($this->dbConn->escapeLikeParameter($path) . '_%')));
} else {
$query->andWhere($qb->expr()->eq('file_target',
$qb->createNamedParameter($path)));
}
}

$stmt = $query->executeQuery();
Expand Down
Loading