Skip to content

Commit

Permalink
Add $shallow arg to RoomShareProvider::getSharesInFolder
Browse files Browse the repository at this point in the history
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 <louis@chmn.me>
  • Loading branch information
artonge committed Jul 26, 2022
1 parent 8fe96ac commit 42418f4
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/Share/RoomShareProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -520,10 +520,11 @@ public function move(IShare $share, $recipient): IShare {
* @param string $userId
* @param Folder $node
* @param bool $reshares Also get the shares where $user is the owner instead of just the shares where $user is the initiator
* @param bool $shallow Whether the method should stop at the first level, or look into sub-folders.
* @return IShare[][]
* @psalm-return array<array-key, non-empty-list<IShare>>
*/
public function getSharesInFolder($userId, Folder $node, $reshares): array {
public function getSharesInFolder($userId, Folder $node, $reshares, $shallow = true): array {
$qb = $this->dbConnection->getQueryBuilder();
$qb->select('*')
->from('share', 's')
Expand All @@ -550,7 +551,11 @@ public function getSharesInFolder($userId, Folder $node, $reshares): array {
}

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

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

Expand Down

0 comments on commit 42418f4

Please sign in to comment.