summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2019-12-12 21:38:52 +0100
committerRoeland Jago Douma <roeland@famdouma.nl>2019-12-16 09:07:25 +0100
commitbb4264c565963f07c087a4aebc47ff6ca0d59686 (patch)
tree1a60ad4d122a1af6b99d2e1ef6e0f9867a64c63d /lib
parent87104ce5100f905dab3ce056f05847fad5dde393 (diff)
downloadnextcloud-server-bb4264c565963f07c087a4aebc47ff6ca0d59686.tar.gz
nextcloud-server-bb4264c565963f07c087a4aebc47ff6ca0d59686.zip
config.php setting to always accept internal shares
Part of #18255 Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'lib')
-rw-r--r--lib/composer/composer/autoload_classmap.php1
-rw-r--r--lib/composer/composer/autoload_static.php1
-rw-r--r--lib/private/Server.php3
-rw-r--r--lib/private/Share20/Manager.php31
-rw-r--r--lib/public/Share/Events/ShareCreatedEvent.php53
5 files changed, 76 insertions, 13 deletions
diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php
index 016b3c360ef..bfc024e5851 100644
--- a/lib/composer/composer/autoload_classmap.php
+++ b/lib/composer/composer/autoload_classmap.php
@@ -418,6 +418,7 @@ return array(
'OCP\\Settings\\ISettings' => $baseDir . '/lib/public/Settings/ISettings.php',
'OCP\\Settings\\ISubAdminSettings' => $baseDir . '/lib/public/Settings/ISubAdminSettings.php',
'OCP\\Share' => $baseDir . '/lib/public/Share.php',
+ 'OCP\\Share\\Events\\ShareCreatedEvent' => $baseDir . '/lib/public/Share/Events/ShareCreatedEvent.php',
'OCP\\Share\\Exceptions\\GenericShareException' => $baseDir . '/lib/public/Share/Exceptions/GenericShareException.php',
'OCP\\Share\\Exceptions\\IllegalIDChangeException' => $baseDir . '/lib/public/Share/Exceptions/IllegalIDChangeException.php',
'OCP\\Share\\Exceptions\\ShareNotFound' => $baseDir . '/lib/public/Share/Exceptions/ShareNotFound.php',
diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php
index 5d63c7740eb..6fe4529c295 100644
--- a/lib/composer/composer/autoload_static.php
+++ b/lib/composer/composer/autoload_static.php
@@ -447,6 +447,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
'OCP\\Settings\\ISettings' => __DIR__ . '/../../..' . '/lib/public/Settings/ISettings.php',
'OCP\\Settings\\ISubAdminSettings' => __DIR__ . '/../../..' . '/lib/public/Settings/ISubAdminSettings.php',
'OCP\\Share' => __DIR__ . '/../../..' . '/lib/public/Share.php',
+ 'OCP\\Share\\Events\\ShareCreatedEvent' => __DIR__ . '/../../..' . '/lib/public/Share/Events/ShareCreatedEvent.php',
'OCP\\Share\\Exceptions\\GenericShareException' => __DIR__ . '/../../..' . '/lib/public/Share/Exceptions/GenericShareException.php',
'OCP\\Share\\Exceptions\\IllegalIDChangeException' => __DIR__ . '/../../..' . '/lib/public/Share/Exceptions/IllegalIDChangeException.php',
'OCP\\Share\\Exceptions\\ShareNotFound' => __DIR__ . '/../../..' . '/lib/public/Share/Exceptions/ShareNotFound.php',
diff --git a/lib/private/Server.php b/lib/private/Server.php
index b8765654c3f..0cc3b24992e 100644
--- a/lib/private/Server.php
+++ b/lib/private/Server.php
@@ -1171,7 +1171,8 @@ class Server extends ServerContainer implements IServerContainer {
$c->getEventDispatcher(),
$c->getMailer(),
$c->getURLGenerator(),
- $c->getThemingDefaults()
+ $c->getThemingDefaults(),
+ $c->query(IEventDispatcher::class)
);
return $manager;
diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php
index 42db0d8af5d..4c94cf26a4d 100644
--- a/lib/private/Share20/Manager.php
+++ b/lib/private/Share20/Manager.php
@@ -44,6 +44,7 @@ use OC\Cache\CappedMemoryCache;
use OC\Files\Mount\MoveableMount;
use OC\HintException;
use OC\Share20\Exception\ProviderException;
+use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\File;
use OCP\Files\Folder;
use OCP\Files\IRootFolder;
@@ -101,7 +102,7 @@ class Manager implements IManager {
/** @var CappedMemoryCache */
private $sharingDisabledForUsersCache;
/** @var EventDispatcherInterface */
- private $eventDispatcher;
+ private $legacyDispatcher;
/** @var LegacyHooks */
private $legacyHooks;
/** @var IMailer */
@@ -110,6 +111,8 @@ class Manager implements IManager {
private $urlGenerator;
/** @var \OC_Defaults */
private $defaults;
+ /** @var IEventDispatcher */
+ private $dispatcher;
/**
@@ -143,10 +146,11 @@ class Manager implements IManager {
IProviderFactory $factory,
IUserManager $userManager,
IRootFolder $rootFolder,
- EventDispatcherInterface $eventDispatcher,
+ EventDispatcherInterface $legacyDispatcher,
IMailer $mailer,
IURLGenerator $urlGenerator,
- \OC_Defaults $defaults
+ \OC_Defaults $defaults,
+ IEventDispatcher $dispatcher
) {
$this->logger = $logger;
$this->config = $config;
@@ -159,12 +163,13 @@ class Manager implements IManager {
$this->factory = $factory;
$this->userManager = $userManager;
$this->rootFolder = $rootFolder;
- $this->eventDispatcher = $eventDispatcher;
+ $this->legacyDispatcher = $legacyDispatcher;
$this->sharingDisabledForUsersCache = new CappedMemoryCache();
- $this->legacyHooks = new LegacyHooks($this->eventDispatcher);
+ $this->legacyHooks = new LegacyHooks($this->legacyDispatcher);
$this->mailer = $mailer;
$this->urlGenerator = $urlGenerator;
$this->defaults = $defaults;
+ $this->dispatcher = $dispatcher;
}
/**
@@ -195,7 +200,7 @@ class Manager implements IManager {
// Let others verify the password
try {
- $this->eventDispatcher->dispatch(new ValidatePasswordPolicyEvent($password));
+ $this->legacyDispatcher->dispatch(new ValidatePasswordPolicyEvent($password));
} catch (HintException $e) {
throw new \Exception($e->getHint());
}
@@ -766,7 +771,7 @@ class Manager implements IManager {
// Pre share event
$event = new GenericEvent($share);
- $this->eventDispatcher->dispatch('OCP\Share::preShare', $event);
+ $this->legacyDispatcher->dispatch('OCP\Share::preShare', $event);
if ($event->isPropagationStopped() && $event->hasArgument('error')) {
throw new \Exception($event->getArgument('error'));
}
@@ -779,7 +784,9 @@ class Manager implements IManager {
// Post share event
$event = new GenericEvent($share);
- $this->eventDispatcher->dispatch('OCP\Share::postShare', $event);
+ $this->legacyDispatcher->dispatch('OCP\Share::postShare', $event);
+
+ $this->dispatcher->dispatchTyped(new Share\Events\ShareCreatedEvent($share));
if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) {
$mailSend = $share->getMailSend();
@@ -1041,7 +1048,7 @@ class Manager implements IManager {
}
$provider->acceptShare($share, $recipientId);
$event = new GenericEvent($share);
- $this->eventDispatcher->dispatch('OCP\Share::postAcceptShare', $event);
+ $this->legacyDispatcher->dispatch('OCP\Share::postAcceptShare', $event);
return $share;
}
@@ -1111,7 +1118,7 @@ class Manager implements IManager {
}
$event = new GenericEvent($share);
- $this->eventDispatcher->dispatch('OCP\Share::preUnshare', $event);
+ $this->legacyDispatcher->dispatch('OCP\Share::preUnshare', $event);
// Get all children and delete them as well
$deletedShares = $this->deleteChildren($share);
@@ -1125,7 +1132,7 @@ class Manager implements IManager {
// Emit post hook
$event->setArgument('deletedShares', $deletedShares);
- $this->eventDispatcher->dispatch('OCP\Share::postUnshare', $event);
+ $this->legacyDispatcher->dispatch('OCP\Share::postUnshare', $event);
}
@@ -1144,7 +1151,7 @@ class Manager implements IManager {
$provider->deleteFromSelf($share, $recipientId);
$event = new GenericEvent($share);
- $this->eventDispatcher->dispatch('OCP\Share::postUnshareFromSelf', $event);
+ $this->legacyDispatcher->dispatch('OCP\Share::postUnshareFromSelf', $event);
}
public function restoreShare(IShare $share, string $recipientId): IShare {
diff --git a/lib/public/Share/Events/ShareCreatedEvent.php b/lib/public/Share/Events/ShareCreatedEvent.php
new file mode 100644
index 00000000000..76e25b7f166
--- /dev/null
+++ b/lib/public/Share/Events/ShareCreatedEvent.php
@@ -0,0 +1,53 @@
+<?php
+declare(strict_types=1);
+/**
+ * @copyright Copyright (c) 2019, Roeland Jago Douma <roeland@famdouma.nl>
+ *
+ * @author Roeland Jago Douma <roeland@famdouma.nl>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCP\Share\Events;
+
+use OCP\EventDispatcher\Event;
+use OCP\Share\IShare;
+
+/**
+ * @since 18.0.0
+ */
+class ShareCreatedEvent extends Event {
+
+ /** @var IShare */
+ private $share;
+
+ /**
+ * @since 18.0.0
+ */
+ public function __construct(IShare $share) {
+ parent::__construct();
+
+ $this->share = $share;
+ }
+
+ /**
+ * @since 18.0.0
+ */
+ public function getShare(): IShare {
+ return $this->share;
+ }
+}