aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Share20/DefaultShareProvider.php48
-rw-r--r--lib/private/Share20/ProviderFactory.php1
2 files changed, 47 insertions, 2 deletions
diff --git a/lib/private/Share20/DefaultShareProvider.php b/lib/private/Share20/DefaultShareProvider.php
index fd22095b420..2d9ec7d3d68 100644
--- a/lib/private/Share20/DefaultShareProvider.php
+++ b/lib/private/Share20/DefaultShareProvider.php
@@ -53,6 +53,7 @@ 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;
@@ -102,6 +103,7 @@ class DefaultShareProvider implements IShareProvider {
IFactory $l10nFactory,
IURLGenerator $urlGenerator,
ITimeFactory $timeFactory,
+ private IManager $shareManager,
) {
$this->dbConn = $connection;
$this->userManager = $userManager;
@@ -1315,7 +1317,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->execute();
+ $cursor = $qb->executeQuery();
$ids = [];
while ($row = $cursor->fetch()) {
$ids[] = (int)$row['id'];
@@ -1332,9 +1334,51 @@ 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->execute();
+ $qb->executeStatement();
}
}
+
+ if ($this->shareManager->shareWithGroupMembersOnly()) {
+ $deleteQuery = $this->dbConn->getQueryBuilder();
+ $deleteQuery->delete('share')
+ ->where($deleteQuery->expr()->in('id', $deleteQuery->createParameter('id')));
+
+ // Delete direct shares received by the user from users in the group.
+ $selectInboundShares = $this->dbConn->getQueryBuilder();
+ $selectInboundShares->select('id')
+ ->from('share', 's')
+ ->join('s', 'group_user', 'g', 's.uid_initiator = g.uid')
+ ->where($selectInboundShares->expr()->eq('share_type', $selectInboundShares->createNamedParameter(IShare::TYPE_USER)))
+ ->andWhere($selectInboundShares->expr()->eq('share_with', $selectInboundShares->createNamedParameter($uid)))
+ ->andWhere($selectInboundShares->expr()->eq('gid', $selectInboundShares->createNamedParameter($gid)))
+ ->setMaxResults(1000)
+ ->executeQuery();
+
+ do {
+ $rows = $selectInboundShares->executeQuery();
+ $ids = $rows->fetchAll();
+ $deleteQuery->setParameter('id', array_column($ids, 'id'), IQueryBuilder::PARAM_INT_ARRAY);
+ $deleteQuery->executeStatement();
+ } while (count($ids) > 0);
+
+ // Delete direct shares from the user to users in the group.
+ $selectOutboundShares = $this->dbConn->getQueryBuilder();
+ $selectOutboundShares->select('id')
+ ->from('share', 's')
+ ->join('s', 'group_user', 'g', 's.share_with = g.uid')
+ ->where($selectOutboundShares->expr()->eq('share_type', $selectOutboundShares->createNamedParameter(IShare::TYPE_USER)))
+ ->andWhere($selectOutboundShares->expr()->eq('uid_initiator', $selectOutboundShares->createNamedParameter($uid)))
+ ->andWhere($selectOutboundShares->expr()->eq('gid', $selectOutboundShares->createNamedParameter($gid)))
+ ->setMaxResults(1000)
+ ->executeQuery();
+
+ do {
+ $rows = $selectOutboundShares->executeQuery();
+ $ids = $rows->fetchAll();
+ $deleteQuery->setParameter('id', array_column($ids, 'id'), IQueryBuilder::PARAM_INT_ARRAY);
+ $deleteQuery->executeStatement();
+ } while (count($ids) > 0);
+ }
}
/**
diff --git a/lib/private/Share20/ProviderFactory.php b/lib/private/Share20/ProviderFactory.php
index dbf1b21dabe..63c161d5bee 100644
--- a/lib/private/Share20/ProviderFactory.php
+++ b/lib/private/Share20/ProviderFactory.php
@@ -106,6 +106,7 @@ class ProviderFactory implements IProviderFactory {
$this->serverContainer->getL10NFactory(),
$this->serverContainer->getURLGenerator(),
$this->serverContainer->query(ITimeFactory::class),
+ $this->serverContainer->get(IManager::class),
);
}