Ejemplo n.º 1
0
 public function __construct(IL10N $l, ISession $session, ICredentialsManager $credentialsManager)
 {
     $this->session = $session;
     $this->credentialsManager = $credentialsManager;
     $this->setIdentifier('password::logincredentials')->setScheme(self::SCHEME_PASSWORD)->setText($l->t('Log-in credentials, save in database'))->addParameters([]);
     \OCP\Util::connectHook('OC_User', 'post_login', $this, 'authenticate');
 }
Ejemplo n.º 2
0
 public static function registerHooks()
 {
     \OCP\Util::connectHook('OC_Filesystem', 'post_rename', '\\OCA\\Files_Sharing\\Updater', 'renameHook');
     \OCP\Util::connectHook('OC_Filesystem', 'post_delete', '\\OCA\\Files_Sharing\\Hooks', 'unshareChildren');
     \OCP\Util::connectHook('OC_Appconfig', 'post_set_value', '\\OCA\\Files_Sharing\\Maintainer', 'configChangeHook');
     \OCP\Util::connectHook('OC_User', 'post_deleteUser', '\\OCA\\Files_Sharing\\Hooks', 'deleteUser');
 }
Ejemplo n.º 3
0
 public static function setUpBeforeClass()
 {
     // reset backend
     \OC_User::clearBackends();
     \OC_User::useBackend('database');
     // enable resharing
     \OC_Appconfig::setValue('core', 'shareapi_allow_resharing', 'yes');
     // clear share hooks
     \OC_Hook::clear('OCP\\Share');
     \OC::registerShareHooks();
     \OCP\Util::connectHook('OC_Filesystem', 'setup', '\\OC\\Files\\Storage\\Shared', 'setup');
     // Sharing related hooks
     \OCA\Encryption\Helper::registerShareHooks();
     // Filesystem related hooks
     \OCA\Encryption\Helper::registerFilesystemHooks();
     // clear and register hooks
     \OC_FileProxy::clearProxies();
     \OC_FileProxy::register(new OCA\Encryption\Proxy());
     // create users
     \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1, true);
     \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2, true);
     \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3, true);
     \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER4, true);
     // create group and assign users
     \OC_Group::createGroup(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_GROUP1);
     \OC_Group::addToGroup(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_GROUP1);
     \OC_Group::addToGroup(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER4, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_GROUP1);
 }
Ejemplo n.º 4
0
 public function __construct(IL10N $l, ISession $session, ICrypto $crypto)
 {
     $this->session = $session;
     $this->crypto = $crypto;
     $this->setIdentifier('password::sessioncredentials')->setScheme(self::SCHEME_PASSWORD)->setText($l->t('Session credentials'))->addParameters([]);
     \OCP\Util::connectHook('OC_User', 'post_login', $this, 'authenticate');
 }
