Merge pull request #401 from owncloud/share_hooks
Create functions to install standard hooks
This commit is contained in:
commit
eaa625c9bc
38
lib/base.php
38
lib/base.php
|
@ -433,13 +433,9 @@ class OC{
|
||||||
//setup extra user backends
|
//setup extra user backends
|
||||||
OC_User::setupBackends();
|
OC_User::setupBackends();
|
||||||
|
|
||||||
// register cache cleanup jobs
|
self::registerCacheHooks();
|
||||||
OC_BackgroundJob_RegularTask::register('OC_Cache_FileGlobal', 'gc');
|
self::registerFilesystemHooks();
|
||||||
OC_Hook::connect('OC_User', 'post_login', 'OC_Cache_File', 'loginListener');
|
self::registerShareHooks();
|
||||||
|
|
||||||
// Check for blacklisted files
|
|
||||||
OC_Hook::connect('OC_Filesystem', 'write', 'OC_Filesystem', 'isBlacklisted');
|
|
||||||
OC_Hook::connect('OC_Filesystem', 'rename', 'OC_Filesystem', 'isBlacklisted');
|
|
||||||
|
|
||||||
//make sure temporary files are cleaned up
|
//make sure temporary files are cleaned up
|
||||||
register_shutdown_function(array('OC_Helper', 'cleanTmp'));
|
register_shutdown_function(array('OC_Helper', 'cleanTmp'));
|
||||||
|
@ -474,6 +470,34 @@ class OC{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* register hooks for the cache
|
||||||
|
*/
|
||||||
|
public static function registerCacheHooks() {
|
||||||
|
// register cache cleanup jobs
|
||||||
|
OC_BackgroundJob_RegularTask::register('OC_Cache_FileGlobal', 'gc');
|
||||||
|
OC_Hook::connect('OC_User', 'post_login', 'OC_Cache_File', 'loginListener');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* register hooks for the filesystem
|
||||||
|
*/
|
||||||
|
public static function registerFilesystemHooks() {
|
||||||
|
// Check for blacklisted files
|
||||||
|
OC_Hook::connect('OC_Filesystem', 'write', 'OC_Filesystem', 'isBlacklisted');
|
||||||
|
OC_Hook::connect('OC_Filesystem', 'rename', 'OC_Filesystem', 'isBlacklisted');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* register hooks for sharing
|
||||||
|
*/
|
||||||
|
public static function registerShareHooks() {
|
||||||
|
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
|
* @brief Handle the request
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -20,11 +20,6 @@
|
||||||
*/
|
*/
|
||||||
namespace OCP;
|
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.
|
* 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.
|
* Apps must create a backend class that implements OCP\Share_Backend and register it with this class.
|
||||||
|
|
|
@ -74,8 +74,7 @@ class Test_Filesystem extends UnitTestCase {
|
||||||
|
|
||||||
public function testBlacklist() {
|
public function testBlacklist() {
|
||||||
OC_Hook::clear('OC_Filesystem');
|
OC_Hook::clear('OC_Filesystem');
|
||||||
OC_Hook::connect('OC_Filesystem', 'write', 'OC_Filesystem', 'isBlacklisted');
|
OC::registerFilesystemHooks();
|
||||||
OC_Hook::connect('OC_Filesystem', 'rename', 'OC_Filesystem', 'isBlacklisted');
|
|
||||||
|
|
||||||
$run = true;
|
$run = true;
|
||||||
OC_Hook::emit(
|
OC_Hook::emit(
|
||||||
|
|
|
@ -54,6 +54,8 @@ class Test_Share extends UnitTestCase {
|
||||||
OC_Group::addToGroup($this->user2, $this->group2);
|
OC_Group::addToGroup($this->user2, $this->group2);
|
||||||
OC_Group::addToGroup($this->user4, $this->group2);
|
OC_Group::addToGroup($this->user4, $this->group2);
|
||||||
OCP\Share::registerBackend('test', 'Test_Share_Backend');
|
OCP\Share::registerBackend('test', 'Test_Share_Backend');
|
||||||
|
OC_Hook::clear('OCP\\Share');
|
||||||
|
OC::registerShareHooks();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tearDown() {
|
public function tearDown() {
|
||||||
|
|
Loading…
Reference in New Issue