diff --git a/lib/base.php b/lib/base.php index c97700b3dbfc311d197e8d1a31f8ab733c94bd8d..74b53c56658ad34f78a897226dc45017c2824457 100644 --- a/lib/base.php +++ b/lib/base.php @@ -433,13 +433,9 @@ class OC{ //setup extra user backends OC_User::setupBackends(); - // register cache cleanup jobs - OC_BackgroundJob_RegularTask::register('OC_Cache_FileGlobal', 'gc'); - OC_Hook::connect('OC_User', 'post_login', 'OC_Cache_File', 'loginListener'); - - // Check for blacklisted files - OC_Hook::connect('OC_Filesystem', 'write', 'OC_Filesystem', 'isBlacklisted'); - OC_Hook::connect('OC_Filesystem', 'rename', 'OC_Filesystem', 'isBlacklisted'); + self::installCacheHooks(); + self::installFilesystemHooks(); + self::installShareHooks(); //make sure temporary files are cleaned up register_shutdown_function(array('OC_Helper', 'cleanTmp')); @@ -474,6 +470,34 @@ class OC{ } } + /** + * install hooks for the cache + */ + public static function installCacheHooks() { + // register cache cleanup jobs + OC_BackgroundJob_RegularTask::register('OC_Cache_FileGlobal', 'gc'); + OC_Hook::connect('OC_User', 'post_login', 'OC_Cache_File', 'loginListener'); + } + + /** + * install hooks for the filesystem + */ + public static function installFilesystemHooks() { + // Check for blacklisted files + OC_Hook::connect('OC_Filesystem', 'write', 'OC_Filesystem', 'isBlacklisted'); + OC_Hook::connect('OC_Filesystem', 'rename', 'OC_Filesystem', 'isBlacklisted'); + } + + /** + * install hooks for sharing + */ + public static function installShareHooks() { + OC_Hook::connect('OC_User', 'post_deleteUser', 'OCP\Share', 'post_deleteUser'); + OC_Hook::connect('OC_User', 'post_addToGroup', 'OCP\Share', 'post_addToGroup'); + OC_Hook::connect('OC_User', 'post_removeFromGroup', 'OCP\Share', 'post_removeFromGroup'); + OC_Hook::connect('OC_User', 'post_deleteGroup', 'OCP\Share', 'post_deleteGroup'); + } + /** * @brief Handle the request */ diff --git a/lib/public/share.php b/lib/public/share.php index dcb1b5c278efdae59659df58cd88519864bb1c8d..3bf0602f63c781a31849a6ad96d5967f4661712a 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -20,11 +20,6 @@ */ namespace OCP; -\OC_Hook::connect('OC_User', 'post_deleteUser', 'OCP\Share', 'post_deleteUser'); -\OC_Hook::connect('OC_User', 'post_addToGroup', 'OCP\Share', 'post_addToGroup'); -\OC_Hook::connect('OC_User', 'post_removeFromGroup', 'OCP\Share', 'post_removeFromGroup'); -\OC_Hook::connect('OC_User', 'post_deleteGroup', 'OCP\Share', 'post_deleteGroup'); - /** * This class provides the ability for apps to share their content between users. * Apps must create a backend class that implements OCP\Share_Backend and register it with this class. diff --git a/tests/lib/filesystem.php b/tests/lib/filesystem.php index 0008336383efae0ba1be56a9112b4694d60f5b9d..7b856ef020c1a89973f36e60f5800d5195178fce 100644 --- a/tests/lib/filesystem.php +++ b/tests/lib/filesystem.php @@ -74,8 +74,7 @@ class Test_Filesystem extends UnitTestCase { public function testBlacklist() { OC_Hook::clear('OC_Filesystem'); - OC_Hook::connect('OC_Filesystem', 'write', 'OC_Filesystem', 'isBlacklisted'); - OC_Hook::connect('OC_Filesystem', 'rename', 'OC_Filesystem', 'isBlacklisted'); + OC::installFilesystemHooks(); $run = true; OC_Hook::emit( diff --git a/tests/lib/share/share.php b/tests/lib/share/share.php index 3cdae98ca6448020448ede4736f540c417a39cb7..25656c6bcd505b61fd2bf46bdb5aecc389abe46c 100644 --- a/tests/lib/share/share.php +++ b/tests/lib/share/share.php @@ -54,6 +54,8 @@ class Test_Share extends UnitTestCase { OC_Group::addToGroup($this->user2, $this->group2); OC_Group::addToGroup($this->user4, $this->group2); OCP\Share::registerBackend('test', 'Test_Share_Backend'); + OC_Hook::clear('OCP\\Share'); + OC::installShareHooks(); } public function tearDown() {