From bd450d6f6b32b3174968ff81e3a376366b836387 Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Tue, 22 Oct 2013 16:15:19 +0200 Subject: [PATCH 1/3] add post_enable hook if a app gets enabled --- lib/private/app.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/private/app.php b/lib/private/app.php index 6f45b6e6dd..eca40a81cc 100644 --- a/lib/private/app.php +++ b/lib/private/app.php @@ -249,6 +249,7 @@ class OC_App{ if(isset($appdata['id'])) { OC_Appconfig::setValue( $app, 'ocsid', $appdata['id'] ); } + \OC_Hook::emit('OC_App', 'post_enable', array('app' => $app)); } }else{ throw new \Exception($l->t("No app name specified")); From eb348b776c4e6d317a42e979c9bbd379c7462b99 Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Tue, 22 Oct 2013 16:15:24 +0200 Subject: [PATCH 2/3] set the init status to "NOT_INITIALIZED" if the encryption app gets enabled --- apps/files_encryption/hooks/hooks.php | 12 ++++++++++++ apps/files_encryption/lib/helper.php | 1 + apps/files_encryption/lib/util.php | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/apps/files_encryption/hooks/hooks.php b/apps/files_encryption/hooks/hooks.php index d9a76becf2..ef216c2e2e 100644 --- a/apps/files_encryption/hooks/hooks.php +++ b/apps/files_encryption/hooks/hooks.php @@ -555,4 +555,16 @@ class Hooks { } } + /** + * set the init status to 'NOT_INITIALIZED' (0) if the app gets enabled + * @param array $params contains the app ID + */ + public static function postEnable($params) { + error_log("app was enabled!"); + if ($params['app'] === 'files_encryption') { + $session = new \OCA\Encryption\Session(new \OC\Files\View('/')); + $session->setInitialized(\OCA\Encryption\Session::NOT_INITIALIZED); + } + } + } diff --git a/apps/files_encryption/lib/helper.php b/apps/files_encryption/lib/helper.php index a754f9f28c..91dd08ec08 100755 --- a/apps/files_encryption/lib/helper.php +++ b/apps/files_encryption/lib/helper.php @@ -69,6 +69,7 @@ class Helper { public static function registerAppHooks() { \OCP\Util::connectHook('OC_App', 'pre_disable', 'OCA\Encryption\Hooks', 'preDisable'); + \OCP\Util::connectHook('OC_App', 'post_disable', 'OCA\Encryption\Hooks', 'postEnable'); } /** diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php index 53d58fbf40..b9592a32cb 100644 --- a/apps/files_encryption/lib/util.php +++ b/apps/files_encryption/lib/util.php @@ -1278,7 +1278,7 @@ class Util { // If no record is found if (empty($migrationStatus)) { \OCP\Util::writeLog('Encryption library', "Could not get migration status for " . $this->userId . ", no record found", \OCP\Util::ERROR); - return false; + return self::MIGRATION_OPEN; // If a record is found } else { return (int)$migrationStatus[0]; From 3d1d44352979436e2cd9dc93d5a097184907f335 Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Tue, 22 Oct 2013 16:21:04 +0200 Subject: [PATCH 3/3] remove debug output --- apps/files_encryption/hooks/hooks.php | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/files_encryption/hooks/hooks.php b/apps/files_encryption/hooks/hooks.php index ef216c2e2e..6e2d360917 100644 --- a/apps/files_encryption/hooks/hooks.php +++ b/apps/files_encryption/hooks/hooks.php @@ -560,7 +560,6 @@ class Hooks { * @param array $params contains the app ID */ public static function postEnable($params) { - error_log("app was enabled!"); if ($params['app'] === 'files_encryption') { $session = new \OCA\Encryption\Session(new \OC\Files\View('/')); $session->setInitialized(\OCA\Encryption\Session::NOT_INITIALIZED);