Ejemplo n.º 5
0
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     // note: not using a data provider because these
     // files all need to coexist to make sure the
     // share keys are found properly (pattern matching)
     self::$testFiles = array('t est.txt', 't est_.txt', 't est.doc.txt', 't est(.*).txt', 'multiple.dots.can.happen.too.txt', 't est.' . self::TEST_ENCRYPTION_HOOKS_USER1 . '.txt', 't est_.' . self::TEST_ENCRYPTION_HOOKS_USER1 . '.shareKey.txt', 'who would upload their.shareKey', 'user ones file.txt', 'user ones file.txt.backup', '.t est.txt');
     // reset backend
     \OC_User::clearBackends();
     \OC_User::useBackend('database');
     \OC_Hook::clear('OC_Filesystem');
     \OC_Hook::clear('OC_User');
     // clear share hooks
     \OC_Hook::clear('OCP\\Share');
     \OC::registerShareHooks();
     \OCP\Util::connectHook('OC_Filesystem', 'setup', '\\OC\\Files\\Storage\\Shared', 'setup');
     // Filesystem related hooks
     \OCA\Encryption\Helper::registerFilesystemHooks();
     // Sharing related hooks
     \OCA\Encryption\Helper::registerShareHooks();
     // clear and register proxies
     \OC_FileProxy::clearProxies();
     \OC_FileProxy::register(new OCA\Encryption\Proxy());
     // create test user
     self::loginHelper(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER1, true);
     self::loginHelper(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER2, true);
 }
 public function register()
 {
     $loginRecord = function ($user) {
         $UserRole = \OC::$server->getConfig()->getUserValue(\OC_User::getUser(), "settings", "role", "undefined");
         Util::writeLog('core', "user:"******" role:" . $UserRole . " action:login success", Util::INFO);
     };
     $logoutRecord = function () {
         $UserRole = \OC::$server->getConfig()->getUserValue(\OC_User::getUser(), "settings", "role", "undefined");
         Util::writeLog('core', "user:"******" role:" . $this->UserRole . " action:logout success", Util::INFO);
     };
     $createRecord = function ($node) {
         $UserRole = \OC::$server->getConfig()->getUserValue(\OC_User::getUser(), "settings", "role", "undefined");
         Util::writeLog('activity', "user:"******" role:" . $UserRole . " action:creates " . $node->getName() . " success", Util::INFO);
     };
     $deleteRecord = function ($node) {
         $UserRole = \OC::$server->getConfig()->getUserValue(\OC_User::getUser(), "settings", "role", "undefined");
         Util::writeLog('activity', "user:"******" role:" . $UserRole . " action:deletes " . $node->getName() . " success", Util::INFO);
     };
     $renameRecord = function ($node) {
         $UserRole = \OC::$server->getConfig()->getUserValue(\OC_User::getUser(), "settings", "role", "undefined");
         Util::writeLog('activity', "user:"******" role:" . $UserRole . " action:renames " . $node->getName() . " success", Util::INFO);
     };
     $touchRecord = function ($node) {
         $UserRole = \OC::$server->getConfig()->getUserValue(\OC_User::getUser(), "settings", "role", "undefined");
         Util::writeLog('activity', "user:"******" role:" . $UserRole . " action:touches " . $node->getName() . " success", Util::INFO);
     };
     Util::connectHook('OCP\\Share', 'post_shared', 'OCA\\Activity_Logging\\UserHooks', 'share');
     $this->userManager->listen('\\OC\\User', 'postLogin', $loginRecord);
     $this->userManager->listen('\\OC\\User', 'logout', $logoutRecord);
     $this->UserFolder->listen('\\OC\\Files', 'postCreate', $createRecord);
     $this->UserFolder->listen('\\OC\\Files', 'postDelete', $deleteRecord);
     $this->UserFolder->listen('\\OC\\Files', 'postRename', $renameRecord);
 }
Ejemplo n.º 7
0
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     // reset backend
     \OC_User::clearBackends();
     \OC_Group::clearBackends();
     // clear share hooks
     \OC_Hook::clear('OCP\\Share');
     \OC::registerShareHooks();
     \OCP\Util::connectHook('OC_Filesystem', 'setup', '\\OC\\Files\\Storage\\Shared', 'setup');
     // create users
     $backend = new \OC_User_Dummy();
     \OC_User::useBackend($backend);
     $backend->createUser(self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER1);
     $backend->createUser(self::TEST_FILES_SHARING_API_USER2, self::TEST_FILES_SHARING_API_USER2);
     $backend->createUser(self::TEST_FILES_SHARING_API_USER3, self::TEST_FILES_SHARING_API_USER3);
     // create group
     $groupBackend = new \OC_Group_Dummy();
     $groupBackend->createGroup(self::TEST_FILES_SHARING_API_GROUP1);
     $groupBackend->createGroup('group');
     $groupBackend->addToGroup(self::TEST_FILES_SHARING_API_USER1, 'group');
     $groupBackend->addToGroup(self::TEST_FILES_SHARING_API_USER2, 'group');
     $groupBackend->addToGroup(self::TEST_FILES_SHARING_API_USER3, 'group');
     $groupBackend->addToGroup(self::TEST_FILES_SHARING_API_USER2, self::TEST_FILES_SHARING_API_GROUP1);
     \OC_Group::useBackend($groupBackend);
 }
