aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMaxence Lange <maxence@nextcloud.com>2017-03-17 18:48:33 -0100
committerMaxence Lange <maxence@nextcloud.com>2017-03-17 18:48:33 -0100
commit69694012ab0eca1ec1f3dc0d2b10a3b1728b0927 (patch)
treef79ec80ba1eefb73884c723718d8fa5c76cbf203 /lib
parent3c66ad64e626cb602685a640c235d472f0777a53 (diff)
downloadnextcloud-server-69694012ab0eca1ec1f3dc0d2b10a3b1728b0927.tar.gz
nextcloud-server-69694012ab0eca1ec1f3dc0d2b10a3b1728b0927.zip
shares-circles
Signed-off-by: Maxence Lange <maxence@nextcloud.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Share/Constants.php1
-rw-r--r--lib/private/Share20/Manager.php7
-rw-r--r--lib/private/Share20/ProviderFactory.php54
3 files changed, 57 insertions, 5 deletions
diff --git a/lib/private/Share/Constants.php b/lib/private/Share/Constants.php
index f13f83f8ba9..1eb5b1e078b 100644
--- a/lib/private/Share/Constants.php
+++ b/lib/private/Share/Constants.php
@@ -32,6 +32,7 @@ class Constants {
const SHARE_TYPE_EMAIL = 4;
const SHARE_TYPE_CONTACT = 5; // ToDo Check if it is still in use otherwise remove it
const SHARE_TYPE_REMOTE = 6;
+ const SHARE_TYPE_CIRCLE = 7;
const FORMAT_NONE = -1;
const FORMAT_STATUSES = -2;
diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php
index acc142f62be..3b565d1ba8c 100644
--- a/lib/private/Share20/Manager.php
+++ b/lib/private/Share20/Manager.php
@@ -190,9 +190,14 @@ class Manager implements IManager {
if ($share->getSharedWith() === null) {
throw new \InvalidArgumentException('SharedWith should not be empty');
}
+ } else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_CIRCLE) {
+ $circle = \OCA\Circles\Api\Circles::detailsCircle($share->getSharedWith());
+ if ($circle === null) {
+ throw new \InvalidArgumentException('SharedWith is not a valid circle');
+ }
} else {
// We can't handle other types yet
- throw new \InvalidArgumentException('unkown share type');
+ throw new \InvalidArgumentException('unknown share type');
}
// Verify the initiator of the share is set
diff --git a/lib/private/Share20/ProviderFactory.php b/lib/private/Share20/ProviderFactory.php
index bbc6f4ffbd3..1a39cfbf337 100644
--- a/lib/private/Share20/ProviderFactory.php
+++ b/lib/private/Share20/ProviderFactory.php
@@ -48,9 +48,13 @@ class ProviderFactory implements IProviderFactory {
private $federatedProvider = null;
/** @var ShareByMailProvider */
private $shareByMailProvider;
+ /** @var \OCA\Circles\ShareByCircleProvider;
+ * ShareByCircleProvider */
+ private $shareByCircleProvider;
/**
* IProviderFactory constructor.
+ *
* @param IServerContainer $serverContainer
*/
public function __construct(IServerContainer $serverContainer) {
@@ -165,6 +169,36 @@ class ProviderFactory implements IProviderFactory {
/**
+ * Create the circle share provider
+ *
+ * @return FederatedShareProvider
+ */
+ protected function getShareByCircleProvider() {
+
+ $appManager = $this->serverContainer->getAppManager();
+ if (!$appManager->isEnabledForUser('circles')) {
+ return null;
+ }
+
+
+ if ($this->shareByCircleProvider === null) {
+
+ $this->shareByCircleProvider = new \OCA\Circles\ShareByCircleProvider(
+ $this->serverContainer->getDatabaseConnection(),
+ $this->serverContainer->getSecureRandom(),
+ $this->serverContainer->getUserManager(),
+ $this->serverContainer->getLazyRootFolder(),
+ $this->serverContainer->getL10N('circles'),
+ $this->serverContainer->getLogger(),
+ $this->serverContainer->getURLGenerator()
+ );
+ }
+
+ return $this->shareByCircleProvider;
+ }
+
+
+ /**
* @inheritdoc
*/
public function getProvider($id) {
@@ -175,6 +209,8 @@ class ProviderFactory implements IProviderFactory {
$provider = $this->federatedShareProvider();
} else if ($id === 'ocMailShare') {
$provider = $this->getShareByMailProvider();
+ } else if ($id === 'ocCircleShare') {
+ $provider = $this->getShareByCircleProvider();
}
if ($provider === null) {
@@ -190,16 +226,20 @@ class ProviderFactory implements IProviderFactory {
public function getProviderForType($shareType) {
$provider = null;
- if ($shareType === \OCP\Share::SHARE_TYPE_USER ||
+ if ($shareType === \OCP\Share::SHARE_TYPE_USER ||
$shareType === \OCP\Share::SHARE_TYPE_GROUP ||
- $shareType === \OCP\Share::SHARE_TYPE_LINK) {
+ $shareType === \OCP\Share::SHARE_TYPE_LINK
+ ) {
$provider = $this->defaultShareProvider();
} else if ($shareType === \OCP\Share::SHARE_TYPE_REMOTE) {
$provider = $this->federatedShareProvider();
} else if ($shareType === \OCP\Share::SHARE_TYPE_EMAIL) {
$provider = $this->getShareByMailProvider();
+ } else if ($shareType === \OCP\Share::SHARE_TYPE_CIRCLE) {
+ $provider = $this->getShareByCircleProvider();
}
+
if ($provider === null) {
throw new ProviderException('No share provider for share type ' . $shareType);
}
@@ -208,10 +248,16 @@ class ProviderFactory implements IProviderFactory {
}
public function getAllProviders() {
+ $shares = [$this->defaultShareProvider(), $this->federatedShareProvider()];
$shareByMail = $this->getShareByMailProvider();
if ($shareByMail !== null) {
- return [$this->defaultShareProvider(), $this->federatedShareProvider(), $shareByMail];
+ $shares[] = $shareByMail;
+ }
+ $shareByCircle = $this->getShareByCircleProvider();
+ if ($shareByCircle !== null) {
+ $shares[] = $shareByCircle;
}
- return [$this->defaultShareProvider(), $this->federatedShareProvider()];
+
+ return $shares;
}
}