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
24 changes: 10 additions & 14 deletions lib/private/Share20/DefaultShareProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -950,18 +950,6 @@ private function _getSharedWith(
$qb->andWhere($qb->expr()->eq('file_source', $qb->createNamedParameter($node->getId())));
}

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)));

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

$groups = array_filter($groups);

$qb->andWhere($qb->expr()->eq('s.share_type', $qb->createNamedParameter(IShare::TYPE_GROUP)))
Expand Down Expand Up @@ -989,7 +977,7 @@ private function _getSharedWith(
/*
* Resolve all group shares to user specific shares
*/
$shares = $this->resolveGroupShares($shares2, $userId);
$shares = $this->resolveGroupShares($shares2, $userId, $forChildren, $path);
} else {
throw new BackendError('Invalid backend');
}
Expand Down Expand Up @@ -1105,14 +1093,22 @@ 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, bool $forChildren = false, ?string $path = null) {
$qb = $this->dbConn->getQueryBuilder();
$query = $qb->select('*')
->from('share')
->where($qb->expr()->eq('share_with', $qb->createNamedParameter($userId)))
->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_USERGROUP)))
->andWhere($qb->expr()->in('item_type', $qb->createNamedParameter(['file', 'folder'], IQueryBuilder::PARAM_STR_ARRAY)));

if ($path !== null) {
if ($forChildren) {
$qb->andWhere($qb->expr()->like('file_target', $qb->createNamedParameter($this->dbConn->escapeLikeParameter($path) . '_%')));
} else {
$qb->andWhere($qb->expr()->eq('file_target', $qb->createNamedParameter($path)));
}
}

// this is called with either all group shares or one group share.
// for all shares it's easier to just only search by share_with,
// for a single share it's efficient to filter by parent
Expand Down
Loading