\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);
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'),
\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');
namespace OCA\Files_Sharing;
+use OC\Files\Filesystem;
+
class Hooks {
public static function deleteUser($params) {
$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);
+ }
+ }
+ }
}
+++ /dev/null
-<?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);
- }
- }
- }
-
-}
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';
\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);