diff options
author | Joas Schilling <213943+nickvergessen@users.noreply.github.com> | 2020-02-28 13:41:13 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-28 13:41:13 +0100 |
commit | 0f08acfe3169e3ef0c332353324271bd86c2e525 (patch) | |
tree | f4d33926d6d5a89c8fdf9ca3df24a376599a18dc | |
parent | 36d6fca8560d2d50fa473cc9880bbc27afc4f82d (diff) | |
parent | 841f2f3b0491dfec43491911f20cce7a78408a1b (diff) | |
download | nextcloud-server-0f08acfe3169e3ef0c332353324271bd86c2e525.tar.gz nextcloud-server-0f08acfe3169e3ef0c332353324271bd86c2e525.zip |
Merge pull request #19321 from nextcloud/enh/allow-to-overwrite-share-target-mountpoints
Allow to overwrite share target mountpoints
-rw-r--r-- | apps/files_sharing/lib/SharedMount.php | 8 | ||||
-rw-r--r-- | lib/composer/composer/autoload_classmap.php | 1 | ||||
-rw-r--r-- | lib/composer/composer/autoload_static.php | 1 | ||||
-rw-r--r-- | lib/public/Share/Events/VerifyMountPointEvent.php | 83 |
4 files changed, 93 insertions, 0 deletions
diff --git a/apps/files_sharing/lib/SharedMount.php b/apps/files_sharing/lib/SharedMount.php index a1a011a9b7d..91f3c39ba05 100644 --- a/apps/files_sharing/lib/SharedMount.php +++ b/apps/files_sharing/lib/SharedMount.php @@ -33,7 +33,9 @@ use OC\Files\Filesystem; use OC\Files\Mount\MountPoint; use OC\Files\Mount\MoveableMount; use OC\Files\View; +use OCP\EventDispatcher\IEventDispatcher; use OCP\Files\Storage\IStorageFactory; +use OCP\Share\Events\VerifyMountPointEvent; /** * Shared mount points can be moved by the user @@ -91,6 +93,12 @@ class SharedMount extends MountPoint implements MoveableMount { $mountPoint = basename($share->getTarget()); $parent = dirname($share->getTarget()); + $event = new VerifyMountPointEvent($share, $this->recipientView, $parent); + /** @var IEventDispatcher $dispatcher */ + $dispatcher = \OC::$server->query(IEventDispatcher::class); + $dispatcher->dispatchTyped($event); + $parent = $event->getParent(); + if ($folderExistCache->hasKey($parent)) { $parentExists = $folderExistCache->get($parent); } else { diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index 39c82330ab6..3bb83768473 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -428,6 +428,7 @@ return array( '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\\Events\\VerifyMountPointEvent' => $baseDir . '/lib/public/Share/Events/VerifyMountPointEvent.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 dd3b61ddf87..1c029a6865d 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -457,6 +457,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c '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\\Events\\VerifyMountPointEvent' => __DIR__ . '/../../..' . '/lib/public/Share/Events/VerifyMountPointEvent.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/public/Share/Events/VerifyMountPointEvent.php b/lib/public/Share/Events/VerifyMountPointEvent.php new file mode 100644 index 00000000000..75914f9416b --- /dev/null +++ b/lib/public/Share/Events/VerifyMountPointEvent.php @@ -0,0 +1,83 @@ +<?php +declare(strict_types=1); +/** + * @copyright Copyright (c) 2020, Joas Schilling <coding@schilljs.com> + * + * @author Joas Schilling <coding@schilljs.com> + * + * @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 OC\Files\View; +use OCP\EventDispatcher\Event; +use OCP\Share\IShare; + +/** + * @since 19.0.0 + */ +class VerifyMountPointEvent extends Event { + + /** @var IShare */ + private $share; + /** @var View */ + private $view; + /** @var string */ + private $parent; + + /** + * @since 19.0.0 + */ + public function __construct(IShare $share, + View $view, + string $parent) { + parent::__construct(); + + $this->share = $share; + $this->view = $view; + $this->parent = $parent; + } + + /** + * @since 19.0.0 + */ + public function getShare(): IShare { + return $this->share; + } + + /** + * @since 19.0.0 + */ + public function getView(): View { + return $this->view; + } + + /** + * @since 19.0.0 + */ + public function getParent(): string { + return $this->parent; + } + + /** + * @since 19.0.0 + */ + public function setParent(string $parent): void { + $this->parent = $parent; + } +} |