Ejemplo n.º 8
0
 public function setup()
 {
     Util::connectHook('OC_User', 'post_createUser', $this, 'postCreateUser');
     Util::connectHook('OC_User', 'pre_deleteUser', $this, 'preDeleteUser');
     Util::connectHook('OC_User', 'post_deleteUser', $this, 'postDeleteUser');
     Util::connectHook('OC_User', 'changeUser', $this, 'changeUser');
 }
Ejemplo n.º 9
0
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     // remember files_encryption state
     self::$stateFilesEncryption = \OC_App::isEnabled('files_encryption');
     //we don't want to tests with app files_encryption enabled
     \OC_App::disable('files_encryption');
     // reset backend
     \OC_User::clearBackends();
     \OC_User::useBackend('database');
     // clear share hooks
     \OC_Hook::clear('OCP\\Share');
     \OC::registerShareHooks();
     \OCP\Util::connectHook('OC_Filesystem', 'setup', '\\OC\\Files\\Storage\\Shared', 'setup');
     // create users
     $backend = new \OC_User_Dummy();
     \OC_User::useBackend($backend);
     $backend->createUser(self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER1);
     $backend->createUser(self::TEST_FILES_SHARING_API_USER2, self::TEST_FILES_SHARING_API_USER2);
     $backend->createUser(self::TEST_FILES_SHARING_API_USER3, self::TEST_FILES_SHARING_API_USER3);
     // create group
     $groupBackend = new \OC_Group_Dummy();
     $groupBackend->createGroup(self::TEST_FILES_SHARING_API_GROUP1);
     $groupBackend->createGroup('group');
     $groupBackend->addToGroup(self::TEST_FILES_SHARING_API_USER1, 'group');
     $groupBackend->addToGroup(self::TEST_FILES_SHARING_API_USER2, 'group');
     $groupBackend->addToGroup(self::TEST_FILES_SHARING_API_USER3, 'group');
     $groupBackend->addToGroup(self::TEST_FILES_SHARING_API_USER2, self::TEST_FILES_SHARING_API_GROUP1);
     \OC_Group::useBackend($groupBackend);
 }
Ejemplo n.º 10
0
 /**
  * Registers the filesystem hooks for basic filesystem operations.
  * All other events has to be triggered by the apps.
  */
 public static function register()
 {
     Util::connectHook('OC_Filesystem', 'post_create', 'OCA\\Activity\\FilesHooksStatic', 'fileCreate');
     Util::connectHook('OC_Filesystem', 'post_update', 'OCA\\Activity\\FilesHooksStatic', 'fileUpdate');
     Util::connectHook('OC_Filesystem', 'delete', 'OCA\\Activity\\FilesHooksStatic', 'fileDelete');
     Util::connectHook('\\OCA\\Files_Trashbin\\Trashbin', 'post_restore', 'OCA\\Activity\\FilesHooksStatic', 'fileRestore');
     Util::connectHook('OCP\\Share', 'post_shared', 'OCA\\Activity\\FilesHooksStatic', 'share');
 }
Ejemplo n.º 11
0
 /**
  * Connects Hooks
  *
  * @return null
  */
 public function addHooks()
 {
     OCUtil::connectHook('OC_User', 'post_login', $this, 'login');
     OCUtil::connectHook('OC_User', 'logout', $this, 'logout');
     OCUtil::connectHook('OC_User', 'post_setPassword', $this, 'setPassphrase');
     OCUtil::connectHook('OC_User', 'pre_setPassword', $this, 'preSetPassphrase');
     OCUtil::connectHook('OC_User', 'post_createUser', $this, 'postCreateUser');
     OCUtil::connectHook('OC_User', 'post_deleteUser', $this, 'postDeleteUser');
 }
Ejemplo n.º 12
0
 public function setUp()
 {
     self::$hookCalls = array();
     $config = \OC::$server->getConfig();
     $this->dataDir = $config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data/');
     \OC_Mount_Config::$skipTest = true;
     \OCP\Util::connectHook(Filesystem::CLASSNAME, Filesystem::signal_create_mount, get_class($this), 'createHookCallback');
     \OCP\Util::connectHook(Filesystem::CLASSNAME, Filesystem::signal_delete_mount, get_class($this), 'deleteHookCallback');
 }
