]> source.dussan.org Git - nextcloud-server.git/commitdiff
replace share proxy with hook
authorRobin Appelman <icewind@owncloud.com>
Wed, 18 Mar 2015 14:26:04 +0000 (15:26 +0100)
committerRobin Appelman <icewind@owncloud.com>
Thu, 26 Mar 2015 18:56:57 +0000 (19:56 +0100)
apps/files_encryption/tests/share.php
apps/files_sharing/appinfo/app.php
apps/files_sharing/lib/helper.php
apps/files_sharing/lib/hooks.php
apps/files_sharing/lib/proxy.php [deleted file]
apps/files_sharing/tests/unsharechildren.php
apps/files_sharing/tests/updater.php

index 06feb630f2771942fa8c900c09bab5590a3aa510..2a9f0359c912e40c1702badc6292eee8c894419c 100755 (executable)
@@ -62,9 +62,6 @@ class Share extends TestCase {
                \OC::registerShareHooks();
                \OCA\Files_Sharing\Helper::registerHooks();
 
-               // clear and register hooks
-               \OC_FileProxy::register(new \OCA\Files\Share\Proxy());
-
                // create users
                self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER1, true);
                self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER2, true);
index 85002ff982b6c80f07d70dfb5ea395d897d86516..a222973fc34818a1866aedf949d333a96bdb43d0 100644 (file)
@@ -51,8 +51,6 @@ OCP\Share::registerBackend('folder', 'OC_Share_Backend_Folder', 'file');
 OCP\Util::addScript('files_sharing', 'share');
 OCP\Util::addScript('files_sharing', 'external');
 
-OC_FileProxy::register(new OCA\Files\Share\Proxy());
-
 \OC::$server->getActivityManager()->registerExtension(function() {
                return new \OCA\Files_Sharing\Activity(
                        \OC::$server->query('L10NFactory'),
index 712b9fa29dd458a485771f490611a34627271cba..236be15a95ae3bbe2619f3dc649f3d654e132c0c 100644 (file)
@@ -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');
index dc7317c5c7d20199b703474469adb7e1381ec54b..c3588ecdfe519229d901cc62c98130ea1b535d41 100644 (file)
@@ -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 (file)
index 538d8bc..0000000
+++ /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);
-                       }
-               }
-       }
-
-}
index 574f1dd08d809d6a3f797b0de2e7af7fe64e857b..b49180fdc832a1981c24db065979cdbea10e87cc 100644 (file)
@@ -37,9 +37,7 @@ class UnshareChildren extends TestCase {
        protected function setUp() {
                parent::setUp();
 
-               // load proxies
-               \OC::$CLASSPATH['OCA\Files\Share\Proxy'] = 'files_sharing/lib/proxy.php';
-               \OC_FileProxy::register(new \OCA\Files\Share\Proxy());
+               \OCP\Util::connectHook('OC_Filesystem', 'post_delete', '\OCA\Files_Sharing\Hooks', 'unshareChildren');
 
                $this->folder = self::TEST_FOLDER_NAME;
                $this->subfolder  = '/subfolder_share_api_test';
index f019fc6a4b29862cea77f86d23370b3f1009eab9..df1bbe1cc66df1ab8308b83d90ab7f0a236c0e86 100644 (file)
@@ -66,7 +66,6 @@ class Test_Files_Sharing_Updater extends OCA\Files_sharing\Tests\TestCase {
                \OC_App::enable('files_trashbin');
 
                \OCA\Files_Trashbin\Trashbin::registerHooks();
-               OC_FileProxy::register(new OCA\Files\Share\Proxy());
 
                $fileinfo = \OC\Files\Filesystem::getFileInfo($this->folder);
                $this->assertTrue($fileinfo instanceof \OC\Files\FileInfo);