aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Share20
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/Share20')
-rw-r--r--lib/private/Share20/DefaultShareProvider.php37
-rw-r--r--lib/private/Share20/Manager.php38
-rw-r--r--lib/private/Share20/ProviderFactory.php11
3 files changed, 82 insertions, 4 deletions
diff --git a/lib/private/Share20/DefaultShareProvider.php b/lib/private/Share20/DefaultShareProvider.php
index 3c56b24707c..5e52156d1d0 100644
--- a/lib/private/Share20/DefaultShareProvider.php
+++ b/lib/private/Share20/DefaultShareProvider.php
@@ -31,6 +31,7 @@ namespace OC\Share20;
use OC\Files\Cache\Cache;
use OCP\Files\Folder;
+use OCP\Share\IShare;
use OCP\Share\IShareProvider;
use OC\Share20\Exception\InvalidShare;
use OC\Share20\Exception\ProviderException;
@@ -412,6 +413,41 @@ class DefaultShareProvider implements IShareProvider {
/**
* @inheritdoc
+ *
+ * For now this only works for group shares
+ * If this gets implemented for normal shares we have to extend it
+ */
+ public function restore(IShare $share, string $recipient): IShare {
+ $qb = $this->dbConn->getQueryBuilder();
+ $qb->select('permissions')
+ ->from('share')
+ ->where(
+ $qb->expr()->eq('id', $qb->createNamedParameter($share->getId()))
+ );
+ $cursor = $qb->execute();
+ $data = $cursor->fetch();
+ $cursor->closeCursor();
+
+ $originalPermission = $data['permissions'];
+
+ $qb = $this->dbConn->getQueryBuilder();
+ $qb->update('share')
+ ->set('permissions', $qb->createNamedParameter($originalPermission))
+ ->where(
+ $qb->expr()->eq('parent', $qb->createNamedParameter($share->getParent()))
+ )->andWhere(
+ $qb->expr()->eq('share_type', $qb->createNamedParameter(self::SHARE_TYPE_USERGROUP))
+ )->andWhere(
+ $qb->expr()->eq('share_with', $qb->createNamedParameter($recipient))
+ );
+
+ $qb->execute();
+
+ return $this->getShareById($share->getId(), $recipient);
+ }
+
+ /**
+ * @inheritdoc
*/
public function move(\OCP\Share\IShare $share, $recipient) {
if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) {
@@ -922,6 +958,7 @@ class DefaultShareProvider implements IShareProvider {
while($data = $stmt->fetch()) {
$shareMap[$data['parent']]->setPermissions((int)$data['permissions']);
$shareMap[$data['parent']]->setTarget($data['file_target']);
+ $shareMap[$data['parent']]->setParent($data['parent']);
}
$stmt->closeCursor();
diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php
index cddd8c8d92b..76b523afd10 100644
--- a/lib/private/Share20/Manager.php
+++ b/lib/private/Share20/Manager.php
@@ -61,6 +61,7 @@ use OCP\Share\Exceptions\GenericShareException;
use OCP\Share\Exceptions\ShareNotFound;
use OCP\Share\IManager;
use OCP\Share\IProviderFactory;
+use OCP\Share\IShare;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\GenericEvent;
use OCP\Share\IShareProvider;
@@ -225,6 +226,10 @@ class Manager implements IManager {
if ($share->getSharedWith() === null) {
throw new \InvalidArgumentException('SharedWith should not be empty');
}
+ } else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_REMOTE_GROUP) {
+ if ($share->getSharedWith() === null) {
+ throw new \InvalidArgumentException('SharedWith should not be empty');
+ }
} else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_EMAIL) {
if ($share->getSharedWith() === null) {
throw new \InvalidArgumentException('SharedWith should not be empty');
@@ -978,6 +983,13 @@ class Manager implements IManager {
$this->eventDispatcher->dispatch('OCP\Share::postUnshareFromSelf', $event);
}
+ public function restoreShare(IShare $share, string $recipientId): IShare {
+ list($providerId, ) = $this->splitFullId($share->getFullId());
+ $provider = $this->factory->getProvider($providerId);
+
+ return $provider->restore($share, $recipientId);
+ }
+
/**
* @inheritdoc
*/
@@ -1124,6 +1136,25 @@ class Manager implements IManager {
/**
* @inheritdoc
*/
+ public function getDeletedSharedWith($userId, $shareType, $node = null, $limit = 50, $offset = 0) {
+ $shares = $this->getSharedWith($userId, $shareType, $node, $limit, $offset);
+
+ // Only get deleted shares
+ $shares = array_filter($shares, function(IShare $share) {
+ return $share->getPermissions() === 0;
+ });
+
+ // Only get shares where the owner still exists
+ $shares = array_filter($shares, function (IShare $share) {
+ return $this->userManager->userExists($share->getShareOwner());
+ });
+
+ return $shares;
+ }
+
+ /**
+ * @inheritdoc
+ */
public function getShareById($id, $recipient = null) {
if ($id === null) {
throw new ShareNotFound();
@@ -1555,6 +1586,13 @@ class Manager implements IManager {
/**
* @inheritdoc
*/
+ public function outgoingServer2ServerGroupSharesAllowed() {
+ return $this->config->getAppValue('files_sharing', 'outgoing_server2server_group_share_enabled', 'no') === 'yes';
+ }
+
+ /**
+ * @inheritdoc
+ */
public function shareProviderExists($shareType) {
try {
$this->factory->getProviderForType($shareType);
diff --git a/lib/private/Share20/ProviderFactory.php b/lib/private/Share20/ProviderFactory.php
index 3716189445f..e4d34146911 100644
--- a/lib/private/Share20/ProviderFactory.php
+++ b/lib/private/Share20/ProviderFactory.php
@@ -29,10 +29,10 @@
namespace OC\Share20;
use OC\CapabilitiesManager;
-use OC\GlobalScale\Config;
use OCA\FederatedFileSharing\AddressHandler;
use OCA\FederatedFileSharing\FederatedShareProvider;
use OCA\FederatedFileSharing\Notifications;
+use OCA\FederatedFileSharing\OCM\CloudFederationProvider;
use OCA\FederatedFileSharing\TokenHandler;
use OCA\ShareByMail\Settings\SettingsManager;
use OCA\ShareByMail\ShareByMailProvider;
@@ -116,7 +116,9 @@ class ProviderFactory implements IProviderFactory {
$addressHandler,
$this->serverContainer->getHTTPClientService(),
$this->serverContainer->query(\OCP\OCS\IDiscoveryService::class),
- $this->serverContainer->getJobList()
+ $this->serverContainer->getJobList(),
+ \OC::$server->getCloudFederationProviderManager(),
+ \OC::$server->getCloudFederationFactory()
);
$tokenHandler = new TokenHandler(
$this->serverContainer->getSecureRandom()
@@ -133,7 +135,8 @@ class ProviderFactory implements IProviderFactory {
$this->serverContainer->getConfig(),
$this->serverContainer->getUserManager(),
$this->serverContainer->getCloudIdManager(),
- $this->serverContainer->query(Config::class)
+ $this->serverContainer->getGlobalScaleConfig(),
+ $this->serverContainer->getCloudFederationProviderManager()
);
}
@@ -248,7 +251,7 @@ class ProviderFactory implements IProviderFactory {
$shareType === \OCP\Share::SHARE_TYPE_LINK
) {
$provider = $this->defaultShareProvider();
- } else if ($shareType === \OCP\Share::SHARE_TYPE_REMOTE) {
+ } else if ($shareType === \OCP\Share::SHARE_TYPE_REMOTE || $shareType === \OCP\Share::SHARE_TYPE_REMOTE_GROUP) {
$provider = $this->federatedShareProvider();
} else if ($shareType === \OCP\Share::SHARE_TYPE_EMAIL) {
$provider = $this->getShareByMailProvider();