diff options
author | Björn Schießle <schiessle@owncloud.com> | 2013-06-27 16:09:22 +0400 |
---|---|---|
committer | Björn Schießle <schiessle@owncloud.com> | 2013-07-02 18:28:27 +0400 |
commit | a7b01ae74ddeb3c475dc6ec9ae4d7858068f6c24 (patch) | |
tree | 15cda733068cbdde93f885a32bb9c655e87000be /apps | |
parent | 102a0415d462bffe4f806be84439cc1e0fe332f6 (diff) |
introduce pre-disable-app hook and use it for the encryption app to reset migration status if the app was disabled
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files_encryption/appinfo/app.php | 3 | ||||
-rw-r--r-- | apps/files_encryption/hooks/hooks.php | 13 | ||||
-rwxr-xr-x | apps/files_encryption/lib/helper.php | 9 |
3 files changed, 25 insertions, 0 deletions
diff --git a/apps/files_encryption/appinfo/app.php b/apps/files_encryption/appinfo/app.php index 80c04bb0cd2..aee49b23c3f 100644 --- a/apps/files_encryption/appinfo/app.php +++ b/apps/files_encryption/appinfo/app.php @@ -22,6 +22,9 @@ if (!OC_Config::getValue('maintenance', false)) { // Filesystem related hooks OCA\Encryption\Helper::registerFilesystemHooks(); + // App manager related hooks + OCA\Encryption\Helper::registerAppHooks(); + stream_wrapper_register('crypt', 'OCA\Encryption\Stream'); // check if we are logged in diff --git a/apps/files_encryption/hooks/hooks.php b/apps/files_encryption/hooks/hooks.php index e39e068cc5d..09153918940 100644 --- a/apps/files_encryption/hooks/hooks.php +++ b/apps/files_encryption/hooks/hooks.php @@ -543,4 +543,17 @@ class Hooks { \OC_FileProxy::$enabled = $proxyStatus;
}
+
+ /**
+ * set migration status back to '0' so that all new files get encrypted
+ * if the app gets enabled again
+ * @param array $params contains the app ID
+ */
+ public static function preDisable($params) {
+ if ($params['app'] === 'files_encryption') {
+ $query = \OC_DB::prepare('UPDATE `*PREFIX*encryption` SET `migration_status`=0');
+ $query->execute();
+ }
+ }
+
}
diff --git a/apps/files_encryption/lib/helper.php b/apps/files_encryption/lib/helper.php index a22c139c503..b2045bfcea8 100755 --- a/apps/files_encryption/lib/helper.php +++ b/apps/files_encryption/lib/helper.php @@ -63,6 +63,15 @@ class Helper { } /** + * @brief register filesystem related hooks + * + */ + public static function registerAppHooks() { + + \OCP\Util::connectHook('OC_App', 'pre_disable', 'OCA\Encryption\Hooks', 'preDisable'); + } + + /** * @brief setup user for files_encryption * * @param Util $util |