Ejemplo n.º 13
0
 public function connectHooks()
 {
     \OCP\Util::connectHook('OC_User', 'pre_setPassword', $this, 'pre_setPasswordHook');
     \OCP\Util::connectHook('OC_User', 'post_setPassword', $this, 'post_setPasswordHook');
     \OCP\Util::connectHook('OC_User', 'pre_createUser', $this, 'pre_createUserHook');
     \OCP\Util::connectHook('OC_User', 'post_createUser', $this, 'post_createUserHook');
     \OCP\Util::connectHook('OC_User', 'pre_deleteUser', $this, 'pre_deleteUserHook');
     \OCP\Util::connectHook('OC_User', 'post_deleteUser', $this, 'post_deleteUserHook');
 }
Ejemplo n.º 14
0
 public static function setUpHooks()
 {
     self::clear();
     \OCP\Util::connectHook(Filesystem::CLASSNAME, Filesystem::signal_create, '\\Test\\HookHelper', 'createCallback');
     \OCP\Util::connectHook(Filesystem::CLASSNAME, Filesystem::signal_update, '\\Test\\HookHelper', 'updateCallback');
     \OCP\Util::connectHook(Filesystem::CLASSNAME, Filesystem::signal_write, '\\Test\\HookHelper', 'writeCallback');
     \OCP\Util::connectHook(Filesystem::CLASSNAME, Filesystem::signal_post_create, '\\Test\\HookHelper', 'postCreateCallback');
     \OCP\Util::connectHook(Filesystem::CLASSNAME, Filesystem::signal_post_update, '\\Test\\HookHelper', 'postUpdateCallback');
     \OCP\Util::connectHook(Filesystem::CLASSNAME, Filesystem::signal_post_write, '\\Test\\HookHelper', 'postWriteCallback');
 }
 /**
  * Registers the filesystem hooks for basic filesystem operations.
  * All other events has to be triggered by the apps.
  */
 public static function register()
 {
     Util::connectHook('OC_Filesystem', 'post_create', 'OCA\\Activity\\FilesHooksStatic', 'fileCreate');
     Util::connectHook('OC_Filesystem', 'post_update', 'OCA\\Activity\\FilesHooksStatic', 'fileUpdate');
     Util::connectHook('OC_Filesystem', 'delete', 'OCA\\Activity\\FilesHooksStatic', 'fileDelete');
     Util::connectHook('\\OCA\\Files_Trashbin\\Trashbin', 'post_restore', 'OCA\\Activity\\FilesHooksStatic', 'fileRestore');
     Util::connectHook('OCP\\Share', 'post_shared', 'OCA\\Activity\\FilesHooksStatic', 'share');
     $eventDispatcher = \OC::$server->getEventDispatcher();
     $eventDispatcher->addListener('OCA\\Files::loadAdditionalScripts', ['OCA\\Activity\\FilesHooksStatic', 'onLoadFilesAppScripts']);
 }
Ejemplo n.º 16
0
 public static function connectHooks()
 {
     // Listen to write signals
     \OCP\Util::connectHook('OC_Filesystem', 'write', "OCA\\Files_Versions\\Hooks", "write_hook");
     // Listen to delete and rename signals
     \OCP\Util::connectHook('OC_Filesystem', 'post_delete', "OCA\\Files_Versions\\Hooks", "remove_hook");
     \OCP\Util::connectHook('OC_Filesystem', 'delete', "OCA\\Files_Versions\\Hooks", "pre_remove_hook");
     \OCP\Util::connectHook('OC_Filesystem', 'rename', "OCA\\Files_Versions\\Hooks", "rename_hook");
     \OCP\Util::connectHook('OC_Filesystem', 'copy', "OCA\\Files_Versions\\Hooks", "copy_hook");
 }
Ejemplo n.º 17
0
 public static function setUpBeforeClass()
 {
     // clear share hooks
     \OC_Hook::clear('OCP\\Share');
     \OC::registerShareHooks();
     \OCA\Files_Versions\Hooks::connectHooks();
     \OCP\Util::connectHook('OC_Filesystem', 'setup', '\\OC\\Files\\Storage\\Shared', 'setup');
     // create test user
     self::loginHelper(self::TEST_VERSIONS_USER2, true);
     self::loginHelper(self::TEST_VERSIONS_USER, true);
 }
