Skip to content
Merged
Show file tree
Hide file tree
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
18 changes: 12 additions & 6 deletions lib/Db/ShareWrapperRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
use OCP\Files\NotFoundException;
use OCP\Share\Exceptions\IllegalIDChangeException;
use OCP\Share\IShare;
use OCP\Files\Folder;

/**
* Class ShareWrapperRequest
Expand Down Expand Up @@ -358,25 +359,30 @@ public function getSharesBy(

/**
* @param FederatedUser $federatedUser
* @param int $nodeId
* @param Folder $node
* @param bool $reshares
* @param bool $shallow Whether the method should stop at the first level, or look into sub-folders.
*
* @return ShareWrapper[]
* @throws RequestBuilderException
*/
public function getSharesInFolder(
FederatedUser $federatedUser,
int $nodeId,
bool $reshares
Folder $node,
bool $reshares,
bool $shallow = true
): array {
$qb = $this->getShareSelectSql();

$qb->leftJoinCircle(CoreQueryBuilder::SHARE, null, 'share_with');
$qb->limitToShareOwner(CoreQueryBuilder::SHARE, $federatedUser, $reshares);
$qb->leftJoinFileCache(CoreQueryBuilder::SHARE);
if ($nodeId > 0) {
$aliasFileCache = $qb->generateAlias(CoreQueryBuilder::SHARE, CoreQueryBuilder::FILE_CACHE);
$qb->limitInt('parent', $nodeId, $aliasFileCache);

$aliasFileCache = $qb->generateAlias(CoreQueryBuilder::SHARE, CoreQueryBuilder::FILE_CACHE);
if ($shallow) {
$qb->limitInt('parent', $node->getId(), $aliasFileCache);
} else {
$qb->like('path', $node->getInternalPath() . '/%', $aliasFileCache);
}
$qb->limitNull('parent', false);

Expand Down
8 changes: 5 additions & 3 deletions lib/Service/ShareWrapperService.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
use OCP\ICache;
use OCP\ICacheFactory;
use OCP\Share\IShare;
use OCP\Files\Folder;

/**
* Class ShareWrapperService
Expand Down Expand Up @@ -267,14 +268,15 @@ public function getSharesBy(

/**
* @param FederatedUser $federatedUser
* @param int $nodeId
* @param Folder $node
* @param bool $reshares
* @param bool $shallow Whether the method should stop at the first level, or look into sub-folders.
*
* @return ShareWrapper[]
* @throws RequestBuilderException
*/
public function getSharesInFolder(FederatedUser $federatedUser, int $nodeId, bool $reshares): array {
return $this->shareWrapperRequest->getSharesInFolder($federatedUser, $nodeId, $reshares);
public function getSharesInFolder(FederatedUser $federatedUser, Folder $node, bool $reshares, bool $shallow = true): array {
return $this->shareWrapperRequest->getSharesInFolder($federatedUser, $node, $reshares, $shallow);
}


Expand Down
9 changes: 5 additions & 4 deletions lib/ShareByCircleProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ public function move(IShare $share, $recipient): IShare {
* @param string $userId
* @param Folder $node
* @param bool $reshares
*
* @param bool $shallow Whether the method should stop at the first level, or look into sub-folders.
* @return array
* @throws ContactAddressBookNotFoundException
* @throws ContactFormatException
Expand All @@ -404,12 +404,13 @@ public function move(IShare $share, $recipient): IShare {
* @throws RequestBuilderException
* @throws SingleCircleNotFoundException
*/
public function getSharesInFolder($userId, Folder $node, $reshares): array {
public function getSharesInFolder($userId, Folder $node, $reshares, $shallow = true): array {
$federatedUser = $this->federatedUserService->getLocalFederatedUser($userId);
$wrappedShares = $this->shareWrapperService->getSharesInFolder(
$federatedUser,
(!is_null($node)) ? $node->getId() : 0,
$reshares
$node,
$reshares,
$shallow
);

$result = [];
Expand Down
3 changes: 2 additions & 1 deletion lib/ShareByCircleProviderDeprecated.php
Original file line number Diff line number Diff line change
Expand Up @@ -378,10 +378,11 @@ private function createShareChild($userId, $share) {
* @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 Share[]
*/
public function getSharesInFolder($userId, Folder $node, $reshares) {
public function getSharesInFolder($userId, Folder $node, $reshares, $shallow = true) {
\OC::$server->getLogger()->log(3, 'deprecated>getSharesInFolder');
return [];
//
Expand Down