From f2559e44808fc785fa7ef148d4e15713b411e605 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Mon, 19 Aug 2024 15:27:34 +0200 Subject: Revert "[stable28] Apply group limit on remove from group" --- lib/private/Share20/DefaultShareProvider.php | 45 ++-------------------------- lib/private/Share20/ProviderFactory.php | 1 - 2 files changed, 2 insertions(+), 44 deletions(-) (limited to 'lib/private') diff --git a/lib/private/Share20/DefaultShareProvider.php b/lib/private/Share20/DefaultShareProvider.php index 75e853164b2..fd22095b420 100644 --- a/lib/private/Share20/DefaultShareProvider.php +++ b/lib/private/Share20/DefaultShareProvider.php @@ -53,7 +53,6 @@ use OCP\L10N\IFactory; use OCP\Mail\IMailer; use OCP\Share\Exceptions\ShareNotFound; use OCP\Share\IAttributes; -use OCP\Share\IManager; use OCP\Share\IShare; use OCP\Share\IShareProvider; use function str_starts_with; @@ -103,7 +102,6 @@ class DefaultShareProvider implements IShareProvider { IFactory $l10nFactory, IURLGenerator $urlGenerator, ITimeFactory $timeFactory, - private IManager $shareManager, ) { $this->dbConn = $connection; $this->userManager = $userManager; @@ -1306,7 +1304,6 @@ class DefaultShareProvider implements IShareProvider { * * @param string $uid * @param string $gid - * @return void */ public function userDeletedFromGroup($uid, $gid) { /* @@ -1318,7 +1315,7 @@ class DefaultShareProvider implements IShareProvider { ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_GROUP))) ->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($gid))); - $cursor = $qb->executeQuery(); + $cursor = $qb->execute(); $ids = []; while ($row = $cursor->fetch()) { $ids[] = (int)$row['id']; @@ -1335,45 +1332,7 @@ class DefaultShareProvider implements IShareProvider { ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_USERGROUP))) ->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($uid))) ->andWhere($qb->expr()->in('parent', $qb->createNamedParameter($chunk, IQueryBuilder::PARAM_INT_ARRAY))); - $qb->executeStatement(); - } - } - - if ($this->shareManager->shareWithGroupMembersOnly()) { - $user = $this->userManager->get($uid); - if ($user === null) { - return; - } - $userGroups = $this->groupManager->getUserGroupIds($user); - - // Delete user shares received by the user from users in the group. - $userReceivedShares = $this->shareManager->getSharedWith($uid, IShare::TYPE_USER, null, -1); - foreach ($userReceivedShares as $share) { - $owner = $this->userManager->get($share->getSharedBy()); - if ($owner === null) { - continue; - } - $ownerGroups = $this->groupManager->getUserGroupIds($owner); - $mutualGroups = array_intersect($userGroups, $ownerGroups); - - if (count($mutualGroups) === 0) { - $this->shareManager->deleteShare($share); - } - } - - // Delete user shares from the user to users in the group. - $userEmittedShares = $this->shareManager->getSharesBy($uid, IShare::TYPE_USER, null, true, -1); - foreach ($userEmittedShares as $share) { - $recipient = $this->userManager->get($share->getSharedWith()); - if ($recipient === null) { - continue; - } - $recipientGroups = $this->groupManager->getUserGroupIds($recipient); - $mutualGroups = array_intersect($userGroups, $recipientGroups); - - if (count($mutualGroups) === 0) { - $this->shareManager->deleteShare($share); - } + $qb->execute(); } } } diff --git a/lib/private/Share20/ProviderFactory.php b/lib/private/Share20/ProviderFactory.php index 63c161d5bee..dbf1b21dabe 100644 --- a/lib/private/Share20/ProviderFactory.php +++ b/lib/private/Share20/ProviderFactory.php @@ -106,7 +106,6 @@ class ProviderFactory implements IProviderFactory { $this->serverContainer->getL10NFactory(), $this->serverContainer->getURLGenerator(), $this->serverContainer->query(ITimeFactory::class), - $this->serverContainer->get(IManager::class), ); } -- cgit v1.2.3