Ejemplo n.º 18
0
 public static function register()
 {
     $signals = array(\OC\Files\Filesystem::signal_post_create, \OC\Files\Filesystem::signal_delete, 'post_delete', \OC\Files\Filesystem::signal_post_rename, \OC\Files\Filesystem::signal_post_write, \OC\Files\Filesystem::signal_write);
     if (defined('\\OC\\Files\\Filesystem::signal_post_update')) {
         self::$supportsPostUpdate = true;
         $signals[] = \OC\Files\Filesystem::signal_post_update;
     }
     foreach ($signals as $signal) {
         \OCP\Util::connectHook(\OC\Files\Filesystem::CLASSNAME, $signal, self::CLASSNAME, $signal . 'Hook');
     }
 }
Ejemplo n.º 19
0
 public static function registerHooks()
 {
     \OCP\Util::connectHook('OC_Filesystem', 'setup', '\\OCA\\Files_Sharing\\External\\Manager', 'setup');
     \OCP\Util::connectHook('OC_Filesystem', 'delete', '\\OC\\Files\\Cache\\Shared_Updater', 'deleteHook');
     \OCP\Util::connectHook('OC_Filesystem', 'post_rename', '\\OC\\Files\\Cache\\Shared_Updater', 'renameHook');
     \OCP\Util::connectHook('OC_Filesystem', 'post_delete', '\\OCA\\Files_Sharing\\Hooks', 'unshareChildren');
     \OCP\Util::connectHook('OC_Appconfig', 'post_set_value', '\\OCA\\Files\\Share\\Maintainer', 'configChangeHook');
     \OCP\Util::connectHook('OCP\\Share', 'post_shared', '\\OC\\Files\\Cache\\Shared_Updater', 'postShareHook');
     \OCP\Util::connectHook('OCP\\Share', 'post_unshare', '\\OC\\Files\\Cache\\Shared_Updater', 'postUnshareHook');
     \OCP\Util::connectHook('OCP\\Share', 'post_unshareFromSelf', '\\OC\\Files\\Cache\\Shared_Updater', 'postUnshareFromSelfHook');
     \OCP\Util::connectHook('OC_User', 'post_deleteUser', '\\OCA\\Files_Sharing\\Hooks', 'deleteUser');
 }
Ejemplo n.º 20
0
 /**
  * @brief Registers the filesystem hooks for basic filesystem operations.
  * All other events has to be triggered by the apps.
  */
 public static function register()
 {
     \OCP\Util::connectHook('OC_Filesystem', 'post_create', 'OCA\\Activity\\Hooks', 'fileCreate');
     \OCP\Util::connectHook('OC_Filesystem', 'post_update', 'OCA\\Activity\\Hooks', 'fileUpdate');
     \OCP\Util::connectHook('OC_Filesystem', 'delete', 'OCA\\Activity\\Hooks', 'fileDelete');
     \OCP\Util::connectHook('OCP\\Share', 'post_shared', 'OCA\\Activity\\Hooks', 'share');
     \OCP\Util::connectHook('OC_User', 'post_deleteUser', 'OCA\\Activity\\Hooks', 'deleteUser');
     // hooking up the activity manager
     $am = \OC::$server->getActivityManager();
     $am->registerConsumer(function () {
         return new Consumer();
     });
 }
Ejemplo n.º 21
0
 protected function setUp()
 {
     parent::setUp();
     \OC_Hook::clear('OC_Filesystem', 'setup');
     \OCP\Util::connectHook('OC_Filesystem', 'setup', '\\OC\\Files\\Storage\\Shared', 'setup');
     \OCP\Share::registerBackend('file', 'OC_Share_Backend_File');
     \OCP\Share::registerBackend('folder', 'OC_Share_Backend_Folder', 'file');
     $this->datadir = \OC_Config::getValue('datadirectory');
     $this->tmpDir = \OC_Helper::tmpFolder();
     \OC_Config::setValue('datadirectory', $this->tmpDir);
     $this->userBackend = new \OC_User_Dummy();
     \OC_User::useBackend($this->userBackend);
 }
