summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBart Visscher <bartv@thisnet.nl>2012-11-13 23:45:17 +0100
committerBart Visscher <bartv@thisnet.nl>2012-11-13 23:45:17 +0100
commit530f3f8be9336ec49eab9f00e2c3b15d29bc78c7 (patch)
tree4554fda5274e69523269ba938878f48bafdd01bb
parentad85087fccf52ab68899b38b8bab28c0d17b673d (diff)
downloadnextcloud-server-530f3f8be9336ec49eab9f00e2c3b15d29bc78c7.tar.gz
nextcloud-server-530f3f8be9336ec49eab9f00e2c3b15d29bc78c7.zip
Create functions to install standard hooks
Also use these in tests that needs them Fix #151
-rw-r--r--lib/base.php38
-rw-r--r--lib/public/share.php5
-rw-r--r--tests/lib/filesystem.php3
-rw-r--r--tests/lib/share/share.php2
4 files changed, 34 insertions, 14 deletions
diff --git a/lib/base.php b/lib/base.php
index c97700b3dbf..74b53c56658 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'));
@@ -475,6 +471,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
*/
public static function handleRequest() {
diff --git a/lib/public/share.php b/lib/public/share.php
index dcb1b5c278e..3bf0602f63c 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 0008336383e..7b856ef020c 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 3cdae98ca64..25656c6bcd5 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() {