diff options
author | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2019-11-06 10:11:23 +0100 |
---|---|---|
committer | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2019-11-06 10:11:23 +0100 |
commit | 866c513871a71d0054f8a098893a3a5535ff4c5d (patch) | |
tree | e4cabe6052ac707d757796c1c177c38b19cb75c6 /apps/files_versions/lib/Hooks.php | |
parent | 6ba2a608d08ec3c1fd440ac2d0a9cfad569da234 (diff) | |
download | nextcloud-server-866c513871a71d0054f8a098893a3a5535ff4c5d.tar.gz nextcloud-server-866c513871a71d0054f8a098893a3a5535ff4c5d.zip |
Fix files_versions app LoadSidebar event
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/files_versions/lib/Hooks.php')
-rw-r--r-- | apps/files_versions/lib/Hooks.php | 43 |
1 files changed, 19 insertions, 24 deletions
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'); - } } |