Ejemplo n.º 22
0
 public static function setUpBeforeClass()
 {
     // reset backend
     \OC_User::clearBackends();
     \OC_User::useBackend('database');
     // clear share hooks
     \OC_Hook::clear('OCP\\Share');
     \OC::registerShareHooks();
     \OCP\Util::connectHook('OC_Filesystem', 'setup', '\\OC\\Files\\Storage\\Shared', 'setup');
     // create users
     self::loginHelper(self::TEST_FILES_SHARING_API_USER1, true);
     self::loginHelper(self::TEST_FILES_SHARING_API_USER2, true);
     self::loginHelper(self::TEST_FILES_SHARING_API_USER3, true);
 }
Ejemplo n.º 23
0
 public static function connectHooks()
 {
     // Listen to write signals
     \OCP\Util::connectHook('OC_Filesystem', 'write', 'OCA\\Files_Versions\\Hooks', 'write_hook');
     // Listen to delete and rename signals
     \OCP\Util::connectHook('OC_Filesystem', 'post_delete', 'OCA\\Files_Versions\\Hooks', 'remove_hook');
     \OCP\Util::connectHook('OC_Filesystem', 'delete', 'OCA\\Files_Versions\\Hooks', 'pre_remove_hook');
     \OCP\Util::connectHook('OC_Filesystem', 'post_rename', 'OCA\\Files_Versions\\Hooks', 'rename_hook');
     \OCP\Util::connectHook('OC_Filesystem', 'post_copy', 'OCA\\Files_Versions\\Hooks', 'copy_hook');
     \OCP\Util::connectHook('OC_Filesystem', 'rename', 'OCA\\Files_Versions\\Hooks', 'pre_renameOrCopy_hook');
     \OCP\Util::connectHook('OC_Filesystem', 'copy', 'OCA\\Files_Versions\\Hooks', 'pre_renameOrCopy_hook');
     $eventDispatcher = \OC::$server->getEventDispatcher();
     $eventDispatcher->addListener('OCA\\Files::loadAdditionalScripts', ['OCA\\Files_Versions\\Hooks', 'onLoadFilesAppScripts']);
 }
Ejemplo n.º 24
0
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     // reset backend
     \OC_User::clearBackends();
     \OC_User::useBackend('database');
     \OCA\Files_Encryption\Helper::registerFilesystemHooks();
     \OCA\Files_Encryption\Helper::registerUserHooks();
     \OCA\Files_Encryption\Helper::registerShareHooks();
     \OC::registerShareHooks();
     \OCP\Util::connectHook('OC_Filesystem', 'setup', '\\OC\\Files\\Storage\\Shared', 'setup');
     // clear and register hooks
     \OC_FileProxy::clearProxies();
     \OC_FileProxy::register(new \OCA\Files_Encryption\Proxy());
 }
Ejemplo n.º 25
0
 public function viewToNode()
 {
     Util::connectHook('OC_Filesystem', 'write', $this, 'write');
     Util::connectHook('OC_Filesystem', 'post_write', $this, 'postWrite');
     Util::connectHook('OC_Filesystem', 'create', $this, 'create');
     Util::connectHook('OC_Filesystem', 'post_create', $this, 'postCreate');
     Util::connectHook('OC_Filesystem', 'delete', $this, 'delete');
     Util::connectHook('OC_Filesystem', 'post_delete', $this, 'postDelete');
     Util::connectHook('OC_Filesystem', 'rename', $this, 'rename');
     Util::connectHook('OC_Filesystem', 'post_rename', $this, 'postRename');
     Util::connectHook('OC_Filesystem', 'copy', $this, 'copy');
     Util::connectHook('OC_Filesystem', 'post_copy', $this, 'postCopy');
     Util::connectHook('OC_Filesystem', 'touch', $this, 'touch');
     Util::connectHook('OC_Filesystem', 'post_touch', $this, 'postTouch');
 }
