Skip to content

Commit 42418f4

Browse files
committed
Add $shallow arg to RoomShareProvider::getSharesInFolder
A new `$shallow` argument was introduced to `IShareProvider::getSharesInFolder` in NC25 by nextcloud/server#31728. This PR adds this new argument and the necessary changes to make it work based on this example https://github.com/nextcloud/server/pull/31728/files#diff-dee1351696d7eae959761edf66c8e5a9052e28be73319733d857a9ab2d9fc967= Signed-off-by: Louis Chemineau <[email protected]>
1 parent 8fe96ac commit 42418f4

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/Share/RoomShareProvider.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -520,10 +520,11 @@ public function move(IShare $share, $recipient): IShare {
520520
* @param string $userId
521521
* @param Folder $node
522522
* @param bool $reshares Also get the shares where $user is the owner instead of just the shares where $user is the initiator
523+
* @param bool $shallow Whether the method should stop at the first level, or look into sub-folders.
523524
* @return IShare[][]
524525
* @psalm-return array<array-key, non-empty-list<IShare>>
525526
*/
526-
public function getSharesInFolder($userId, Folder $node, $reshares): array {
527+
public function getSharesInFolder($userId, Folder $node, $reshares, $shallow = true): array {
527528
$qb = $this->dbConnection->getQueryBuilder();
528529
$qb->select('*')
529530
->from('share', 's')
@@ -550,7 +551,11 @@ public function getSharesInFolder($userId, Folder $node, $reshares): array {
550551
}
551552

552553
$qb->innerJoin('s', 'filecache', 'f', $qb->expr()->eq('s.file_source', 'f.fileid'));
553-
$qb->andWhere($qb->expr()->eq('f.parent', $qb->createNamedParameter($node->getId())));
554+
if ($shallow) {
555+
$qb->andWhere($qb->expr()->eq('f.parent', $qb->createNamedParameter($node->getId())));
556+
} else {
557+
$qb->andWhere($qb->expr()->like('f.path', $qb->createNamedParameter($this->dbConnection->escapeLikeParameter($node->getInternalPath()) . '/%')));
558+
}
554559

555560
$qb->orderBy('s.id');
556561

0 commit comments

Comments
 (0)