diff options
author | Robin Appelman <icewind@owncloud.com> | 2015-03-18 15:26:04 +0100 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2015-03-26 19:56:57 +0100 |
commit | 1be7da4a57ed006bd246f25dbe053b58b89557c9 (patch) | |
tree | 377cea7c0ea851f9cf4b16a2194c6df8b1704129 /apps/files_sharing/lib | |
parent | 173c31e42af766298c9f43837a9a3e4021cdc131 (diff) | |
download | nextcloud-server-1be7da4a57ed006bd246f25dbe053b58b89557c9.tar.gz nextcloud-server-1be7da4a57ed006bd246f25dbe053b58b89557c9.zip |
replace share proxy with hook
Diffstat (limited to 'apps/files_sharing/lib')
-rw-r--r-- | apps/files_sharing/lib/helper.php | 1 | ||||
-rw-r--r-- | apps/files_sharing/lib/hooks.php | 16 | ||||
-rw-r--r-- | apps/files_sharing/lib/proxy.php | 65 |
3 files changed, 17 insertions, 65 deletions
diff --git a/apps/files_sharing/lib/helper.php b/apps/files_sharing/lib/helper.php index 712b9fa29dd..236be15a95a 100644 --- a/apps/files_sharing/lib/helper.php +++ b/apps/files_sharing/lib/helper.php @@ -36,6 +36,7 @@ class Helper { \OCP\Util::connectHook('OC_Filesystem', 'post_delete', '\OC\Files\Cache\Shared_Updater', 'postDeleteHook'); \OCP\Util::connectHook('OC_Filesystem', 'delete', '\OC\Files\Cache\Shared_Updater', 'deleteHook'); \OCP\Util::connectHook('OC_Filesystem', 'post_rename', '\OC\Files\Cache\Shared_Updater', 'renameHook'); + \OCP\Util::connectHook('OC_Filesystem', 'post_delete', '\OCA\Files_Sharing\Hooks', 'unshareChildren'); \OCP\Util::connectHook('OC_Appconfig', 'post_set_value', '\OCA\Files\Share\Maintainer', 'configChangeHook'); \OCP\Util::connectHook('OCP\Share', 'post_shared', '\OC\Files\Cache\Shared_Updater', 'postShareHook'); diff --git a/apps/files_sharing/lib/hooks.php b/apps/files_sharing/lib/hooks.php index dc7317c5c7d..c3588ecdfe5 100644 --- a/apps/files_sharing/lib/hooks.php +++ b/apps/files_sharing/lib/hooks.php @@ -22,6 +22,8 @@ namespace OCA\Files_Sharing; +use OC\Files\Filesystem; + class Hooks { public static function deleteUser($params) { @@ -35,4 +37,18 @@ class Hooks { $manager->removeUserShares($params['uid']); } + public static function unshareChildren($params) { + $path = Filesystem::getView()->getAbsolutePath($params['path']); + $view = new \OC\Files\View('/'); + + // find share mount points within $path and unmount them + $mountManager = \OC\Files\Filesystem::getMountManager(); + $mountedShares = $mountManager->findIn($path); + foreach ($mountedShares as $mount) { + if ($mount->getStorage()->instanceOfStorage('OCA\Files_Sharing\ISharedStorage')) { + $mountPoint = $mount->getMountPoint(); + $view->unlink($mountPoint); + } + } + } } diff --git a/apps/files_sharing/lib/proxy.php b/apps/files_sharing/lib/proxy.php deleted file mode 100644 index 538d8bcfecf..00000000000 --- a/apps/files_sharing/lib/proxy.php +++ /dev/null @@ -1,65 +0,0 @@ -<?php -/** - * @author Björn Schießle <schiessle@owncloud.com> - * @author Morris Jobke <hey@morrisjobke.de> - * - * @copyright Copyright (c) 2015, ownCloud, Inc. - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * 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, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * - */ - -namespace OCA\Files\Share; -use OCA\Files_Sharing\Helper; - -class Proxy extends \OC_FileProxy { - - /** - * check if the deleted folder contains share mount points and unshare them - * - * @param string $path - */ - public function preUnlink($path) { - $this->unshareChildren($path); - } - - /** - * check if the deleted folder contains share mount points and unshare them - * - * @param string $path - */ - public function preRmdir($path) { - $this->unshareChildren($path); - } - - /** - * unshare shared items below the deleted folder - * - * @param string $path - */ - private function unshareChildren($path) { - $view = new \OC\Files\View('/'); - - // find share mount points within $path and unmount them - $mountManager = \OC\Files\Filesystem::getMountManager(); - $mountedShares = $mountManager->findIn($path); - foreach ($mountedShares as $mount) { - if ($mount->getStorage()->instanceOfStorage('OCA\Files_Sharing\ISharedStorage')) { - $mountPoint = $mount->getMountPoint(); - $view->unlink($mountPoint); - } - } - } - -} |