Ejemplo n.º 26
0
 protected function setUp()
 {
     parent::setUp();
     \OCP\Util::connectHook('OC_Filesystem', 'post_delete', '\\OCA\\Files_Sharing\\Hooks', 'unshareChildren');
     $this->folder = self::TEST_FOLDER_NAME;
     $this->subfolder = '/subfolder_share_api_test';
     $this->subsubfolder = '/subsubfolder_share_api_test';
     $this->filename = '/share-api-test';
     // save file with content
     $this->view->mkdir($this->folder);
     $this->view->mkdir($this->folder . $this->subfolder);
     $this->view->mkdir($this->folder . $this->subfolder . $this->subsubfolder);
     $this->view->file_put_contents($this->folder . $this->filename, $this->data);
     $this->view->file_put_contents($this->folder . $this->subfolder . $this->filename, $this->data);
 }
Ejemplo n.º 27
0
 public static function init()
 {
     //check if curl extension installed
     if (!in_array('curl', get_loaded_extensions())) {
         \OCP\Util::writeLog(self::APP_ID, 'This app needs cUrl PHP extension', \OCP\Util::DEBUG);
         return false;
     }
     \OC::$CLASSPATH['OCA\\User_persona\\Policy'] = self::APP_PATH . 'lib/policy.php';
     \OCP\App::registerAdmin(self::APP_ID, 'settings');
     if (!\OCP\User::isLoggedIn()) {
         \OC::$CLASSPATH['OCA\\User_persona\\Validator'] = self::APP_PATH . 'lib/validator.php';
         \OC::$CLASSPATH['OC_USER_PERSONA'] = self::APP_PATH . 'user_persona.php';
         \OC_User::useBackend('persona');
         \OCP\Util::connectHook('OC_User', 'post_login', "OCA\\User_persona\\Validator", "postlogin_hook");
         \OCP\Util::addScript(self::APP_ID, 'utils');
     }
 }
Ejemplo n.º 28
0
 public static function register()
 {
     \OCP\Share::registerBackend(App::SHARECALENDAR, '\\OCA\\CalendarPlus\\Share\\Backend\\Calendar');
     \OCP\Share::registerBackend(App::SHAREEVENT, '\\OCA\\CalendarPlus\\Share\\Backend\\Event');
     \OCP\Util::connectHook('OC_User', 'post_createUser', '\\OCA\\CalendarPlus\\Hooks', 'createUser');
     \OCP\Util::connectHook('OC_User', 'post_deleteUser', '\\OCA\\CalendarPlus\\Hooks', 'deleteUser');
     if (\OC::$server->getAppManager()->isEnabledForUser('activity')) {
         \OCP\Util::connectHook('OCP\\Share', 'post_shared', '\\OCA\\CalendarPlus\\Hooks', 'share');
         \OCP\Util::connectHook('OCP\\Share', 'post_unshare', '\\OCA\\CalendarPlus\\Hooks', 'unshare');
     }
     //		\OCP\Util::connectHook('OCP\Share', 'share_internal_mail', 'OCA\Calendar\Hooks', 'shareInternalMail');
     //\OCP\Util::connectHook('\OCA\CalendarPlus', 'addEvent', '\OCA\CalendarPlus\Repeat', 'generate');
     //\OCP\Util::connectHook('\OCA\CalendarPlus', 'editEvent', '\OCA\CalendarPlus\Repeat', 'update');
     //	\OCP\Util::connectHook('\OCA\CalendarPlus', 'deleteEvent', '\OCA\CalendarPlus\Repeat', 'clean');
     //	\OCP\Util::connectHook('\OCA\CalendarPlus', 'moveEvent', '\OCA\CalendarPlus\Repeat', 'update');
     //\OCP\Util::connectHook('\OCA\CalendarPlus', 'deleteCalendar', '\OCA\CalendarPlus\Repeat', 'cleanCalendar');
 }
