diff options
author | Maxence Lange <maxence@nextcloud.com> | 2017-03-17 18:48:33 -0100 |
---|---|---|
committer | Maxence Lange <maxence@nextcloud.com> | 2017-03-17 18:48:33 -0100 |
commit | 69694012ab0eca1ec1f3dc0d2b10a3b1728b0927 (patch) | |
tree | f79ec80ba1eefb73884c723718d8fa5c76cbf203 /lib/private/Share20/ProviderFactory.php | |
parent | 3c66ad64e626cb602685a640c235d472f0777a53 (diff) | |
download | nextcloud-server-69694012ab0eca1ec1f3dc0d2b10a3b1728b0927.tar.gz nextcloud-server-69694012ab0eca1ec1f3dc0d2b10a3b1728b0927.zip |
shares-circles
Signed-off-by: Maxence Lange <maxence@nextcloud.com>
Diffstat (limited to 'lib/private/Share20/ProviderFactory.php')
-rw-r--r-- | lib/private/Share20/ProviderFactory.php | 54 |
1 files changed, 50 insertions, 4 deletions
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; } } |