From 866c513871a71d0054f8a098893a3a5535ff4c5d Mon Sep 17 00:00:00 2001 From: "John Molakvoæ (skjnldsv)" Date: Wed, 6 Nov 2019 10:11:23 +0100 Subject: Fix files_versions app LoadSidebar event MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ (skjnldsv) --- apps/files_versions/lib/Hooks.php | 43 +++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 24 deletions(-) (limited to 'apps/files_versions/lib/Hooks.php') diff --git a/apps/files_versions/lib/Hooks.php b/apps/files_versions/lib/Hooks.php index 4e2dcfa3087..953bd5deca2 100644 --- a/apps/files_versions/lib/Hooks.php +++ b/apps/files_versions/lib/Hooks.php @@ -35,28 +35,30 @@ namespace OCA\Files_Versions; +use OC\Files\Filesystem; +use OC\Files\Mount\MoveableMount; +use OC\Files\View; +use OCP\Util; + class Hooks { public static function connectHooks() { // Listen to write signals - \OCP\Util::connectHook('OC_Filesystem', 'write', Hooks::class, 'write_hook'); + Util::connectHook('OC_Filesystem', 'write', Hooks::class, 'write_hook'); // Listen to delete and rename signals - \OCP\Util::connectHook('OC_Filesystem', 'post_delete', Hooks::class, 'remove_hook'); - \OCP\Util::connectHook('OC_Filesystem', 'delete', Hooks::class, 'pre_remove_hook'); - \OCP\Util::connectHook('OC_Filesystem', 'post_rename', Hooks::class, 'rename_hook'); - \OCP\Util::connectHook('OC_Filesystem', 'post_copy', Hooks::class, 'copy_hook'); - \OCP\Util::connectHook('OC_Filesystem', 'rename', Hooks::class, 'pre_renameOrCopy_hook'); - \OCP\Util::connectHook('OC_Filesystem', 'copy', Hooks::class, 'pre_renameOrCopy_hook'); - - $eventDispatcher = \OC::$server->getEventDispatcher(); - $eventDispatcher->addListener('OCA\Files::loadAdditionalScripts', [Hooks::class, 'onLoadFilesAppScripts']); + Util::connectHook('OC_Filesystem', 'post_delete', Hooks::class, 'remove_hook'); + Util::connectHook('OC_Filesystem', 'delete', Hooks::class, 'pre_remove_hook'); + Util::connectHook('OC_Filesystem', 'post_rename', Hooks::class, 'rename_hook'); + Util::connectHook('OC_Filesystem', 'post_copy', Hooks::class, 'copy_hook'); + Util::connectHook('OC_Filesystem', 'rename', Hooks::class, 'pre_renameOrCopy_hook'); + Util::connectHook('OC_Filesystem', 'copy', Hooks::class, 'pre_renameOrCopy_hook'); } /** * listen to write event. */ public static function write_hook( $params ) { - $path = $params[\OC\Files\Filesystem::signal_param_path]; + $path = $params[Filesystem::signal_param_path]; if($path !== '') { Storage::store($path); } @@ -71,7 +73,7 @@ class Hooks { * cleanup the versions directory if the actual file gets deleted */ public static function remove_hook($params) { - $path = $params[\OC\Files\Filesystem::signal_param_path]; + $path = $params[Filesystem::signal_param_path]; if($path !== '') { Storage::delete($path); } @@ -82,7 +84,7 @@ class Hooks { * @param array $params */ public static function pre_remove_hook($params) { - $path = $params[\OC\Files\Filesystem::signal_param_path]; + $path = $params[Filesystem::signal_param_path]; if($path !== '') { Storage::markDeletedFile($path); } @@ -129,26 +131,19 @@ class Hooks { public static function pre_renameOrCopy_hook($params) { // if we rename a movable mount point, then the versions don't have // to be renamed - $absOldPath = \OC\Files\Filesystem::normalizePath('/' . \OCP\User::getUser() . '/files' . $params['oldpath']); - $manager = \OC\Files\Filesystem::getMountManager(); + $absOldPath = Filesystem::normalizePath('/' . \OCP\User::getUser() . '/files' . $params['oldpath']); + $manager = Filesystem::getMountManager(); $mount = $manager->find($absOldPath); $internalPath = $mount->getInternalPath($absOldPath); - if ($internalPath === '' and $mount instanceof \OC\Files\Mount\MoveableMount) { + if ($internalPath === '' and $mount instanceof MoveableMount) { return; } - $view = new \OC\Files\View(\OCP\User::getUser() . '/files'); + $view = new View(\OCP\User::getUser() . '/files'); if ($view->file_exists($params['newpath'])) { Storage::store($params['newpath']); } else { Storage::setSourcePathAndUser($params['oldpath']); } } - - /** - * Load additional scripts when the files app is visible - */ - public static function onLoadFilesAppScripts() { - \OCP\Util::addScript('files_versions', 'files_versions'); - } } -- cgit v1.2.3