Ejemplo n.º 29
0
 public function setUp()
 {
     self::$hookCalls = array();
     $config = \OC::$server->getConfig();
     $this->dataDir = $config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data/');
     \OC_Mount_Config::$skipTest = true;
     // prepare BackendService mock
     $this->backendService = $this->getMockBuilder('\\OCA\\Files_External\\Service\\BackendService')->disableOriginalConstructor()->getMock();
     $authMechanisms = ['identifier:\\Auth\\Mechanism' => $this->getAuthMechMock('null', '\\Auth\\Mechanism'), 'identifier:\\Other\\Auth\\Mechanism' => $this->getAuthMechMock('null', '\\Other\\Auth\\Mechanism'), 'identifier:\\OCA\\Files_External\\Lib\\Auth\\NullMechanism' => $this->getAuthMechMock()];
     $this->backendService->method('getAuthMechanism')->will($this->returnCallback(function ($class) use($authMechanisms) {
         if (isset($authMechanisms[$class])) {
             return $authMechanisms[$class];
         }
         return null;
     }));
     $this->backendService->method('getAuthMechanismsByScheme')->will($this->returnCallback(function ($schemes) use($authMechanisms) {
         return array_filter($authMechanisms, function ($authMech) use($schemes) {
             return in_array($authMech->getScheme(), $schemes, true);
         });
     }));
     $this->backendService->method('getAuthMechanisms')->will($this->returnValue($authMechanisms));
     $sftpBackend = $this->getBackendMock('\\OCA\\Files_External\\Lib\\Backend\\SFTP', '\\OC\\Files\\Storage\\SFTP');
     $backends = ['identifier:\\OCA\\Files_External\\Lib\\Backend\\SMB' => $this->getBackendMock('\\OCA\\Files_External\\Lib\\Backend\\SMB', '\\OC\\Files\\Storage\\SMB'), 'identifier:\\OCA\\Files_External\\Lib\\Backend\\SFTP' => $sftpBackend, 'identifier:sftp_alias' => $sftpBackend];
     $backends['identifier:\\OCA\\Files_External\\Lib\\Backend\\SFTP']->method('getLegacyAuthMechanism')->willReturn($authMechanisms['identifier:\\Other\\Auth\\Mechanism']);
     $this->backendService->method('getBackend')->will($this->returnCallback(function ($backendClass) use($backends) {
         if (isset($backends[$backendClass])) {
             return $backends[$backendClass];
         }
         return null;
     }));
     $this->backendService->method('getBackends')->will($this->returnValue($backends));
     \OCP\Util::connectHook(Filesystem::CLASSNAME, Filesystem::signal_create_mount, get_class($this), 'createHookCallback');
     \OCP\Util::connectHook(Filesystem::CLASSNAME, Filesystem::signal_delete_mount, get_class($this), 'deleteHookCallback');
     $containerMock = $this->getMock('\\OCP\\AppFramework\\IAppContainer');
     $containerMock->method('query')->will($this->returnCallback(function ($name) {
         if ($name === 'OCA\\Files_External\\Service\\BackendService') {
             return $this->backendService;
         }
     }));
     \OC_Mount_Config::$app = $this->getMockBuilder('\\OCA\\Files_External\\Appinfo\\Application')->disableOriginalConstructor()->getMock();
     \OC_Mount_Config::$app->method('getContainer')->willReturn($containerMock);
 }
Ejemplo n.º 30
0
 /**
  * @brief Registers the filesystem hooks for basic filesystem operations.
  * All other events has to be triggered by the apps.
  */
 public static function register()
 {
     //Listen to create file signal
     \OCP\Util::connectHook('OC_Filesystem', 'post_create', "OCA\\Activity\\Hooks", "file_create");
     //Listen to delete file signal
     \OCP\Util::connectHook('OC_Filesystem', 'delete', "OCA\\Activity\\Hooks", "file_delete");
     //Listen to write file signal
     \OCP\Util::connectHook('OC_Filesystem', 'post_write', "OCA\\Activity\\Hooks", "file_write");
     //Listen to share signal
     \OCP\Util::connectHook('OCP\\Share', 'post_shared', "OCA\\Activity\\Hooks", "share");
     // hooking up the activity manager
     if (property_exists('OC', 'server')) {
         if (method_exists(\OC::$server, 'getActivityManager')) {
             $am = \OC::$server->getActivityManager();
             $am->registerConsumer(function () {
                 return new Consumer();
             });
         }
     }
 }